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 WETH (Wrapped ETH). To register your own ERC20 tokens see Registering Tokens.
If you already have WETH you can skip this step. If not go to the WETH contract and make a deposit.
WETH Contract Address: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
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.
WETH Contract Address: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
Navigate to the Contract tab, click on Write Contract, and connect your wallet.
Enter Snowbridge’s Gateway contract as the guy
(spender) parameter. Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
Enter the amount that Snowbridge can spend as the wad
parameter. In this example, we have used 5 Gwei (5000000000 Wei).
You can now send WETH to Polkadot using the Snowbridge Gateway. Assets are held in reserve on the Asset Hub.
To send WETH 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 extrinsic screen for the Rococo relaychain. Click on the Decode tab.
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.
Go Polkadot.js web interface’s chain state screen for Asset Hub. Click on the storage tab and query state system.account
to check if your funds were successfully teleported.
Get a quote for the fee required to send a token.
Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
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
.
With the beneficiary
account set up on Asset Hub and the required fees queried, we can now send WETH.
Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
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)
.
token
is the address of the ERC20 token contract. In this example, it is the WETH token contract.
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).
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 handy website’s AccountId to Hex tool.
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.
Go Polkadot.js web interface’s chain state screen for the Asset Hub. Click on the storage tab.
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 token address. In this example, it is the WETH contract address.
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 parachain needs to be configured to allow assets from AssetHub to be used as reserve assets. See Penpal XCM config.
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:
Most of the steps will be the same as the pre-transfer steps are the same as sending tokens to Asset Hub.
The token needs to be registered on Asset Hub.
You will need to deposit ETH to get WETH.
The Snowbridge Gateway will need to be an approved spender.
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 Asset Hub example.
Get a quote for the fee required to send a token.
Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
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
.
You can now send the token just like sending to Asset Hub with the following changes.
Add the fee returned from quote. In this example it is 0,000000500025
Ether.
Set the destinationChain
to 2005.
Supply the destinationFee
that was provided to the quote. Here we use 1,000,000 ROC CENTS
. (1 MircroROC
)
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.
Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
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.
Go Polkadot.js web interface’s chain state screen for Asset Hub. Click on the storage tab.
You want to query the foreignAssets.asset(XcmV3MultiLocation)
key. Bridged assets are identified by their Multilocation relative to Asset Hub.
Two parents up.
Ethereum chain 11155111 for Sepolia.
The token address that you registered. In this example, it is the WETH contract address.
When the registration is complete the asset will appear in the storage query with a supply of 0 and 0 accounts. Use Send Token to transfer some of your tokens to mint it on Asset Hub.
Tokens are held in the Asset Hub. You can send ERC20 tokens back across the bridge from there.
Go to the Polkadot.js web interfaces extrinsics screen for Asset Hub. Click on the Decode tab.
Paste in the encoded call. This call with transfer 5 Gwei (5000000000 Wei) of WETH to the
destination Ethereum address 0x0000000000000000000000000000000000000000
using the bridgeTransfer.transferAssets(dest, beneficiary, assets, feeAssetItem, weightLimit)
extrinsic.
Click on the Submission tab where you can now edit the call further.
Select the account you want to transfer WETH from. In this example, we will use the account 5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX
.
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 token address. In this example, it is the WETH contract address.
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.
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 Etherscan. In this example, we used the Ethereum address [0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f](https://sepolia.etherscan.io/address/0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f)
.
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.