Build on Asentum
Deploy Your First Contract
Estimated read time: 10 minutes
Prerequisites
- Node.js 20+ installed
- An Asentum wallet — see Wallets & Accounts
- Some testnet ASE for gas (faucet opens in Phase 2)
- A text editor — VS Code, Vim, anything you like writing JavaScript in
Write the contract
An Asentum smart contract is a plain JavaScript module. No compiler. No DSL. No new syntax. Save the following as counter.js:
export default class Counter {
constructor() {
this.count = 0n;
this.owner = null;
}
init(owner) {
if (this.owner) throw new Error('already initialized');
this.owner = owner;
}
increment() {
this.count = this.count + 1n;
return this.count;
}
reset(caller) {
if (caller !== this.owner) throw new Error('unauthorized');
this.count = 0n;
}
get() {
return this.count;
}
}That's the entire contract. Note: BigInt for math (no floats in contract semantics), normal class syntax, normal methods. The contract runs inside a Hardened JavaScript (SES) sandbox — it can't touch the network, the filesystem, the clock, or random sources. It's just data and logic.
Test it locally
The Asentum CLI ships with a local in-memory chain you can run tests against:
npx @asentum/cli test counter.jsOr write Jest-style tests in counter.test.js using @asentum/testing — the test harness provides snapshot/revert, time control, and pre-funded mock accounts.
Deploy to testnet
npx @asentum/cli deploy counter.js --network testnetThe CLI gzip-compresses your source, signs the deploy transaction with your wallet, broadcasts it, and prints the contract address once the transaction finalizes:
✓ Source compiled and gzipped (412 bytes)
✓ Deploy fee: 0.0042 ASE (base fee + per-byte deploy cost)
✓ Signed and broadcast: 0xd9a4...
✓ Confirmed at block 18420
✓ Contract deployed at: 0x5aC14fD3A2c0e8ee48B07C8A3D1Ebf27b0EeDF0CYour contract is now immutable. The source you just deployed is what runs forever, unless you explicitly built in a proxy pattern with a configurable upgrade authority.
Call your contract
From the SDK:
import { Chain } from '@asentum/sdk';
const chain = new Chain({ rpc: 'https://rpc-testnet.asentum.io' });
const counter = await chain.contract('0x5aC14fD3A2c0e8ee48B07C8A3D1Ebf27b0EeDF0C');
// Mutating call (signs a transaction)
const newValue = await counter.increment({ signer: wallet });
// Read-only call (no signature, no gas)
const current = await counter.get();
console.log('Counter is now', current);Note: cross-contract calls — calls from one contract to another — are async via the E() syntax. From your application code (not from another contract), the SDK handles this transparently.
Verify the source
Verification on Asentum is free, automatic, and trivial. Because contracts deploy as plain JavaScript source (not bytecode), verification is just a hash compare:
hash(submitted_source) == deployed_code_hashThe block explorer shows your contract source directly with syntax highlighting, comments, everything you wrote. Anyone can hash the file locally with any BLAKE3 implementation and confirm it matches the deployed code.
Next steps
- Read the contract model — async message-passing, immutability, source verification, modular pricing
- SDK & CLI reference — every command, every API method
- Interact with a contract — for users of contracts you didn't write