This node represents an entire program deployed on-chain. It defines all elements of a program such as accounts, instructions, PDAs, errors, etc.
Attribute | Type | Description |
---|---|---|
kind |
"programNode" |
The node discriminator. |
name |
CamelCaseString |
The name of the program. |
publicKey |
string |
The 32-bytes address of the program base58 encoded. |
version |
\d.\d.\d |
The semantic version of the program being defined. |
docs |
string[] |
Markdown documentation for the program. |
origin |
"anchor" | "shank" |
(Optional) An optional attribute tells us how this program node was created. |
Attribute | Type | Description |
---|---|---|
accounts |
AccountNode [] |
The accounts created and managed by the program. |
instructions |
InstructionNode [] |
The instructions that allows us to interact with the program. |
definedTypes |
DefinedTypeNode [] |
Some reusable types defined by the program. |
pdas |
PdaNode [] |
The Program-Derived Addresses (PDAs) used by the program. |
errors |
ErrorNode [] |
The errors that can be thrown by the program. |
Helper function that creates a ProgramNode
object from an input object
const node = programNode({
name: 'counter',
publicKey: '7ovtg4pFqjQdSwFAUCu8gTnh5thZHzAyJFXy3Ssnj3yK',
version: '1.42.6',
accounts: [],
instructions: [],
definedTypes: [],
pdas: [],
errors: [],
});
Helper function that returns all ProgramNodes
under a given node. This can be a RootNode
, a ProgramNode
— returning itself in an array — or an array of ProgramNode
.
const allPrograms = getAllPrograms(rootNode);
Helper function that returns all PdaNodes
under a given node. This can be a RootNode
, a ProgramNode
or an array of ProgramNode
.
const allPdas = getAllPdas(rootNode);
Helper function that returns all AccountNodes
under a given node. This can be a RootNode
, a ProgramNode
or an array of ProgramNode
.
const allAccounts = getAllAccounts(rootNode);
Helper function that returns all DefinedTypeNodes
under a given node. This can be a RootNode
, a ProgramNode
or an array of ProgramNode
.
const allDefinedTypes = getAllDefinedTypes(rootNode);
Helper function that returns all InstructionNodes
under a given node. This can be a RootNode
, a ProgramNode
or an array of ProgramNode
.
const allInstructions = getAllInstructions(rootNode);
Helper function that returns all ErrorNodes
under a given node. This can be a RootNode
, a ProgramNode
or an array of ProgramNode
.
const allErrors = getAllErrors(rootNode);