For the complete documentation index, see llms.txt. This page is also available as Markdown.

Token transfer Polkadot -> Ethereum

A guide on using the Snowbridge TypeScript SDK for Polkadot to Ethereum transfers.

Uses the @snowbridge/api SDK.

Setup

import { createApi } from "@snowbridge/api"
import { EthersEthereumProvider } from "@snowbridge/provider-ethers"
import { polkadot_mainnet } from "@snowbridge/registry"

const {
    chains: { assetHub, ethereum },
} = polkadot_mainnet

const api = createApi({ info: polkadot_mainnet, ethereumProvider: new EthersEthereumProvider() })

const sender = api.sender(assetHub, ethereum)

Build

const transfer = await sender.build(
    "5...", // source Polkadot account
    "0x...", // beneficiary Ethereum account
    "0x0000000000000000000000000000000000000000", // Ether address
    15_000_000_000_000n, // amount: 0.000015 ETH
    {
        fee: {
            feeTokenLocation: { parents: 1, interior: "Here" }, // DOT location
            padFeeByPercentage: 33n,
            slippagePadPercentage: 20n,
        },
    },
)

The returned transfer.tx can then be submitted to the wallet by your application.

Last updated