0

I have a Solana dApp that requests tokens from a wallet that I own. When the user try to claim the Tokens, one transaction is created on the frontend and signed by the user; the signature is coded and sent to my backend API. In my backend I have a function that verifies if the signature is valid: It mounts other transaction the same way (the same process) and verify if the client transaction and my generated transaction is the same. I used this script for more than 1 year but now Im getting so much trouble with differences in the Buffers of the instructions of my generated wallet:

Client instruction: TransactionInstruction { keys: [ { pubkey: [PublicKey [(x)], isSigner: false, isWritable: true }, { pubkey: [PublicKey [(y)], isSigner: false, isWritable: true }, { pubkey: [PublicKey [(z)], isSigner: true, isWritable: false } ], programId: PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)] { _bn: <BN: (w) > }, data: <Buffer 03 00 be 88 c6 1a 00 00 00> } generated instruction: TransactionInstruction { keys: [ { pubkey: [PublicKey [(x)], isSigner: false, isWritable: true }, { pubkey: [PublicKey [(y)], isSigner: false, isWritable: true }, { pubkey: [PublicKey [(z)], isSigner: true, isWritable: false } ], programId: PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)] { _bn: <BN: (w) > }, data: <Buffer 03 00 e4 0b 54 02 00 00 00> }

I used x, y, z & w because this infos arent important (but they are the same on the transactions)

my problem is this Buffer, its different!:

<Buffer 03 00 e4 0b 54 02 00 00 00>

Im strugling with this problem like 1 week and I dont know what to to anymore. This two transactions are made in the same process, using the same libs, functions, basicaly ctrl+c -> ctrl+v. And worked very well for an Year.

and is important to say that it still works with some wallets, but others is getting troubles

I code in Typescript, using Next.js and react for frontend and ts using Nest and Node.js in backend.

2
  • Which instruction are you trying to invoke on the Token Program specifically?
    – Serban
    Commented Sep 25, 2023 at 17:41
  • Token.createTransferInstruction() just the transfer instruction
    – ZuckOFB
    Commented Sep 25, 2023 at 18:12

1 Answer 1

1

If the instruction you're using is created with createTransferInstruction(), the data part of the instruction will contain the instruction key (which is 0x03 in both, so it's the same) and the amount of tokens.

The difference between your instructions is the amount of tokens, one of them is I think 10 tokens and the other 115 tokens.

1
  • How do you know the amount? how is made this Buffer?
    – ZuckOFB
    Commented Sep 25, 2023 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.