This directory contains organized examples from the NEAR Zig SDK. Each example has been placed in its own project directory with proper build configurations.
- A simple stateful counter contract on NEAR
- Demonstrates state storage with Borsh serialization, public methods, and owner-only access control
- Exported functions:
new,increment,decrement,get_count,reset,get_owner
- A minimal fungible token implementation following the NEP-141 standard
- Features:
ft_transfer,ft_balance_of,ft_total_supply,ft_metadata - Exported functions:
new,ft_transfer,ft_balance_of,ft_total_supply,ft_metadata
- Store status messages per account
- Demonstrates using storage for key-value pairs and account-based data isolation
- Exported functions:
set_status,get_status
Each project can be built independently:
# Build WASM contract
cd counter_project
zig build wasm
# Run tests
zig build testSame commands work for the other projects (fungible_token_project and status_message_project).
After building with zig build wasm, the compiled WASM contract will be available at:
zig-out/lib/contract.wasm
This structure allows for easy deployment to NEAR using the NEAR CLI:
near deploy --accountId your_contract.testnet --wasmFile zig-out/lib/contract.wasmEach project depends on the near-sdk-zig library located in the parent directory. The build system is configured to reference this dependency via the build.zig.zon file in each project.