ProgramNodeThis 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. |
programNode(input)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: [],
});
getAllPrograms(node)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);
getAllPdas(node)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);
getAllAccounts(node)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);
getAllDefinedTypes(node)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);
getAllInstructions(node)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);
getAllErrors(node)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);