3

I'm trying to send a serialized transaction to a server, and then deserialize it there to be sent to an RPC then.

There's one owner account, and two types of instructions as mentioned:

  • NonWritableIx: this instruction does NOT require owner to be isWritable: true
  • WritableIx: this instruction does require owner to be isWritable: true

Now if a send a serialized Transaction(NonWritableIx, WritableIx), and then deserialize it in the server, I notice that the owner account is marked as isWritable: true even for the NonWritableIx.

Whereas if I send a serialized Transaction(NonWritableIx, NonWritableIx), then on deserialization, both instructions have owner as isWritable: false.

I'm assuming in the former case, the isWritable changes due to the presence of a WritableIx. But I was wondering if this is a desired behaviour?

The code snippet for serialization/deserialization is as shown below,

// Client
 const serialized = tx.serialize({
     requireAllSignatures: false,
 });

// Server
const serialized = request.body?.transaction;
if (typeof serialized !== 'string') throw new Error('invalid transaction');
let transaction = Transaction.from(Buffer.from(serialized, 'base64'));
2
  • In the sentence “Whereas if I send a serialized Transaction(NonWritableIx, WritableIx)” did you mean to write “Whereas if I send a serialized Transaction(NonWritableIx, NonWritableIx)”? Commented Jul 21, 2022 at 5:08
  • 1
    Ah yes, my bad I'll change that. Thanks @steveluscher!
    – sayantank
    Commented Jul 23, 2022 at 15:20

1 Answer 1

5

When a transaction is serialized, the writeable and signer bits are only stored once for each account, at their most promoted value as referenced by all instructions. This discards the individual instruction-specified values making it impossible to recover upon deserialization.

2

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.