Skip to main content

What is a Smart Contract?

A smart contract is a program that lives on-chain. Once deployed, it runs exactly as written — no company or person controls it. Anyone can call it, and the outcome is transparent and verifiable. NEXUS smart contracts run on Zcash today. The same contract code will work identically when Bitcoin and Dogecoin join the unified execution layer. On NEXUS, smart contracts can:
  • Hold and transfer vZEC (live), vSAT and vDOGE (coming soon)
  • Run any logic — token balances, swap pools, lending, NFTs
  • Call other contracts — composable DeFi
  • Read Zcash L1 data — e.g. block height, deposit confirmations

How it Works (No Code Required)

You write logic in Rust

Compile to WebAssembly (WASM) — a compact, fast binary format

Deploy to NEXUS — gets a permanent address on-chain

Anyone calls your contract — NEXUS runs it, results are final
WASM is the same technology used in modern web browsers — it is fast, portable, and sandboxed.

What Can Contracts Do?

Contracts have persistent storage — like a database that lives on-chain forever. A token contract stores balances. An AMM stores liquidity pool reserves. No server, no database bill — it just exists.
Contracts can hold and move vSAT (Bitcoin), vZEC (Zcash), and vDOGE (Dogecoin). A swap pool holds both sides of a trading pair. A lending protocol holds collateral. Funds only move when contract logic says they can.
Contracts can call each other — this is how DeFi composes. A yield vault can call an AMM to swap, which calls a token to transfer. Everything happens atomically in one transaction.
Contracts emit events when things happen (e.g. “Transfer: Alice sent 10 to Bob”). Wallets, explorers, and indexers listen for these events off-chain.
Contracts can read Bitcoin block height, Zcash confirmations, and Dogecoin data directly. This enables time-locks, oracle-free conditions, and cross-chain logic.

Gas: Paying for Computation

Every operation in a contract costs gas — a small fee proportional to how much work the network does. Gas prevents runaway loops and spam. You set a gas limit when submitting a transaction; if your contract uses more, it reverts.
OperationRelative Cost
Read stored dataLow
Write stored dataMedium
Cryptographic hashVery low
Call another contractMedium + subcall cost

Built-in Protections

NEXUS contracts have safeguards built into the SDK:
  • Reentrancy guard — prevents the classic DeFi reentrancy attack automatically
  • Safe math — arithmetic overflows revert the transaction instead of wrapping
  • Require checks — any failed condition reverts the entire transaction (no partial state)

Ready-Made Templates

You don’t have to start from scratch. The nexus-contract-template includes production-ready examples:
ExampleWhat it gives you
CounterMinimal working contract with nexus_fn!
NEP-20Fungible token (like ERC-20)
WVZECWrapped native vZEC for AMM compatibility
AMM PairCore swap logic (SatsAMM)
git clone https://github.com/yattacorp/nexus-contract-template
cd nexus-contract-template
cargo build --target wasm32-unknown-unknown --release

For Developers

If you want to write contracts, see: