Skip to main content

Common Libraries & Tooling

These libraries are used across the stack to write tests, simulate transactions, connect wallets, and interface with the blockchain in both scripting and frontend contexts.
Ethers and Viem serve similar purposes, but Viem is optimized for frontend apps. Wagmi builds on Viem. Web3.js is no longer recommended for new projects.

Testing Frameworks

Note Smart contract quality and security depend on a comprehensive testing strategy including but not limited to:
  • Unit Tests: Verify individual functions and components
  • Property-Based Fuzzing: Test invariants with random inputs
  • Code Coverage: Ensure all code paths are tested
  • Static Analysis: Detect common vulnerabilities and anti-patterns
The tools and frameworks below provide a foundation for each of these testing layers.

Foundry — Solidity-Native

  • Tests written directly in Solidity.
  • Very fast runner (forge test) and rich cheatcodes for state manipulation.
  • Built-in, configurable fuzzing (forge test --fuzz-runs=N).
  • Includes tools like forge script, forge coverage, and forge snapshot.

Hardhat — JavaScript / TypeScript

  • Mocha + Chai test runner for JS/TS-based tests.
  • Flexible task system (hardhat.config.js), plugin support, and network forking.
  • Integrates with Ethers.js and Solidity tooling for deployments, gas tracking, and test orchestration.

v0.5.0 Compatibility Testing Framework

Cosmos EVM v0.5.0 introduces comprehensive compatibility testing to ensure seamless integration with major Ethereum development tools.

EVM Tools Compatibility Testing

Automated Testing Suites: Five comprehensive test suites validate compatibility with popular Ethereum tools:

Running Compatibility Tests

Local Testing:
Test Structure:

JSON-RPC Compatibility Testing

Comprehensive RPC Validation: New framework compares Cosmos EVM responses against geth for accuracy. Setup:
Test Coverage:
  • Transaction Processing: Compare transaction execution results
  • Block Queries: Validate block structure and data
  • Account Queries: Verify balance and nonce handling
  • Event Logs: Ensure log filtering and retrieval accuracy
  • Gas Estimation: Compare gas estimation algorithms
Configuration:

Fuzz (Property-Based) Testing

Fuzz testing generates random inputs to find edge cases that violate expected properties.
test/MyContract.t.sol (Foundry)
Use fuzzing to test against invariants such as:
  • balance never exceeds total supply
  • no overflow or underflow under bounded inputs
  • access control is consistently enforced

Supplementary Tools

Tools that enhance test coverage, assert correctness, or catch common vulnerabilities.

Example — OpenZeppelin Test Helpers