Rococo-Sepolia Token Transfers
Using Snowbridge to transfer tokens in a testnet.
Last updated
Using Snowbridge to transfer tokens in a testnet.
Last updated
Snowbridge has initially only activated support for the sending of ERC20 tokens to Polkadot. To send Ether to Polkadot you can use (Wrapped ETH). To register your own ERC20 tokens see .
If you already have you can skip this step. If not go to the contract and make a deposit.
WETH Contract Address:
Click on the Contracts tab.
Click on the Write Contract tab.
Connect your wallet.
Enter 5 Gwei (0.000000005 Ether).
Click the write button and sign the transaction using your wallet.
Snowbridge needs to be an approved spender for you to send tokens to Polkadot.
Navigate to the Contract tab, click on Write Contract, and connect your wallet.
Enter the amount that Snowbridge can spend as the wad
parameter. In this example, we have used 5 Gwei (5000000000 Wei).
Paste in the encoded call. This call will send 0.0001
ROC to parachain 1000 (Asset Hub) which will cover the existential deposit and fees for the transfer.
Click on the Submission tab where you can now edit the call further. You will want to change the beneficiary
to point to the account of your choice. In this example, we will use account 5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX
.
Sign and submit the transaction.
Get a quote for the fee required to send a token.
Navigate to the Contract tab, click Read as Proxy.
Expand quoteSendTokenFee
and input the token address.
The destination address is 1000
for Asset Hub.
The destinationFee
is always 0 for transfers to Asset Hub.
Click query, the fee is returned in the unit Wei
.
Navigate to the Contract tab and connect your wallet.
This time we will select the Write as Proxy tab.
Expand sendToken
.
The bridge charges a fee of 0.0000005
Ether for message delivery. This is the value returned from [quoteRegisterTokenFee](https://www.notion.so/Rococo-Sepolia-User-Docs-4fc668649a094246aa909ba16d59ac51?pvs=21)
.
destinationChain
is the parachain id of the destination. In this example, it is 1000 (Asset Hub).
destinationAddress.kind
is the type of address that the destination accepts. In our example, the destination is Asset Hub, which accepts kind AddressId32
(value = 1).
The destinationFee
is always 0 for transfers to Asset Hub.
amount
is how much Ether we want to send in Wei. In this example, we are sending 5 Gwei (5000000000 Wei).
The transfer process takes about ±30 minutes to get to the other side of the bridge. You can query the beneficiary account to see if the transfer is successful.
You want to query the foreignAssets.account(XcmV3MultiLocation, AccountId32)
key. Bridged assets are identified by their Multilocation relative to Asset Hub.
Two parents up.
Ethereum chain 11155111 for Sepolia.
The beneficiary
account from above to query.
When the transfer is complete the amount will appear in the storage query.
Snowbridge supports sending tokens to a user-specified destination parachain. When specifying a destination chain the funds are transfered to Asset Hub and then a reserve transfer is done from Asset Hub to the destination parachain.
An HRMP channel needs to exist between Asset Hub and the parachain.
The parachain chain needs to support XCM v3.
The parachain must support the relaychain native currency(ROC
) as payment for XCM execution.
The parachain must have a funded sovereign account on Asset Hub with an existential deposit of 0.000033333333
ROC.
The asset being transferred needs to be registered with the destination parachain. This is dependent on the chain itself.
ORML based parachains require the asset to be registered in asset-registry
pallet before transfer. Example runtime config:
pallet-assets
- An instance of the pallet-assets
can be added to store foreign assets. The asset needs to be created with create
extrinsic before transfer. Examples runtime config:
pallet-balances
- A currency adapter can be added to convert a MultiLocation from an Ethereum Asset to the local parachain currency. Examples runtime config:
Get a quote for the fee required to send a token.
Navigate to the Contract tab, click Read as Proxy.
Expand quoteSendTokenFee
and input the token address.
The destinationChain
that the token is going to be sent to. In this example it is destination parachain 2005
.
The destinationFee
is the fee used by the destination chain to pay for XCM execution. This amount in the unit of the relaychain native currency. Here we use 1,000,000 ROC CENTS
. (1 MircroROC
)
Click query, the fee is returned in the unit Wei
.
Set the destinationChain
to 2005.
If the destination chain supports 20 byte addresses they can be provided using the following parameters:
Set the address kind
to 2
for 20 byte address.
Set the address data
to the 20 byte address.
Any ERC20 token can be registered for use with Snowbridge in a single step.
Get a quote for the fee required to register a token. Navigate to the Contract tab, click Read as Proxy.
Click Read as Proxy.
Expand quoteRegisterTokenFee
. This fee is returned in the unit Wei
.
Navigate to the Contract tab, click on Write as Proxy, and connect your wallet.
Expand registerToken
.
The bridge charges a fee returned by the quoteRegisterTokenFee
call for message delivery and token creation. This fee returned by this call is in unit Wei. The fee accepted by the registerToken
call must be passed in unit Ether.
Enter ERC20 token address.
Click on the Write button and verify the transaction was processed without revert.
This will queue a message to register the asset on Asset Hub. The transfer process takes about ±30 minutes to get to the other side of the bridge. To confirm the creation of your token as an asset in AssetHub.
Two parents up.
Ethereum chain 11155111 for Sepolia.
Click on the Submission tab where you can now edit the call further.
Select the dest
. Two parents up.
Ethereum chain 11155111
for Sepolia.
You will want to change the beneficiary
Mulitlocation to point to the account of your choice. In this example, we will use the Ethereum account 0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f
.
Specify the parents for the asset
. Two parents up.
Specify the Ethereum chain id for the destination. Ethereum chain 11155111 for Sepolia.
The amount of the token you want to send. In the example, 5 Gwei (5000000000 Wei).
Select 0 as the fee asset item to use on the destination. This means that WETH is used as a fee item. However, Snowbridge does not charge fees on the destination, so no fees will be deducted with WETH. A fee will be charged on the ROC on assethub for the transfer. There is no simple way to get a quote fee currently. You should have a balance of atleast 3 ROC before you attempt to transfer.
Use unlimited weight for the transfer.
Sign and submit the transaction. Ensure that it executions without errors by checking its status in the block.
Select the token transfers tab.
View the transfer transaction. The source method will SubmitV1
which means it came from the Snowbridge Gateway contract.
You can also verify using your wallet. In MetaMask we can see our 5 Gwei has arrived.
WETH Contract Address:
Enter Snowbridge’s Gateway contract as the guy
(spender) parameter. Gateway Contract Address:
You can now send to Polkadot using the Snowbridge Gateway. Assets are held in reserve on the .
To send to a beneficiary
account it must have at least an existential deposit of 0.000033333333
ROC on Asset Hub. Before transfer, you will first need to teleport assets to the Asset Hub. This step only needs to be done once per beneficiary.
Go Polkadot.js web interface’s for the Rococo relaychain. Click on the Decode tab.
Go Polkadot.js web interface’s for Asset Hub. Click on the storage tab and query state system.account
to check if your funds were successfully teleported.
Gateway Contract Address:
With the beneficiary
account set up on Asset Hub and the required fees queried, we can now send .
Gateway Contract Address:
token
is the address of the ERC20 token contract. In this example, it is the token contract.
destinationAddress.data
is the AccountId32
(public key hex) for the beneficiary
we set up on Asset Hub. To get the public key hex you can use subkey cli or this ’s AccountId to Hex tool.
Go Polkadot.js web interface’s for the Asset Hub. Click on the storage tab.
The token address. In this example, it is the contract address.
The parachain needs to be configured to allow assets from AssetHub to be used as reserve assets. See .
.
.
.
.
Most of the steps will be the same as the pre-transfer steps are the same as .
The token needs to be .
You will need to .
The Snowbridge Gateway will need to be an.
The beneficiary
account must have at least an existential deposit of a sufficient asset on the destination chain to exist and receive tokens. The sufficient asset and existential deposit depend on the destination chain. See the .
Gateway Contract Address:
You can now send the token just like with the following changes.
Add the fee . In this example it is 0,000000500025
Ether.
Supply the destinationFee
that was . Here we use 1,000,000 ROC CENTS
. (1 MircroROC
)
Gateway Contract Address:
Go Polkadot.js web interface’s for Asset Hub. Click on the storage tab.
You want to query the foreignAssets.asset(XcmV3MultiLocation)
key. Bridged assets are identified by their .
The token address that you registered. In this example, it is the contract address.
When the registration is complete the asset will appear in the storage query with a supply of 0 and 0 accounts. Use to transfer some of your tokens to mint it on Asset Hub.
Tokens are held in the . You can send ERC20 tokens back across the bridge from there.
Go to the Polkadot.js web interfaces for Asset Hub. Click on the Decode tab.
Paste in the encoded call. This call with transfer 5 Gwei (5000000000 Wei) of to the
destination Ethereum address 0x0000000000000000000000000000000000000000
using the bridgeTransfer.transferAssets(dest, beneficiary, assets, feeAssetItem, weightLimit)
extrinsic.
Select the account you want to transfer from. In this example, we will use the account 5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX
.
The token address. In this example, it is the contract address.
The transfer process takes about ±45 minutes to get to the other side of the bridge. You can verify by searching at the destination address in . In this example, we used the Ethereum address [0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f](https://sepolia.etherscan.io/address/0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f)
.