Rococo-Sepolia Token Transfers
Using Snowbridge to transfer tokens in a testnet.
Sending ERC20 tokens from Ethereum to Polkadot
Sending tokens to Asset Hub
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.
1. Deposit ETH
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.
2. Approve Snowbridge as a spender for your WETH
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: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cdEnter the amount that Snowbridge can spend as the
wad
parameter. In this example, we have used 5 Gwei (5000000000 Wei).
3. Creation of an Account on Asset Hub
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 account5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX
.
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.
4. Checking the Required Fee
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
.
5. Send WETH to Polkadot
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 kindAddressId32
(value = 1).destinationAddress.data
is theAccountId32
(public key hex) for thebeneficiary
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.
Sending Tokens to a User-specified Destination Parachain
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.
1. Destination Parachain Requirements
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 thepallet-assets
can be added to store foreign assets. The asset needs to be created withcreate
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:
2. Before Performing the Transfer
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.
3. Checking the Required Fee
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 parachain2005
.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 use1,000,000 ROC CENTS
. (1 MircroROC
)Click query, the fee is returned in the unit
Wei
.
4. Sending the token
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 use1,000,000 ROC CENTS
. (1 MircroROC
)
Sending tokens to Parachains which support 20-byte Addresses (EVM based chains)
If the destination chain supports 20 byte addresses they can be provided using the following parameters:
Set the address
kind
to2
for 20 byte address.Set the address
data
to the 20 byte address.
Registering Tokens
Any ERC20 token can be registered for use with Snowbridge in a single step.
Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
1. Checking the Required Fee
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 unitWei
.
2. Register
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 theregisterToken
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.
Sending ERC20 tokens from Polkadot to Ethereum
1. Send Tokens back to Polkadot
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 address0x0000000000000000000000000000000000000000
using thebridgeTransfer.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 account0xFeAd9f6EAC9A616C8CCa1161bff792dd79093A0f
.
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.
Last updated