diff --git a/.vitepress/sidebar.ts b/.vitepress/sidebar.ts index f0786033..6bbfc610 100644 --- a/.vitepress/sidebar.ts +++ b/.vitepress/sidebar.ts @@ -240,6 +240,10 @@ export function getSidebar() { text: '🚀 Getting Started', link: '/guides/use-iapp/getting-started', }, + { + text: 'How to Pay the Executions', + link: '/guides/use-iapp/how-to-pay-executions', + }, { text: 'Run iApp with ProtectedData', link: '/guides/use-iapp/run-iapp-with-ProtectedData', @@ -248,32 +252,6 @@ export function getSidebar() { text: 'Run iApp without ProtectedData', link: '/guides/use-iapp/run-iapp-without-ProtectedData', }, - { - text: 'How to Pay the Executions', - link: '/guides/use-iapp/how-to-pay-executions', - }, - { - text: '💰 How to Pay', - collapsed: true, - items: [ - { - text: 'How to Pay for Web3Mail', - link: '/guides/use-iapp/how-to-pay/how-to-pay-for-web3mail', - }, - { - text: 'How to Pay for Web3Telegram', - link: '/guides/use-iapp/how-to-pay/how-to-pay-for-web3telegram', - }, - { - text: 'Pricing Considerations', - link: '/guides/use-iapp/how-to-pay/pricing-considerations', - }, - { - text: 'Voucher', - link: '/guides/use-iapp/how-to-pay/voucher', - }, - ], - }, ], }, ], diff --git a/src/guides/use-iapp/how-to-pay-executions.md b/src/guides/use-iapp/how-to-pay-executions.md index da98c5fa..ec96ffbc 100644 --- a/src/guides/use-iapp/how-to-pay-executions.md +++ b/src/guides/use-iapp/how-to-pay-executions.md @@ -18,24 +18,20 @@ iExec supports multiple payment methods for executing iApp: 2. **Vouchers**: Pre-funded vouchers for simplified payment 3. **Mixed Payment**: Combination of RLC and vouchers -## Method 1: Paying with RLC Tokens +## Paying with RLC Tokens RLC tokens are the native currency of the iExec network. You need to have RLC in your wallet to pay for executions. -### Setting Up RLC Payment +### Step 1: Get RLC Tokens -#### Step 1: Get RLC Tokens +For detailed information on how to obtain RLC tokens, see our +[RLC guide](/get-started/overview/rlc.md). -You can obtain RLC tokens from various exchanges: +### Step 2: Transfer to iExec Sidechain -- **Centralized Exchanges**: Binance, Coinbase, Kraken -- **Decentralized Exchanges**: Uniswap, SushiSwap -- **Direct Purchase**: Through iExec's official channels - -#### Step 2: Transfer to iExec Sidechain - -RLC tokens need to be on the iExec sidechain (Bellecour) for payments: +RLC tokens need to be staked on the iExec protocol to allow task payment. To do +this, you should use the [iExec SDK](/references/sdk.md). ```ts twoslash import { IExec, utils } from 'iexec'; @@ -57,42 +53,98 @@ console.log('Nano RLC locked:', balance.locked.toString()); await iexec.account.deposit(1_000_000_000); // Deposit 1 RLC ``` -#### Step 3: Execute with RLC Payment +Now you are ready to run a task on the iExec Protocol and pay for it. See our +guide on +[running iApps with ProtectedData](/guides/use-iapp/run-iapp-with-ProtectedData.md) +for detailed execution steps. -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; +## Paying with Vouchers + +Vouchers are pre-funded payment instruments that simplify the payment process +and can be shared with others. They are ERC-20 tokens that represent pre-funded +computation credits on the iExec network and offer several advantages: +simplified payment (no need to manage RLC transfers), sharing capabilities (can +be shared with team members or users), budget control (set spending limits), and +automated top-up (can be configured to automatically refill). + +### Step 1: Obtain a Voucher + +- **Acquire Vouchers**: Obtain vouchers through the + [iExec Builder Dashboard](https://builder.iex.ec/). Note that the number of + Web3Mail executions and the expiration time of each voucher is restricted + based on its validity period. Refer to + [pricing documentation](https://www.iex.ec/voucher) for more information. +- **Support**: For specific limitations related to your voucher, please contact + iExec Support. + +### Step 2: Use the Builder Dashboard + + + +The iExec Builder Dashboard manages vouchers and resources with an intuitive +interface for: + +- **Claiming Vouchers**: Builders can claim vouchers during the BUILD and EARN + stages. +- **Top-Up Vouchers**: Future updates will allow direct top-ups via the + dashboard. Currently, builders are redirected to Discord. +- **Checking Voucher Balance**: Track your voucher balance and usage history. + +### Step 3: Grant Allowance (If Necessary) + +Use [iExec SDK](/references/sdk.md) with `iexec.account.approve(voucherAddress)` +to authorize the voucher smart contract to debit your account if the voucher +balance is insufficient. This ensures that if the voucher alone doesn't cover +the execution cost, the remaining balance is automatically deducted from your +account. + +For additional information on using for fallback payment in +Web3Mail, refer to the **Using with Web3Mail** section. + +### Step 4: Use Voucher + +::: code-group + +```ts twoslash [Web3Mail] +import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); +const web3mail = new IExecWeb3mail(web3Provider); // ---cut--- -// Execute with RLC payment (default) -const result = await dataProtectorCore.processProtectedData({ +const sendEmail = await web3mail.sendEmail({ protectedData: '0x123abc...', - app: '0x456def...', - useVoucher: false, // Explicitly use RLC payment + emailSubject: 'My email subject', + emailContent: 'My email content', + useVoucher: true, // [!code focus] }); ``` -## Method 2: Paying with Vouchers - -Vouchers are pre-funded payment instruments that simplify the payment process -and can be shared with others. - -### Understanding Vouchers - -Vouchers are ERC-20 tokens that represent pre-funded computation credits on the -iExec network. They offer several advantages: - -- **Simplified Payment**: No need to manage RLC transfers -- **Sharing**: Can be shared with team members or users -- **Budget Control**: Set spending limits -- **Automated Top-up**: Can be configured to automatically refill +```ts twoslash [Web3Telegram] +import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram'; -### Using Vouchers for Payment +const web3Provider = getWeb3Provider('PRIVATE_KEY'); +const web3telegram = new IExecWeb3telegram(web3Provider); +// ---cut--- -#### Basic Voucher Usage +const sendTelegram = await web3telegram.sendTelegram({ + protectedData: '0x123abc...', + telegramContent: 'My telegram message content', + senderName: 'Awesome project team', + label: 'some-custom-id', + workerpoolAddressOrEns: 'prod-v8-bellecour.main.pools.iexec.eth', + dataMaxPrice: 42, + appMaxPrice: 42, + workerpoolMaxPrice: 42, + useVoucher: true, // [!code focus] +}); +``` -```ts twoslash +```ts twoslash [Any iApp] import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); @@ -101,10 +153,12 @@ const dataProtectorCore = new IExecDataProtectorCore(web3Provider); const result = await dataProtectorCore.processProtectedData({ protectedData: '0x123abc...', app: '0x456def...', - useVoucher: true, // Use voucher for payment + useVoucher: true, // [!code focus] }); ``` +::: + ::: tip If your voucher doesn't have enough to cover the deal, the SDK @@ -114,9 +168,9 @@ has sufficient funds for this transfer to proceed. ::: -#### Using Someone Else Voucher +### Step 4: Use Someone Else Voucher -```ts twoslash +```ts twoslash [Any iApp] import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); @@ -125,8 +179,8 @@ const dataProtectorCore = new IExecDataProtectorCore(web3Provider); const result = await dataProtectorCore.processProtectedData({ protectedData: '0x123abc...', app: '0x456def...', - useVoucher: true, - voucherOwner: '0x5714eB...', // Voucher owner's address + useVoucher: true, // [!code focus] + voucherOwner: '0x5714eB...', // [!code focus] }); ``` @@ -169,281 +223,25 @@ const result = await dataProtectorCore.processProtectedData({ ::: info -All price parameters are in **nRLC** (nano RLC). The default value for all price -parameters is `0`, which means no maximum price limit is set. +All price parameters are in nRLC (nano RLC). The default value for all price +parameters is 0, which means only free resources are accepted. ::: -## Cost Management Strategies - -### 1. Monitor Your Balance - -Regularly check your RLC balance and voucher status: - -```ts twoslash -import { IExec, utils } from 'iexec'; - -const ethProvider = utils.getSignerFromPrivateKey( - 'bellecour', // blockchain node URL - 'PRIVATE_KEY' -); -const iexec = new IExec({ - ethProvider, -}); -const protectedDataAddress = '0x123abc...'; -// ---cut--- -// Check your balance -const balance = await iexec.account.checkBalance('0xa0c15e...'); -console.log('Nano RLC staked:', balance.stake.toString()); -console.log('Nano RLC locked:', balance.locked.toString()); - -// Check voucher balance (if applicable) -const myVoucher = await iexec.voucher.showUserVoucher('0xa0c15e...'); -console.log('Voucher info:', myVoucher); -``` - -### 2. Set Reasonable Price Limits - -Always set maximum prices to avoid unexpected costs: - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -// Good practice: Set explicit price limits -const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - dataMaxPrice: 5, // Maximum for data access - appMaxPrice: 3, // Maximum for app usage - workerpoolMaxPrice: 2, // Maximum for computation -}); -``` - -### 3. Use Vouchers for Regular Usage - -For frequent executions, consider using vouchers: - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -// Use vouchers for regular operations -const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - useVoucher: true, // Simplify payment process -}); -``` - -## Payment Troubleshooting - -### Insufficient Balance - -If you encounter insufficient balance errors: - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; -import { IExec, utils } from 'iexec'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -const ethProvider = utils.getSignerFromPrivateKey( - 'bellecour', // blockchain node URL - 'PRIVATE_KEY' -); -const iexec = new IExec({ - ethProvider, -}); -// ---cut--- -try { - const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - }); -} catch (error) { - if ( - error instanceof Error && - error.message.includes('insufficient balance') - ) { - console.log('Please add more RLC to your account'); - // Check balance and deposit more if needed - const balance = await iexec.account.checkBalance('0xa0c15e...'); - console.log('Nano RLC staked:', balance.stake.toString()); - console.log('Nano RLC locked:', balance.locked.toString()); - } -} -``` - -### Voucher Authorization Issues - -If voucher payment fails: - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -try { - const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - useVoucher: true, - voucherOwner: '0x5714eB...', - }); -} catch (error) { - if (error instanceof Error && error.message.includes('voucher')) { - console.log('Voucher authorization failed. Check voucher permissions.'); - } -} -``` - -### Price Too High Errors - -If execution fails due to price constraints: - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -try { - const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - dataMaxPrice: 2, // Low price limit - appMaxPrice: 1, - workerpoolMaxPrice: 1, - }); -} catch (error) { - if (error instanceof Error && error.message.includes('price')) { - console.log('Increase price limits or wait for lower prices'); - // Retry with higher prices - const retryResult = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - dataMaxPrice: 8, // Higher price limit - appMaxPrice: 5, - workerpoolMaxPrice: 3, - }); - } -} -``` - -## Best Practices - -### 1. Always Set Price Limits - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -// Never execute without price limits -const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - dataMaxPrice: 5, // Always set price limits - appMaxPrice: 3, - workerpoolMaxPrice: 2, -}); -``` - -### 2. Use Vouchers for Production - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -// Use vouchers for production applications -const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - useVoucher: true, // More reliable for production -}); -``` - -### 3. Monitor Costs Regularly - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; -import { IExec, utils } from 'iexec'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -const ethProvider = utils.getSignerFromPrivateKey( - 'bellecour', // blockchain node URL - 'PRIVATE_KEY' -); -const iexec = new IExec({ - ethProvider, -}); -// ---cut--- -// Check costs before and after execution -const balanceBefore = await iexec.account.checkBalance('0xa0c15e...'); -const result = await dataProtectorCore.processProtectedData({ - protectedData: '0x123abc...', - app: '0x456def...', - dataMaxPrice: 5, - appMaxPrice: 3, - workerpoolMaxPrice: 2, -}); -const balanceAfter = await iexec.account.checkBalance('0xa0c15e...'); -console.log( - 'Cost:', - balanceBefore.stake.toString(), - '->', - balanceAfter.stake.toString() -); -``` - -### 4. Handle Payment Errors Gracefully - -```ts twoslash -import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const dataProtectorCore = new IExecDataProtectorCore(web3Provider); -// ---cut--- -const executeWithPaymentRetry = async (params: any, maxRetries = 3) => { - for (let i = 0; i < maxRetries; i++) { - try { - return await dataProtectorCore.processProtectedData(params); - } catch (error) { - if ( - error instanceof Error && - error.message.includes('insufficient balance') - ) { - console.log('Insufficient balance, please add more RLC'); - break; - } - if (i === maxRetries - 1) throw error; - console.log(`Payment retry ${i + 1}/${maxRetries}`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - } - } -}; -``` - ## Next Steps Now that you understand payment methods: - Learn about [Run iApp with ProtectedData](/guides/use-iapp/run-iapp-with-ProtectedData) -- Explore [Getting Started with iApp](/guides/use-iapp/getting-started) -- Review the pricing information above for detailed cost analysis +- Learn about + [Run iApp without ProtectedData](/guides/use-iapp/run-iapp-without-ProtectedData) diff --git a/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3mail.md b/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3mail.md deleted file mode 100644 index 599832b1..00000000 --- a/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3mail.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: How to Pay for Web3Mail -description: - Learn how to pay for Web3Mail's confidential computing power using vouchers - and RLC for secure, blockchain-based email communication. ---- - -# How to Pay for Web3Mail - -[Web3Mail](/references/web3mail) offers secure, blockchain-based communication -by encrypting emails and protecting user privacy. - -The `sendEmail` function uses iExec's protocol to encrypt and send messages, -ensuring secure and decentralized email exchanges. - -This guide shows how to pay for Web3Mail using **vouchers** and -****. - -## Using Vouchers for Web3Mail - -### Step 1: Obtain a Voucher - -- **Acquire Vouchers**: Obtain vouchers through the - [iExec Builder Dashboard](https://builder.iex.ec/). Note that the number of - Web3Mail executions and the expiration time of each voucher is restricted - based on its validity period. Refer to - [pricing documentation](https://www.iex.ec/voucher) for more information. -- **Support**: For specific limitations related to your voucher, please contact - iExec Support. - -### Step 2: Use the Builder Dashboard - - - Builder dashboard screenshot - - -The iExec Builder Dashboard manages vouchers and resources with an intuitive -interface for: - -- **Claiming Vouchers**: Builders can claim vouchers during the BUILD and EARN - stages. -- **Top-Up Vouchers**: Future updates will allow direct top-ups via the - dashboard. Currently, builders are redirected to Discord. -- **Checking Voucher Balance**: Track your voucher balance and usage history. - -🧙🏼 [Go here](https://builder.iex.ec/) - -### Step 3: Grant Allowance (If Necessary) - -Use `iexec.account.approve(voucherAddress)` to authorize the voucher smart -contract to debit your account if the voucher balance is insufficient. This -ensures that if the voucher alone doesn't cover the execution cost, the -remaining balance is automatically deducted from your account. - -For additional information on using for fallback payment in -Web3Mail, refer to the **Using with Web3Mail** section. - -### Step 4: Execute Web3Mail's SendEmail Function - -When using a voucher for payment, set the `useVoucher` parameter to `true`: - -```ts twoslash -import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const web3mail = new IExecWeb3mail(web3Provider); -// ---cut--- -const sendEmail = await web3mail.sendEmail({ - protectedData: '0x123abc...', - emailSubject: 'My email subject', - emailContent: 'My email content', - useVoucher: true, // [!code focus] -}); -``` - -## Using for Web3Mail - -If you choose to use to cover the computational cost of Web3Mail -(or if you need to cover data access costs such as retrieving the recipient's -email address), follow these steps: - -### Install the iExec SDK - -To manage RLC tokens, developers must use the iExec SDK, which offers all the -necessary tools for interacting with the iExec platform. This includes -depositing, withdrawing, and checking balances of RLC and - -- In your JS/TS project, run `npm install iexec` -- Instantiate the iExec SDK (see the - [doc](https://github.com/iExecBlockchainComputing/iexec-sdk/blob/master/docs/README.md#quick-start)) - -```javascript -import { IExec } from 'iexec'; -// Connect to injected provider -const iexec = new IExec({ ethProvider: window.ethereum }); -``` - -### Purchase RLC - -Obtain RLC tokens from a supported cryptocurrency exchange. For detailed -information on how to buy RLC tokens, see our -[RLC Token guide](/get-started/overview/rlc) which covers all available DEX and -CEX options. - -For detailed instructions on how to bridge RLC tokens between networks, see our -[Bridge guide](/get-started/tooling-and-explorers/bridge) which covers all -supported networks and bridging methods. - -### Deposit - -Deposit the into your iExec account using the command: - -```javascript -iexec.account.deposit(RLC_amount); -``` - -This converts into sRLC, used as proof of funds for task -execution. - -### Check sRLC Balance - -Use the command below to check your balance: - -```javascript -iexec.account.show(); -``` - -### Execute sendEmail - -Set the `useVoucher` parameter to `false` when using Web3Mail's sendEmail -function to pay with : - -```ts twoslash -import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const web3mail = new IExecWeb3mail(web3Provider); -// ---cut--- -const sendEmail = await web3mail.sendEmail({ - protectedData: '0x123abc...', - emailSubject: 'My email subject', - emailContent: 'My email content', - useVoucher: false, // [!code focus] -}); -``` - -### Withdraw sRLC (If Desired) - -Convert sRLC back to and withdraw to your wallet using: - -```javascript -iexec.account.withdraw(RLC_amount); -``` - - diff --git a/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3telegram.md b/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3telegram.md deleted file mode 100644 index e9a9d098..00000000 --- a/src/guides/use-iapp/how-to-pay/how-to-pay-for-web3telegram.md +++ /dev/null @@ -1,172 +0,0 @@ ---- -title: How to Pay for Web3Telegram -description: - Learn how to pay for Web3Telegram's confidential computing power using - vouchers and RLC for secure, blockchain-based email communication. ---- - -# How to Pay for Web3Telegram - -[Web3Telegram](/references/web3telegram) offers secure, blockchain-based -communication by encrypting messages and protecting user privacy. - -The `sendTelegram` function uses iExec's protocol to encrypt and send messages, -ensuring secure and decentralized email exchanges. - -This guide shows how to pay for Web3Telegram using **vouchers** and -****. - -## Using Vouchers for Web3Telegram - -### Step 1: Obtain a Voucher - -- **Acquire Vouchers**: Obtain vouchers through the - [iExec Builder Dashboard](https://builder.iex.ec/). Note that the number of - Web3Telegram executions and the expiration time of each voucher is restricted - based on its validity period. Refer to - [pricing documentation](https://www.iex.ec/voucher) for more information. -- **Support**: For specific limitations related to your voucher, please contact - iExec Support. - -### Step 2: Use the Builder Dashboard - - - Builder dashboard screenshot - - -The iExec Builder Dashboard manages vouchers and resources with an intuitive -interface for: - -- **Claiming Vouchers**: Builders can claim vouchers during the BUILD and EARN - stages. -- **Top-Up Vouchers**: Future updates will allow direct top-ups via the - dashboard. Currently, builders are redirected to Discord. -- **Checking Voucher Balance**: Track your voucher balance and usage history. - -🧙🏼 [Go here](https://builder.iex.ec/) - -### Step 3: Grant Allowance (If Necessary) - -Use `iexec.account.approve(voucherAddress)` to authorize the voucher smart -contract to debit your account if the voucher balance is insufficient. This -ensures that if the voucher alone doesn't cover the execution cost, the -remaining balance is automatically deducted from your account. - -For additional information on using for fallback payment in -Web3Telegram, refer to the **Using with Web3Telegram** section. - -### Step 4: Execute Web3Telegram's `sendTelegram` Function - -When using a voucher for payment, set the `useVoucher` parameter to `true`: - -```ts twoslash -import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const web3telegram = new IExecWeb3telegram(web3Provider); -// ---cut--- - -const sendTelegram = await web3telegram.sendTelegram({ - protectedData: '0x123abc...', - telegramContent: 'My telegram message content', - senderName: 'Awesome project team', - label: 'some-custom-id', - workerpoolAddressOrEns: 'prod-v8-bellecour.main.pools.iexec.eth', - dataMaxPrice: 42, - appMaxPrice: 42, - workerpoolMaxPrice: 42, - useVoucher: true, // [!code focus] -}); -``` - -## Using for Web3Telegram - -If you choose to use to cover the computational cost of -Web3Telegram (or if you need to cover data access costs such as retrieving the -recipient's Chat Id), follow these steps: - -### Install the iExec SDK - -To manage RLC tokens, developers must use the iExec SDK, which offers all the -necessary tools for interacting with the iExec platform. This includes -depositing, withdrawing, and checking balances of RLC and - -- In your JS/TS project, run `npm install iexec` -- Instantiate the iExec SDK (see the - [doc](https://github.com/iExecBlockchainComputing/iexec-sdk/blob/master/docs/README.md#quick-start)) - -```javascript -import { IExec } from 'iexec'; -// Connect to injected provider -const iexec = new IExec({ ethProvider: window.ethereum }); -``` - -### Purchase RLC - -Obtain RLC tokens from a supported cryptocurrency exchange. For detailed -information on how to buy RLC tokens, see our -[RLC Token guide](/get-started/overview/rlc) which covers all available DEX and -CEX options. - -For detailed instructions on how to bridge RLC tokens between networks, see our -[Bridge guide](/get-started/tooling-and-explorers/bridge) which covers all -supported networks and bridging methods. - -### Deposit - -Deposit the into your iExec account using the command: - -```javascript -iexec.account.deposit(RLC_amount); -``` - -This converts into sRLC, used as proof of funds for task -execution. - -### Check sRLC Balance - -Use the command below to check your balance: - -```javascript -iexec.account.show(); -``` - -### Execute `sendTelegram` - -Set the `useVoucher` parameter to `false` when using Web3Telegram's sendTelegram -function to pay with : - -```ts twoslash -import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram'; - -const web3Provider = getWeb3Provider('PRIVATE_KEY'); -const web3telegram = new IExecWeb3telegram(web3Provider); -// ---cut--- - -const sendTelegram = await web3telegram.sendTelegram({ - protectedData: '0x123abc...', - telegramContent: 'My telegram message content', - senderName: 'Awesome project team', - label: 'some-custom-id', - workerpoolAddressOrEns: 'prod-v8-bellecour.main.pools.iexec.eth', - dataMaxPrice: 42, - appMaxPrice: 42, - workerpoolMaxPrice: 42, - useVoucher: false, // [!code focus] -}); -``` - -### Withdraw sRLC (If Desired) - -Convert sRLC back to and withdraw to your wallet using: - -```javascript -iexec.account.withdraw(RLC_amount); -``` - - diff --git a/src/guides/use-iapp/how-to-pay/pricing-considerations.md b/src/guides/use-iapp/how-to-pay/pricing-considerations.md deleted file mode 100644 index 09587a20..00000000 --- a/src/guides/use-iapp/how-to-pay/pricing-considerations.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Pricing Considerations -description: Pricing considerations ---- - -# Pricing Considerations - -This page is under development. - - diff --git a/src/guides/use-iapp/how-to-pay/voucher.md b/src/guides/use-iapp/how-to-pay/voucher.md deleted file mode 100644 index cf1c7822..00000000 --- a/src/guides/use-iapp/how-to-pay/voucher.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Voucher Guide -description: Voucher Guide ---- - -# Voucher Guide - -This page is under development. - - diff --git a/src/references/sdk.md b/src/references/sdk.md index 54ee6c83..f56f75db 100644 --- a/src/references/sdk.md +++ b/src/references/sdk.md @@ -9,8 +9,72 @@ The iExec SDK is a [CLI](#command-line-interface) and a [JS library](#javascripttypescript-library) that allows easy interactions with iExec decentralized marketplace in order to run off-chain computations. -iExec SDK is available on [npm](https://www.npmjs.com/package/iexec) and -[GitHub](https://github.com/iExecBlockchainComputing/iexec-sdk) +## Overview + +### Prerequisites + +Before getting started, ensure that you have the following installed on your +system: + +\- [**Node.js**](https://nodejs.org/en/) version 18 or higher + +\- [**NPM**](https://docs.npmjs.com/) (Node.js package manager) + +### Installation + +::: code-group + +```sh [npm] +npm install @iexec/dataprotector +``` + +```sh [yarn] +yarn add @iexec/dataprotector +``` + +```sh [pnpm] +pnpm add @iexec/dataprotector +``` + +```sh [bun] +bun add @iexec/dataprotector +``` + +::: + +### Instantiate SDK + +::: code-group + +```ts twoslash [Browser] +declare global { + interface Window { + ethereum: any; + } +} +// ---cut--- +import { IExec } from 'iexec'; + +// Connect to injected provider +const iexec = new IExec({ ethProvider: window.ethereum }); +``` + +```ts twoslash [NodeJS] +import { IExec, utils } from 'iexec'; + +const ethProvider = utils.getSignerFromPrivateKey( + 'http://localhost:8545', // blockchain node URL + 'YOUR_PRIVATE_KEY' +); +const iexec = new IExec({ + ethProvider, +}); +``` + +::: + +For comprehensive documentation and advanced usage examples, see the +[iExec SDK GitHub repository](https://github.com/iExecBlockchainComputing/iexec-sdk/blob/master/docs/README.md). ## Command Line Interface diff --git a/src/references/web3mail/methods/sendEmail.md b/src/references/web3mail/methods/sendEmail.md index 39d3cdfc..4eefbaa3 100644 --- a/src/references/web3mail/methods/sendEmail.md +++ b/src/references/web3mail/methods/sendEmail.md @@ -23,7 +23,7 @@ documentation for more details. For executing the `sendEmail` method with a voucher or , refer to the dedicated section in the documentation under -"[How to Pay for web3mail](/guides/use-iapp/how-to-pay/how-to-pay-for-web3mail)". +"[How to Pay for Executions](/guides/use-iapp/how-to-pay-executions.md)". ::: diff --git a/src/references/web3telegram/methods/sendTelegram.md b/src/references/web3telegram/methods/sendTelegram.md index c14135ac..6b9e1450 100644 --- a/src/references/web3telegram/methods/sendTelegram.md +++ b/src/references/web3telegram/methods/sendTelegram.md @@ -23,7 +23,7 @@ documentation for more details. For executing the `sendTelegram` method with a voucher or , refer to the dedicated section in the documentation under -"[How to Pay for web3telegram](/guides/use-iapp/how-to-pay/how-to-pay-for-web3telegram)". +"[How to Pay for Executions](/guides/use-iapp/how-to-pay-executions.md)". :::