poseidon_client/transactions/
system_instruction.rs

1use crate::PublicKey;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
5pub enum SystemInstruction {
6    /// Create a new account
7    ///
8    /// # Account references
9    ///   0. `[WRITE, SIGNER]` Funding account
10    ///   1. `[WRITE, SIGNER]` New account
11    CreateAccount {
12        /// Number of lamports to transfer to the new account
13        lamports: u64,
14
15        /// Number of bytes of memory to allocate
16        space: u64,
17
18        /// Address of program that will own the new account
19        owner: PublicKey,
20    },
21
22    /// Assign account to a program
23    ///
24    /// # Account references
25    ///   0. `[WRITE, SIGNER]` Assigned account public key
26    Assign {
27        /// Owner program account
28        owner: PublicKey,
29    },
30
31    /// Transfer lamports
32    ///
33    /// # Account references
34    ///   0. `[WRITE, SIGNER]` Funding account
35    ///   1. `[WRITE]` Recipient account
36    Transfer { lamports: u64 },
37
38    /// Create a new account at an address derived from a base pubkey and a seed
39    ///
40    /// # Account references
41    ///   0. `[WRITE, SIGNER]` Funding account
42    ///   1. `[WRITE]` Created account
43    ///   2. `[SIGNER]` (optional) Base account; the account matching the base Pubkey below must be
44    ///                          provided as a signer, but may be the same as the funding account
45    ///                          and provided as account 0
46    CreateAccountWithSeed {
47        /// Base public key
48        base: PublicKey,
49
50        /// String of ASCII chars, no longer than `Pubkey::MAX_SEED_LEN`
51        seed: String,
52
53        /// Number of lamports to transfer to the new account
54        lamports: u64,
55
56        /// Number of bytes of memory to allocate
57        space: u64,
58
59        /// Owner program account address
60        owner: PublicKey,
61    },
62
63    /// Consumes a stored nonce, replacing it with a successor
64    ///
65    /// # Account references
66    ///   0. `[WRITE]` Nonce account
67    ///   1. `[]` RecentBlockhashes sysvar
68    ///   2. `[SIGNER]` Nonce authority
69    AdvanceNonceAccount,
70
71    /// Withdraw funds from a nonce account
72    ///
73    /// # Account references
74    ///   0. `[WRITE]` Nonce account
75    ///   1. `[WRITE]` Recipient account
76    ///   2. `[]` RecentBlockhashes sysvar
77    ///   3. `[]` Rent sysvar
78    ///   4. `[SIGNER]` Nonce authority
79    ///
80    /// The `u64` parameter is the lamports to withdraw, which must leave the
81    /// account balance above the rent exempt reserve or at zero.
82    WithdrawNonceAccount(u64),
83
84    /// Drive state of Uninitialized nonce account to Initialized, setting the nonce value
85    ///
86    /// # Account references
87    ///   0. `[WRITE]` Nonce account
88    ///   1. `[]` RecentBlockhashes sysvar
89    ///   2. `[]` Rent sysvar
90    ///
91    /// The `Pubkey` parameter specifies the entity authorized to execute nonce
92    /// instruction on the account
93    ///
94    /// No signatures are required to execute this instruction, enabling derived
95    /// nonce account addresses
96    InitializeNonceAccount(PublicKey),
97
98    /// Change the entity authorized to execute nonce instructions on the account
99    ///
100    /// # Account references
101    ///   0. `[WRITE]` Nonce account
102    ///   1. `[SIGNER]` Nonce authority
103    ///
104    /// The `Pubkey` parameter identifies the entity to authorize
105    AuthorizeNonceAccount(PublicKey),
106
107    /// Allocate space in a (possibly new) account without funding
108    ///
109    /// # Account references
110    ///   0. `[WRITE, SIGNER]` New account
111    Allocate {
112        /// Number of bytes of memory to allocate
113        space: u64,
114    },
115
116    /// Allocate space for and assign an account at an address
117    ///    derived from a base public key and a seed
118    ///
119    /// # Account references
120    ///   0. `[WRITE]` Allocated account
121    ///   1. `[SIGNER]` Base account
122    AllocateWithSeed {
123        /// Base public key
124        base: PublicKey,
125
126        /// String of ASCII chars, no longer than `pubkey::MAX_SEED_LEN`
127        seed: String,
128
129        /// Number of bytes of memory to allocate
130        space: u64,
131
132        /// Owner program account
133        owner: PublicKey,
134    },
135
136    /// Assign account to a program based on a seed
137    ///
138    /// # Account references
139    ///   0. `[WRITE]` Assigned account
140    ///   1. `[SIGNER]` Base account
141    AssignWithSeed {
142        /// Base public key
143        base: PublicKey,
144
145        /// String of ASCII chars, no longer than `pubkey::MAX_SEED_LEN`
146        seed: String,
147
148        /// Owner program account
149        owner: PublicKey,
150    },
151
152    /// Transfer lamports from a derived address
153    ///
154    /// # Account references
155    ///   0. `[WRITE]` Funding account
156    ///   1. `[SIGNER]` Base for funding account
157    ///   2. `[WRITE]` Recipient account
158    TransferWithSeed {
159        /// Amount to transfer
160        lamports: u64,
161
162        /// Seed to use to derive the funding account address
163        from_seed: String,
164
165        /// Owner to use to derive the funding account address
166        from_owner: PublicKey,
167    },
168}