Smart Contract Development Guide

Last updated March 20, 2026 · Estimated read time: 15 minutes

1.1 Smart Contract Architecture

Asentum smart contracts are ES module classes that run in sandboxed V8 Isolates. Each contract exports a default class. Methods are callable from transactions or other contracts. Class properties are automatically persisted to chain state between transactions.

1.2 State Management

Any property set on this is automatically stored on-chain. Objects, arrays, maps, and primitives are all supported. Storage writes cost 20,000 gas (new slot) or 5,000 gas (update). Deleting state refunds 15,000 gas. Keep state minimal to reduce costs.

1.3 Injected Globals

msg.sender — the address calling the contract. msg.value — ASX tokens sent with the call. block.number and block.timestamp — current block context. assert(condition, message) — reverts the transaction if false. emit(event, data) — fires an indexed event.

1.4 Standard Library

@asentum/token — ERC20-like fungible token standard. @asentum/nft — non-fungible token standard. @asentum/dao — voting and governance primitives. @asentum/math — safe BigInt math wrappers. @asentum/storage — typed persistent storage helpers.

1.5 Common Patterns

Access control: Use assert(msg.sender === this.owner) for admin-only methods. Reentrancy guard: Set a lock flag before external calls. Pausable: Add an isPaused flag and check it at the top of sensitive methods. Proxy pattern: Delegate calls to an upgradeable implementation contract.

1.6 Gas Cost Reference

Simple transfer: 21,000 gas. Contract deployment: 32,000 + 200/byte. Storage read: 50 gas. Storage write (new): 20,000 gas. Storage write (update): 5,000 gas. Arithmetic: 1-5 gas. Hashing: 30 + 6/word. Contract call: 2,500 + child gas. Event: 375 + 8/byte. Block gas limit: 15M target, 30M max.