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.
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.
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- Foundry - Smart contract development toolkit
To compile contracts:
forge buildTo run tests:
# Run all tests
forge test
# Run specific test
forge test --match-test testFunctionName -vvvTo 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├── 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
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++;
}
}- 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.
If you wish to contribute to this package, please follow the contribution guidelines in the root repository README.
This project is licensed under the MIT License - see the LICENSE file for details.