Update Stream

For updating stream, you must make sure that your stream has not started. Your can update your stream in following way.

const sourceChain = CHAIN_ID_BSC;
const targetChain = CHAIN_ID_SOLANA;
const now = nowInSec();
const startTime = now + 600;
const endTime = startTime + 6000;

const sender = "<evm address>";
const receiver = "<evm address>";
const tokenMint = "<solana mint key>";
const dataAccount = "<solana stream data account key>";

const receipt = await ethClient.updateStream(
   startTime.toString(),
   endTime.toString(),
   amount,
   receiver,
   sender,
   tokenMint,
   dataAccount,
);

Now you can find signed Vaa bytes of your payload sent to wormhole.

const sequence = parseSequenceFromLogEth(receipt, getBridgeAddressForChain(sourceChain));
const emitterAddress = getEmitterAddressEth(BSC_ZEBEC_BRIDGE_ADDRESS);
const { vaaBytes } = await getSignedVAAWithRetry(
   WORMHOLE_RPC_HOSTS,
   sourceChain,
   emitterAddress,
   sequence,
);

Now post this signed vaa to wormhole solana core bridge program, parse the payloads from vaa and send the parsed data to solana zebec bridge program. This part is optional because it's handled by zebec's specialized relayer.

const payerAddress = wallet.publicKey.toString();
const bridgeAddress = getBridgeAddressForChain(targetChain);
const vaaBuf = Buffer.from(vaaBytes);

setDefaultWasm("node"); // use bundler for browser

// posting vaa in solana
await postVaaSolanaWithRetry(
   connection,
   wallet.signTransaction,
   bridgeAddress,
   payerAddress,
   vaaBuf,
   MAX_VAA_UPLOAD_RETRIES_SOLANA,
);

const parsedVaa = parse_vaa(updateStreamVaa);
const parsedPayload = parseZebecPayload(Buffer.from(parsedVaa.payload));

const result = await solanaClient.updateStreamToken(
   vaaBytes, 
   <CancelTokenStreamPayload>parsedPayload
);

Last updated