Skip to content

How to Pay for Web3Telegram

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 RLC.

Using Vouchers for Web3Telegram Chain Not Supported

Step 1: Obtain a Voucher

  • Acquire Vouchers: Obtain vouchers through the iExec Builder Dashboard. 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 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

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 RLC for fallback payment in Web3Telegram, refer to the Using RLC with Web3Telegram section.

Step 4: Execute Web3Telegram's sendTelegram Function

When using a voucher for payment, set the useVoucher parameter to true:

ts

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,
});

Using RLC for Web3Telegram

If you choose to use RLC 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 RLC

  • In your JS/TS project, run npm install iexec
  • Instantiate the iExec SDK (see the doc)
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 which covers all available DEX and CEX options.

For detailed instructions on how to bridge RLC tokens between networks, see our Bridge guide which covers all supported networks and bridging methods.

Deposit RLC

Deposit the RLC into your iExec account using the command:

javascript
iexec.account.deposit(RLC_amount);

This converts RLC 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 RLC:

ts

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,
});

Withdraw sRLC (If Desired)

Convert sRLC back to RLC and withdraw to your wallet using:

javascript
iexec.account.withdraw(RLC_amount);