Bridge Tokens Between Ethereum and XRPL
Attention
Don't use any funds from a mainnet
wallet to perform the actions in this tutorial. The steps outlined are for a testnet
deployment, so any funds transferred from mainnet
may be lost. Additionally:
-
Gas payments aren't currently supported. You don't need to call
AxelarGasService
on Ethereum Sepolia to refund our relayer since it's running "pro bono". - The bridge doesn't charge any fees currently.
-
The
IAxelarGateway
interface andAxelarExecutable
smart contracts used in this tutorial are different from the ones currently deployed by Axelar. Instructions you find elsewhere likely won't be compatible with thistestnet
deployment. -
Only one validator is used to secure this
testnet
bridge. - Only one relayer is active.
This tutorial describes how to transfer tokens between Ethereum Sepolia
and the XRPL Testnet
.
Prerequisites
- Foundry
- XRPL.js Library
-
An RPC provider, such as Alchemy or Infura, with the
SEPOLIA_RPC_URL
environment variable set to a workingSepolia
RPC URL. -
Funded wallets on both chains.
- ETH Sepolia Faucet: alchemy.com/faucets/ethereum-sepolia
- XRPL Testnet Faucet: faucet.tequ.dev
Bridge ETH
ETH from Ethereum to XRPL
-
Create a trust line on XRPL
testnet
between the Axelar multisig account and the destination account, using theTrustSet
transaction.{ "TransactionType": "TrustSet", "Account": user.address, // the XRPL address of the ETH transfer recipient "LimitAmount": { "currency": "ETH", "issuer": "rfEf91bLxrTVC76vw1W3Ur8Jk4Lwujskmb", "value": "10000000000", }, ... },
-
Wrap ETH on Ethereum
Sepolia
. You can do this using the Foundrycast
command, or directly on Etherscan.-
Using Foundry's
cast
command:
WETH=0x7b79995e5f793a07bc00c21412e50ecae098e7f9 cast send $WETH "deposit()" --value 0.1ether --private-key $PRIVATE_KEY --rpc-url $SEPOLIA_RPC_URL
- Using Etherescan , select Connect to Web3 to connect your wallet. Expand the deposit dropdown and type the amount of ETH you want to bridge. Click Write to perform the transaction.
-
Using Foundry's
-
Approve the
AxelarGateway
contract to spend your WETH on EthereumSepolia
:-
Using Foundry's
cast
command:
WETH=0x7b79995e5f793a07bc00c21412e50ecae098e7f9 AXELAR_GATEWAY=0xAABdd46ba1B3147d0Cf6aCc9605a74fE8668fC74 cast send $WETH "approve(address guy, uint256 amount)" $AXELAR_GATEWAY $(cast to-wei 0.1) --private-key $PRIVATE_KEY --rpc-url $SEPOLIA_RPC_URL
-
Using
Etherescan
, select
Connect to Web3
to connect your wallet. Expand the
approve
dropdown, enter
AxelarGateway
's address (0x832B2dfe8a225550C144626111660f61B8690efD
), and the amount of ETH to bridge under deposit . Click Write to perform the transcation.
-
Using Foundry's
-
On Ethereum Sepolia, call
AxelarGateway.sendToken()
to bridge your WETH.AXELAR_GATEWAY=0xAABdd46ba1B3147d0Cf6aCc9605a74fE8668fC74 XRPL_DESTINATION= # your XRPL recipient address cast send $AXELAR_GATEWAY "sendToken(string destinationChain, string destinationAddress, string symbol, uint256 amount)" "xrpl" $XRPL_DESTINATION "WETH" $(cast to-wei 0.1) --private-key $PRIVATE_KEY --rpc-url $SEPOLIA_RPC_URL
- The destination address should receive the bridged ETH in a few minutes. You can check for a successful transaction on the XRPL Testnet explorer .
Wrapped ETH from XRPL to Ethereum
-
Deposit ETH into the XRPL multisig account, using a
Payment
transaction.{ TransactionType: "Payment", Account: user.address, // The user initiating the transfer Amount: { currency: "ETH", value: "0.001", // = 10^15 wei - the amount of ETH you want to bridge, in ETH issuer: "rfEf91bLxrTVC76vw1W3Ur8Jk4Lwujskmb", }, Destination: "rfEf91bLxrTVC76vw1W3Ur8Jk4Lwujskmb", // Axelar's XRPL multisig account Memos: [ { Memo: { MemoData: "605459C28E6bE7B31B8b622FD29C82B3059dB1C6", // your ETH recipient address, without the 0x prefix MemoType: "64657374696E6174696F6E5F61646472657373", // hex("destination_address") }, }, { Memo: { MemoData: "657468657265756D", // hex("ethereum") MemoType: "64657374696E6174696F6E5F636861696E", // hex("destination_chain") }, }, { Memo: { MemoData: "0000000000000000000000000000000000000000000000000000000000000000", // bytes32(0) indicates pure token transfer, without GMP MemoType: "7061796C6F61645F68617368", // hex("payload_hash") }, }, ], ... }
-
Within a few minutes, the
destination_address
should receive the bridged ETH on EthereumSepolia
, as WETH. You can check for the transaction on the Ethereum Sepolia explorer .
Bridge XRP
XRP from XRPL to Ethereum
-
Deposit XRP into the XRPL multisig account, using a
Payment
transaction.{ TransactionType: "Payment", Account: user.address, // The user initiating the transfer Amount: "1000000", // = 1 XRP - the amount of XRP you want to bridge, in drops Destination: "rfEf91bLxrTVC76vw1W3Ur8Jk4Lwujskmb", // Axelar's XRPL multisig account Memos: [ { Memo: { MemoData: "605459C28E6bE7B31B8b622FD29C82B3059dB1C6", // your ETH recipient address, without the 0x prefix MemoType: "64657374696E6174696F6E5F61646472657373", // hex("destination_address") }, }, { Memo: { MemoData: "657468657265756D", // hex("ethereum") MemoType: "64657374696E6174696F6E5F636861696E", // hex("destination_chain") }, }, { Memo: { MemoData: "0000000000000000000000000000000000000000000000000000000000000000", // bytes32(0) indicates pure token transfer, without GMP MemoType: "7061796C6F61645F68617368", // hex("payload_hash") }, }, ], ... }
-
Within a few minutes, the
destination_address
should receive the bridged XRP on Ethereum Sepolia, as Axelar-wrapped XRP (axlXRP). You can check for the transaction on the Ethereum Sepolia explorer .
Wrapped XRP (axlXRP) from Ethereum to XRPL
-
Approve the
AxelarGateway
contract to spend your axlXRP on EthereumSepolia
:-
Using Foundry's
cast
command:
AXL_XRP=0x40d5ed73982468499ecfa9c8cc0abb63ff13a409 AXELAR_GATEWAY=0xAABdd46ba1B3147d0Cf6aCc9605a74fE8668fC74 cast send $AXL_XRP "approve(address guy, uint256 amount)" $AXELAR_GATEWAY 1000000 --private-key $PRIVATE_KEY --rpc-url $SEPOLIA_RPC_URL
-
Using
Etherescan
, select
Connect to Web3
to connect your wallet. Expand the
approve
dropdown, enter the
AxelarGateway
's address (0x832B2dfe8a225550C144626111660f61B8690efD
) and the amount of axlXRP to bridge under deposit . Click Write to perform the transcation.
-
Using Foundry's
-
On Ethereum
Sepolia
, callAxelarGateway.sendToken()
to bridge your axlXRP.AXELAR_GATEWAY=0xAABdd46ba1B3147d0Cf6aCc9605a74fE8668fC74 XRPL_DESTINATION= # your XRPL recipient address cast send $AXELAR_GATEWAY "sendToken(string destinationChain, string destinationAddress, string symbol, uint256 amount)" "xrpl" $XRPL_DESTINATION "axlXRP" 1000000 --private-key $PRIVATE_KEY --rpc-url $SEPOLIA_RPC_URL
- Within a few minutes, your destination address should receive the XRP. You can check for the transaction on the XRPL Testnet explorer .