Initialize Token Account
Creating a token account from Solana Proxy Account for each x-chain users.
For any tokens to migrate from evm chain to solana chain a user must have an existing token account in solana chain. This is becuase, every token has separate associated token account and a user may own many token account. An associated token account address is derived from the token mint address, user wallet address and token program id.
You can create a token account in following way.
const owner = "0x91845D534744Ef350695CF98393d23acC9639024";
const tokenAddress = "<evm token address>"
const sourceChain = CHAIN_ID_BSC;
const targetChain = CHAIN_ID_SOLANA;
const tokenAddrInSolana = await getTargetAsset(
signer,
tokenAddress,
sourceChain,
targetChain
)
const proxyAccount = ZebecSolBridgeClient.getProxyUserKey(
tryNativeToUint8Array(owner, sourceChain),
sourceChain,
SOL_ZEBEC_BRIDGE_ADDRESS
);
const ethClient = new ZebecEthBridgeClient(BSC_ZEBEC_BRIDGE_ADDRESS, signer, sourceChain);
const receipt = await ethClient.createTokenAccount(owner, tokenAddrInSolana);Now you can find signed Vaa bytes of your payload sent to wormhole.
Rest of work is performed by the relayer. If you want to manually relay the payloads to solana, you can accomplish it in following way.
Then you parse payload information from vaa and call method in Zebec Solana bridge program to initialize token account in solana.
Last updated