Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Latest commit

 

History

History
132 lines (91 loc) · 3.1 KB

File metadata and controls

132 lines (91 loc) · 3.1 KB

Contracts

A Foundry-based Solidity package for testing and demonstration of smart contracts with the TinyExplorer.

The contracts package provides example smart contracts for testing the TinyExplorer's analysis capabilities.

Table of contents

Overview

The contracts package contains a simple example smart contract (Counter.sol) implemented using Solidity and the Foundry development framework. This package serves as a testing ground for the TinyExplorer, providing real contracts that can be analyzed by the system.

Installation

This package is part of the TinyExplorer monorepo. To install it:

# From the repository root
pnpm install

# Install Foundry dependencies
cd packages/contracts
forge install

Prerequisites

  • Foundry - Smart contract development toolkit

Usage

Development

To compile contracts:

forge build

Testing

To run tests:

# Run all tests
forge test

# Run specific test
forge test --match-test testFunctionName -vvv

Deployment

To deploy contracts to a local Anvil node:

# Start an Anvil node
anvil

# Deploy using the script
forge script script/Counter.s.sol --rpc-url http://localhost:8545 --broadcast

Structure

├── src/                # Contract source files
│   └── Counter.sol     # Example counter contract
├── test/               # Test files
│   └── Counter.t.sol   # Tests for Counter contract
├── script/             # Deployment scripts
│   └── Counter.s.sol   # Script to deploy Counter
├── lib/                # Dependencies (managed by Forge)
│   └── forge-std/      # Forge standard library
└── foundry.toml        # Foundry configuration

Contract Details

Counter.sol

A simple smart contract that demonstrates basic state management:

  • Stores a single integer value
  • Provides functions to get, set, and increment the value
  • Used for testing the indexer's analysis capabilities
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract Counter {
    uint256 public number;

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }

    function increment() public {
        number++;
    }
}

Additional Foundry Commands

  • Format code: forge fmt
  • Gas snapshots: forge snapshot
  • Interact with contracts: cast <subcommand>
  • Get help: forge --help, anvil --help, cast --help

For more information on Foundry, visit the Foundry documentation.

Contributing

If you wish to contribute to this package, please follow the contribution guidelines in the root repository README.

License

This project is licensed under the MIT License - see the LICENSE file for details.