Skip to main content

Overview

The simplest starting point for Web3 development. Includes two contracts — a Counter for learning state management and a SimpleToken ERC-20 — with full test suites.
DifficultyBeginner
CategoryBasic
ChainsEthereum
ServicesNone
LicenseApache-2.0

Quick Start

dokrypt init my-app --template evm-basic
cd my-app
dokrypt up

Generated Files

my-app
dokrypt.yaml
foundry.toml
README.md
contracts
Counter.sol
SimpleToken.sol
test
Counter.t.sol
SimpleToken.t.sol
scripts
deploy.js

Configuration

version: "1"
name: my-app

settings:
  runtime: docker
  log_level: info
  accounts: 10
  account_balance: "10000"

chains:
  ethereum:
    engine: anvil
    chain_id: 31337
    block_time: "2s"

services: {}

Contracts

Counter.sol

A simple state management contract for learning the basics. Storage:
  • uint256 public number — The stored counter value
Functions:
FunctionAccessDescription
setNumber(uint256 newNumber)PublicSet the counter to a specific value
increment()PublicIncrease counter by 1
decrement()PublicDecrease counter by 1 (reverts if 0)
reset()PublicReset counter to 0
Events:
  • NumberChanged(uint256 newNumber) — Emitted on every state change

SimpleToken.sol

A minimal ERC-20 token implementation. Constructor:
constructor(string memory name, string memory symbol, uint256 initialSupply)
Mints initialSupply tokens to the deployer. Functions:
FunctionAccessDescription
transfer(address to, uint256 amount)PublicTransfer tokens
approve(address spender, uint256 amount)PublicApprove spending
transferFrom(address from, address to, uint256 amount)PublicTransfer on behalf
mint(address to, uint256 amount)Owner onlyMint new tokens
balanceOf(address account)ViewGet token balance
allowance(address owner, address spender)ViewGet allowance
Constants: 18 decimals

Deployment

npx hardhat run scripts/deploy.js --network localhost
The script deploys both Counter and SimpleToken and outputs their addresses.

Testing

dokrypt test run
Tests cover:
  • Counter: increment, decrement, setNumber, reset, underflow revert
  • SimpleToken: transfer, approve, transferFrom, mint, access control