You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[`pinocchio`](https://crates.io/crates/pinocchio) helpers to perform cross-program invocations (CPIs) for System program instructions.
4
+
5
+
Each instruction defines an `struct` with the accounts and parameters required. Once all values are set, you can call directly `invoke` or `invoke_signed` to perform the CPI.
6
+
7
+
> [!IMPORTANT]
8
+
> The API defined in this crate should be considered experimental.
9
+
10
+
## Examples
11
+
12
+
Creating a new account:
13
+
```rust
14
+
// This example assumes that the instruction receives a writable signer `payer_info`
15
+
// and `new_account` accounts.
16
+
CreateAccount {
17
+
from:payer_info,
18
+
to:new_account,
19
+
lamports:1_000_000_000, // 1 SOL
20
+
space:200, // 200 bytes
21
+
owner:&spl_token::ID,
22
+
}.invoke()?;
23
+
```
24
+
25
+
Performing a transfer of lamports:
26
+
```rust
27
+
// This example assumes that the instruction receives a writable signer `payer_info`
28
+
// account and a writable `recipient` account.
29
+
Transfer {
30
+
from:payer_info,
31
+
to:recipient,
32
+
lamports:500_000_000, // 0.5 SOL
33
+
}.invoke()?;
34
+
```
35
+
36
+
## License
37
+
38
+
The code is licensed under the [Apache License Version 2.0](../LICENSE)
0 commit comments