Smart Contracts

Writing, testing, and deploying Solidity smart contracts on Armchain.

Overview

If you've built smart contracts on Ethereum, you already know how to build on Armchain. The EVM is fully compatible (London fork), so no Solidity changes are required. The main differences are at the network level:

  • Transactions use ML-DSA44 signatures (not ECDSA), handled by the SDK

  • Transaction type is 3 (PQC), set automatically by the SDK

  • Finality is instant, no need to wait for confirmations

Development Setup

Option 1: Remix IDE

No local setup required.

  1. Write your Solidity contract

  2. In the Solidity Compiler tab, select version 0.8.24 and set EVM version to london

  3. In the Deploy & Run Transactions tab, select Injected Provider (with Armchain Wallet connected)

  4. For local development, select External HTTP Provider and enter http://localhost:4000

Option 2: Hardhat (Partial Compatibility)

⚠ Compatibility Warning: Hardhat's built-in signers and hre.ethers use ECDSA and cannot sign Armchain transactions. The following features are not supported with standard Hardhat:

  • hre.ethers.getSigners() / hre.ethers.getContractFactory().deploy() (ECDSA signing fails)

  • Self-funding test accounts

  • Fork testing against Armchain

Hardhat can be used for: npx hardhat compile, artifact generation, and project structure. All signing must go through @armchain-ethersv6/ethers.

Configure for Armchain:

Compile with:

Writing Contracts

Supported Solidity Versions

Use Solidity 0.8.x. Recommended:

EVM Version

Set the EVM target to london in your compiler settings. Do not use:

  • shanghai (PUSH0 opcode not supported)

  • cancun (transient storage not supported)

Standard Patterns

All common Solidity patterns work on Armchain:

ERC-20 Token

NFT (ERC-721)

Upgradeable Contract (Proxy Pattern)

Testing

⚠ Compatibility Warning: Hardhat's default test environment (hre.ethers.getSigners()) provides ECDSA signers that cannot send Armchain transactions. Hardhat tests that deploy contracts or send transactions will fail. Unit tests that only test pure Solidity logic (no state changes) work fine.

For contract interaction tests, use the Armchain Ethers SDK with a local Fakenet:

Remix IDE also has a built-in Solidity Unit Testing plugin for simpler logic checks.

Deploying

Remix IDE

Deploy using Remix IDE with the Injected Provider environment (Armchain Wallet). For a step-by-step walkthrough, see the Quickstart.

Hardhat + Armchain Ethers SDK

⚠ Do not use hre.ethers for deployments. Use @armchain-ethersv6/ethers with artifacts generated by npx hardhat compile.

Run with Node.js directly (not via npx hardhat run, which injects an ECDSA signer):

Contract Verification

Submit your source code to the Armchain Explorer for public verification:

  1. Deploy your contract

  2. Navigate to the contract address on explorer.armchain.orgarrow-up-right

  3. Click "Verify & Publish"

  4. Submit your source code, compiler version, and constructor arguments

The explorer supports:

  • Single file verification

  • Standard JSON input verification

  • Multi-file verification with imports

Gas Optimization Tips

Since Armchain uses the same gas model as Ethereum (Berlin pricing):

  1. Use calldata instead of memory for read-only function parameters

  2. Pack storage variables so that uint128 + uint128 fits in one 32-byte slot

  3. Use immutable and constant for values that don't change

  4. Minimize storage writes since they cost 20,000-5,000 gas

  5. Use events for data that doesn't need on-chain reads

  6. Enable the optimizer with 200+ runs

Security Best Practices

  1. Use OpenZeppelin contracts for standard implementations

  2. Follow checks-effects-interactions pattern to prevent reentrancy

  3. Use ReentrancyGuard for state-changing external calls

  4. Validate all inputs by checking addresses, amounts, and array lengths

  5. Use access control like Ownable, AccessControl, or custom modifiers

  6. Test thoroughly with unit tests, integration tests, and fuzz tests

  7. Get audited before production deployment

  8. Use timelocks for admin functions in production

Important Notes

  • No PUSH0 opcode: Set evmVersion: "london" in compiler settings.

  • Instant finality: No confirmation waits. Once mined, the contract is live.

  • Same address derivation: CREATE and CREATE2 work identically to Ethereum.

  • Gas prices: EIP-1559 fee market. Minimum gas price is 1 Gwei.

Further Reading

Last updated