Skip to content

Commit a5c68d0

Browse files
committed
Add readme
1 parent 71ed627 commit a5c68d0

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

programs/system/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "pinocchio-system"
33
description = "Pinocchio helpers to invoke System program instructions"
44
version = "0.0.0"
55
edition = "2021"
6+
license = "Apache-2.0"
7+
readme = "./README.md"
8+
repository = "https://github.com/febo/pinocchio"
69

710
[dependencies]
811
pinocchio = { version="^0", path="../../sdk/pinocchio" }

programs/system/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# `system`
2+
3+
[`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

Comments
 (0)