Skip to content

Ashen SDK

The Ashen SDK provides Zig modules for writing smart contracts that run on Ashen’s RISC-V execution environment.

const sdk = @import("ashen-sdk");
export fn _start(calldata_ptr: [*]const u8, calldata_len: usize) sdk.ByteSlice {
sdk.heap.reset();
const calldata = if (calldata_len == 0) &[_]u8{} else calldata_ptr[0..calldata_len];
// Your contract logic here
return sdk.ByteSlice.from(result);
}
pub const panic = sdk.panic;

sdk.storage - Persistent key-value storage

const storage = sdk.storage;
// Read/write raw bytes
const value = storage.read(key);
storage.write(key, data);
// Typed helpers for u128
const balance = storage.readU128(key);
storage.writeU128(key, amount);
ModuleImportPurpose
heapsdk.heapBump allocator
storagesdk.storageState read/write
contextsdk.contextCaller, origin, block info
cryptosdk.cryptoKeccak256, SHA256, Blake3
eventssdk.eventsEvent emission
guardssdk.guardsReentrancy, safe math
mathsdk.mathWAD/RAY/BPS math