Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ lets the VM assume it worked.
| Language | CU Usage |
| --- | --- |
| Rust | 464 |
| Zig | 186 |
| Zig | 43 |
| C | 103 |
| Assembly | 22 |

Expand Down
15 changes: 2 additions & 13 deletions transfer-lamports/zig/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,11 @@
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
.base58 = .{
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.13.3.tar.gz",
.hash = "1220fd067bf167b9062cc29ccf715ff97643c2d3f8958beea863b6036876bb71bcb8",
},
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.13.1.tar.gz",
.hash = "122030336f1257e3c0aa64243f5243f554b903c6b9ef3a91d48bfbe896c0c7d9b13b",
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "1220bdfa4ea1ab6330959ce4bc40feb5b39a7f98923a266a94b69e27fd20c3526786",
},
},

// Specifies the set of files and directories that are included in this package.
// Only files and directories listed here are included in the `hash` that
// is computed for this package.
// Paths are relative to the build root. Use the empty string (`""`) to refer to
// the build root itself.
// A directory listed here means that all files within, recursively, are included.
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
8 changes: 2 additions & 6 deletions transfer-lamports/zig/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ const sol = @import("solana-program-sdk");

export fn entrypoint(input: [*]u8) u64 {
const context = sol.Context.load(input) catch return 1;
const accounts = context.loadRawAccounts(sol.allocator) catch return 1;
defer accounts.deinit();

const source = accounts.items[0];
const destination = accounts.items[1];
const source = context.accounts[0];
const destination = context.accounts[1];
source.lamports().* -= 5;
destination.lamports().* += 5;

return 0;
}