Transfer

Initiate raw transaction for the token transfer with this SDK instance:

// initiate transfer using Messenger.WORMHOLE
const transaction = (await sdk.bridge.rawTxBuilder.send({
  amount: "0.2",
  fromAccountAddress: fromAddress,
  toAccountAddress: toAddressPol,
  sourceToken: sourceTokenInfo,
  destinationToken: destinationTokenInfoPol,
  messenger: Messenger.WORMHOLE,
  txFeeParams: {
    solana: SolanaAutoTxFee,
  },
})) as RawBridgeSolanaTransaction;

const keypair = solanaWeb3.Keypair.fromSecretKey(bs58.decode(privateKey));
transaction.sign([keypair]);

const connection = new solanaWeb3.Connection(nodeUrlsDefault.solanaRpcUrl, "confirmed");
const txId = await connection.sendTransaction(transaction);
console.log(`https://explorer.solana.com/tx/${txId}`);

Allbrdige and Wormhole messaging full example

Last updated