Upgrade using ABI
import { ethers } from "hardhat";
import { PublicKey } from "@solana/web3.js";
import { coder } from "your-coder-library"; // Example placeholder
const solanaAddress = new PublicKey("your-solana-account").toBytes();
const sourceAddress = coder.encode(["bytes32"], [Buffer.from(solanaAddress)]);
const payload = coder.encode(["bytes32", "bytes"], [sourceAddress, Buffer.from([0])]);
// Send message using the Solana program
const programID = new PublicKey("solana-program-address");
const program = new anchor.Program(idl, programID);
const message = hexStringToUint8Array(payload);
const ix3 = program.methods.sendMessage(Buffer.from(message)).accounts({
config: realConfig,
wormholeProgram: CORE_BRIDGE_PID,
...wormholeAccounts2,
}).instruction();
const tx3 = new Transaction().add(await ix3);
try {
const commitment: Commitment = 'confirmed';
await sendAndConfirmTransaction(provider.connection, tx3, [yourSolanaAccount], { commitment });
} catch (error) {
console.error(error);
}
Last updated