Trying to send XRP from XRPL EVM to XRPL wallet. I have an available balance etc but its not working:
import { ethers } from "ethers";
// --- Configuration ---
// Load your private key securely from .env
const privateKey = "Metamask XRPL EVM Testnet Wallet with 50 xrp balance";
// XRPL EVM Testnet RPC
const rpcUrl = "https://rpc.testnet.xrplevm.org";
// ITS contract (Interchain Token Service) deployed on XRPL EVM Testnet
// Ref: deployed-contracts list
const itsContractAddress = "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C";
// Token ID for wrapped XRP on Testnet (Axelar ITS)
// Confirm from deployed contracts docs
const wrappedXRPTokenId =
"0xba5a21ca88ef6bba2bfff5088994f90e1077e2a1cc3dcc38bd261f00fce2824f";
// Destination XRPL (r-address) — native XRPL wallet
const recipientXrplAddress = "raxF7y2wirxDZt1Q1qGHCYN7dMSD41Rdwv";
// Amount: 10 XRP → converted to wei (10 * 1e18)
const amountInWei = ethers.parseUnits("1", 18);
// --- Main Function ---
async function sendXrpFromEvmToXrpl() {
try {
// 1. Connect to XRPL EVM
const provider = new ethers.JsonRpcProvider(rpcUrl);
const wallet = new ethers.Wallet(privateKey, provider);
// 2. Load ITS contract
const itsAbi = [
"function interchainTransfer(bytes32 tokenId, string destinationChain, bytes recipient, uint256 amount, bytes metadata) external",
];
const its = new ethers.Contract(itsContractAddress, itsAbi, wallet);
// 3. Encode recipient XRPL address as bytes
const encodedRecipient = ethers.hexlify(
ethers.toUtf8Bytes(recipientXrplAddress)
);
console.log("Encoded XRPL recipient:", encodedRecipient);
const wXRPAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // wXRP contract address on XRPL EVM Testnet
const erc20 = new ethers.Contract(wXRPAddress, ["function balanceOf(address) view returns (uint256)"], provider);
console.log("Balance: " + (await erc20.balanceOf(wallet.address)).toString());
// 4. Build transaction
console.log("Initiating interchain transfer...");
const tx = await its.interchainTransfer(
wrappedXRPTokenId, // Axelar token ID for wXRP
"xrpl", // Destination chain ID on Testnet
encodedRecipient, // Encoded XRPL r-address
amountInWei, // Amount
"0x" // No metadata
);
console.log("Tx submitted. Hash:", tx.hash);
// 5. Wait for confirmation
const receipt = await tx.wait();
console.log("Tx confirmed in block:", receipt.blockNumber);
console.log(`✅ Successfully sent 10 XRP to XRPL address: ${recipientXrplAddress}`);
console.log("Now wait for Axelar relayers to deliver the funds on XRPL.");
} catch (err) {
console.error("❌ Transfer failed:", err);
}
}
sendXrpFromEvmToXrpl();
This is the Output/Error I have encountered:
Encoded XRPL recipient: 0x7261784637793277697278445a7431513171474843594e37644d5344343152647776 Balance: 13345831482671678320 Initiating interchain transfer... ❌ Transfer failed: Error: missing revert data (action="estimateGas", data=null, reason=null, transaction={ "data": "0xbf356661ba5a21ca88ef6bba2bfff5088994f90e1077e2a1cc3dcc38bd261f00fce2824f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000047872706c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000227261784637793277697278445a7431513171474843594e37644d53443431526477760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "from": "0xD4C58be0fC494ed63c9D8338c159dC62E403Ca12", "to": "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.15.0) at makeError code: 'CALL_EXCEPTION', action: 'estimateGas', data: null, reason: null, transaction: { to: '0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C', data: '0xbf356661ba5a21ca88ef6bba2bfff5088994f90e1077e2a1cc3dcc38bd261f00fce2824f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000047872706c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000227261784637793277697278445a7431513171474843594e37644d53443431526477760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', from: '0xD4C58be0fC494ed63c9D8338c159dC62E403Ca12' }, invocation: null, revert: null, shortMessage: 'missing revert data', info: { error: { code: -32000, message: 'execution reverted' }, payload: { method: 'eth_estimateGas', params: [Array], id: 5, jsonrpc: '2.0' } } }