Created
September 3, 2024 02:41
-
-
Save codebender828/4cc6e90babe4a8c8e4d62a977f4d17de to your computer and use it in GitHub Desktop.
Binance DD Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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