This node defines an argument that is passed to an instruction. When all arguments are combined and serialized next to each other, they form the instruction's data.
Attribute | Type | Description |
---|---|---|
kind |
"instructionArgumentNode" |
The node discriminator. |
name |
CamelCaseString |
The name of the instruction argument. |
docs |
string[] |
Markdown documentation for the instruction argument. |
defaultValueStrategy |
"optional" | "omitted" |
(Optional) The strategy to use when a default value is provided for the argument. "optional" means that the argument's default value may be overriden by a provided argument, while "omitted" means that no argument should be provided and the default value should always be the argument's value. Defaults to "optional" . |
Attribute | Type | Description |
---|---|---|
type |
TypeNode |
The TypeNode that describes the argument's data. |
defaultValue |
InstructionInputValueNode |
(Optional) A default value for the argument should this argument not be provided when constructing the instruction. |
Helper function that creates a InstructionArgumentNode
object from an input object.
const node = instructionArgumentNode({
name: 'amount',
type: numberTypeNode('u64'),
docs: ['This amount of tokens to transfer.'],
});
instructionArgumentNode({
name: 'amount',
type: numberTypeNode('u64'),
defaultValue: numberValueNode(0),
});
instructionArgumentNode({
name: 'instructionDiscriminator',
type: numberTypeNode('u8'),
defaultValue: numberValueNode(42),
defaultValueStrategy: 'omitted',
});