Skip to content

Instantly share code, notes, and snippets.

@codebender828
Created September 3, 2024 02:41
Show Gist options
  • Save codebender828/4cc6e90babe4a8c8e4d62a977f4d17de to your computer and use it in GitHub Desktop.
Save codebender828/4cc6e90babe4a8c8e4d62a977f4d17de to your computer and use it in GitHub Desktop.
Binance DD Code Snippets
// Creates Instruction layout for syncing state
function createInstructionData(index: number) {
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
const data = Buffer.alloc(dataLayout.span);
dataLayout.encode({ instruction: index }, data);
return data;
}
// Creates synchronize state instruction
function createSynchronizeProgramInstruction(source: PublicKey, target: PublicKey) {
const instruction1 = new TransactionInstruction({
keys: [
{ pubkey: source, isSigner: false, isWritable: false },
{ pubkey: target, isSigner: false, isWritable: false }
],
programId: new PublicKey(SYNC_PROGRAM_ID),
data: createInstructionData(0)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment