The title says it all: If my anchor instruction expects an Option<T>
to be passed what do I need to send in typescript for None
and Some<T>
respectively? I checked the docs but couldn't find any info on this.
1 Answer
If you mean the transaction data (arguments) then null
works fine for me.
In particular for recent Anchor project we pass configuration options either with value (to be configured) or None (to not be configured). The program arguments are defined as: https://github.com/marinade-finance/validator-bonds/blob/main/programs/validator-bonds/src/instructions/config/configure_config.rs#L7
The Anchor TS IDL is generated as: https://github.com/marinade-finance/validator-bonds/blob/contract-v1.4.0/packages/validator-bonds-sdk/generated/validator_bonds.ts#L2936
And the Anchor TS types are loaded and used in the following way to pass null
at on-chain call.
-
1
null
works now for me, so the error I was facing stemmed from something else. Thanks for the elaborate answer!– McBainCommented Apr 19 at 4:33
None
I've triedundefined
,null
,[undefined]
,[null]
,{}
but all of these result inInstructionDidNotDeserialize