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

  1. Click on the Contracts tab.

  2. Click on the Write Contract tab.

  3. Connect your wallet.

  4. Enter 5 Gwei (0.000000005 Ether).

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

  1. Enter Snowbridge’s Gateway contract as the guy (spender) parameter. Gateway Contract Address: 0x5b4909ce6ca82d2ce23bd46738953c7959e710cd

  2. Enter 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.

  1. Go Polkadot.js web interface’s extrinsic screen for the Rococo relaychain. Click on the Decode tab.

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

0x630b03000100a10f030001010000000000000000000000000000000000000000000000000000000000000000000304000000000284d7170000000000
  1. 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.

  1. Sign and submit the transaction.

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

  1. Navigate to the Contract tab, click Read as Proxy.

  2. Expand quoteSendTokenFee and input the token address.

  3. The destination address is 1000 for Asset Hub.

  4. The destinationFee is always 0 for transfers to Asset Hub.

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

  1. This time we will select the Write as Proxy tab.

  1. Expand sendToken.

  2. 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).

  3. token is the address of the ERC20 token contract. In this example, it is the WETH token contract.

  4. destinationChain is the parachain id of the destination. In this example, it is 1000 (Asset Hub).

  5. 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).

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

$ subkey inspect 5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX
  1. The destinationFee is always 0 for transfers to Asset Hub.

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

  1. Go Polkadot.js web interface’s chain state screen for the Asset Hub. Click on the storage tab.

  2. You want to query the foreignAssets.account(XcmV3MultiLocation, AccountId32) key. Bridged assets are identified by their Multilocation relative to Asset Hub.

../../GlobalConsensus(Ethereum{chain_id:11155111})/AccountKey20([0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14](https://sepolia.etherscan.io/address/0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14))
  1. Two parents up.

  2. Ethereum chain 11155111 for Sepolia.

  3. The token address. In this example, it is the WETH contract address.

  4. The beneficiary account from above to query.

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

  1. An HRMP channel needs to exist between Asset Hub and the parachain.

  2. The parachain chain needs to support XCM v3.

  3. The parachain must support the relaychain native currency(ROC) as payment for XCM execution.

  4. The parachain must have a funded sovereign account on Asset Hub with an existential deposit of 0.000033333333 ROC.

  5. The parachain needs to be configured to allow assets from AssetHub to be used as reserve assets. See Penpal XCM config.

  6. The asset being transferred needs to be registered with the destination parachain. This is dependent on the chain itself.

    1. ORML based parachains require the asset to be registered in asset-registry pallet before transfer. Example runtime config:

    2. 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:

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

  1. The token needs to be registered on Asset Hub.

  2. You will need to deposit ETH to get WETH.

  3. The Snowbridge Gateway will need to be an approved spender.

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

  1. Navigate to the Contract tab, click Read as Proxy.

  2. Expand quoteSendTokenFee and input the token address.

  3. The destinationChain that the token is going to be sent to. In this example it is destination parachain 2005.

  4. 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)

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

  1. Add the fee returned from quote. In this example it is 0,000000500025 Ether.

  2. Set the destinationChain to 2005.

  3. Supply the destinationFee that was provided to the quote. Here we use 1,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:

  1. Set the address kind to 2 for 20 byte address.

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

  1. Click Read as Proxy.

  2. Expand quoteRegisterTokenFee. This fee is returned in the unit Wei.

2. Register

Navigate to the Contract tab, click on Write as Proxy, and connect your wallet.

  1. Expand registerToken.

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

  3. Enter ERC20 token address.

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

  1. Go Polkadot.js web interface’s chain state screen for Asset Hub. Click on the storage tab.

  2. You want to query the foreignAssets.asset(XcmV3MultiLocation) key. Bridged assets are identified by their Multilocation relative to Asset Hub.

  3. Two parents up.

  4. Ethereum chain 11155111 for Sepolia.

  5. The token address that you registered. In this example, it is the WETH contract address.

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

  1. Go to the Polkadot.js web interfaces extrinsics screen for Asset Hub. Click on the Decode tab.

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

0x1f0b03020109079edaa80203000103000000000000000000000000000000000000000000030400020209079edaa8020300fff9976782d46cc05630d1f6ebab18b2324d6b14000700f2052a010000000000
  1. Click on the Submission tab where you can now edit the call further.

  2. Select the account you want to transfer WETH from. In this example, we will use the account 5Gn12Tq1ndABBJrym2uzNoeGRcBgTRRSviLnSajVxqka4mfX.

  3. Select the dest. Two parents up.

  4. Ethereum chain 11155111 for Sepolia.

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

  1. Specify the parents for the asset. Two parents up.

  2. Specify the Ethereum chain id for the destination. Ethereum chain 11155111 for Sepolia.

  3. The token address. In this example, it is the WETH contract address.

  1. The amount of the token you want to send. In the example, 5 Gwei (5000000000 Wei).

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

  3. Use unlimited weight for the transfer.

  1. 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).

  1. Select the token transfers tab.

  2. View the transfer transaction. The source method will SubmitV1 which means it came from the Snowbridge Gateway contract.

  1. You can also verify using your wallet. In MetaMask we can see our 5 Gwei has arrived.

Last updated