Snowbridge
  • Introduction
  • Concepts
  • Architecture
    • Overview
    • Components
    • Channels
    • Verification
      • Ethereum
      • Polkadot
        • Operational Costs
    • Governance
    • Upgrades
    • Relayers
  • Applications
    • Token Transfers
  • Security
    • Exploit Reporting
    • Audits
  • Other
    • Quick Start Guide
    • Processes for keeping track of dependency changes
    • Bridges Workshop
  • Rococo Testnet
    • Rococo-Sepolia Token Transfers
  • Operations
    • Infrastructure
    • Contributing to Snowbridge
    • Governance and Operational Processes
    • General Governance Updates
    • Test Runtime Upgrades
    • Run Relayers
Powered by GitBook
On this page
  • Sending ERC20 tokens from Ethereum to Polkadot
  • Sending tokens to Asset Hub
  • Sending Tokens to a User-specified Destination Parachain
  • Sending tokens to Parachains which support 20-byte Addresses (EVM based chains)
  • Registering Tokens
  • Sending ERC20 tokens from Polkadot to Ethereum
  1. Rococo Testnet

Rococo-Sepolia Token Transfers

Using Snowbridge to transfer tokens in a testnet.

PreviousBridges WorkshopNextInfrastructure

Last updated 1 year ago

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 (Wrapped ETH). To register your own ERC20 tokens see .

1. Deposit ETH

If you already have you can skip this step. If not go to the contract and make a deposit.

WETH Contract Address:

  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.

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

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

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

4. Checking the Required Fee

Get a quote for the fee required to send a token.

  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

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. destinationChain is the parachain id of the destination. In this example, it is 1000 (Asset Hub).

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

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

3. Checking the Required Fee

Get a quote for the fee required to send a token.

  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

  1. Set the destinationChain to 2005.

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.

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. Two parents up.

  2. Ethereum chain 11155111 for Sepolia.

Sending ERC20 tokens from Polkadot to Ethereum

1. Send Tokens back to Polkadot

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

  2. Select the dest. Two parents up.

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

  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.

  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.

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

0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
WETH
Asset Hub
WETH
extrinsic screen
chain state screen
0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
WETH
0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
WETH
handy website
chain state screen
WETH
Penpal XCM config
Snowbridge ORML Template
Penpal Asset Transactor
Penpal Foreign Assets Pallet
Trappist Parachain Currency Adapter
0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
0x5b4909ce6ca82d2ce23bd46738953c7959e710cd
chain state screen
Multilocation relative to Asset Hub
WETH
Asset Hub
extrinsics screen
WETH
WETH
WETH
Etherscan
sending tokens to Asset Hub
registered on Asset Hub
deposit ETH to get WETH
approved spender
Asset Hub example
sending to Asset Hub
returned from quote
provided to the quote
Send Token
WETH
WETH
WETH
0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
Registering Tokens