Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,52 @@ contract Bar {

Provides comprehensive assertion functions for testing, including equality checks (assertEq, assertNotEq), comparisons (assertLt, assertGt, assertLe, assertGe), approximate equality (assertApproxEqAbs, assertApproxEqRel), and boolean assertions (assertTrue, assertFalse). All assertions support multiple data types and optional custom error messages.

### StdConfig

This is a contract that parses a TOML configuration file and loads its variables into storage, automatically casting them on deployment. It assumes a TOML structure where top-level keys represent chain IDs or aliases. Under each chain key, variables are organized by type in separate sub-tables like `[<chain>.<type>]`, where type must be: `bool`, `address`, `bytes32`, `uint`, `int`, `string`, or `bytes`.

#### Example usage

```solidity

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "forge-std/StdConfig.sol";

contract MyScript is Script {
StdConfig config;

function run() public {
// Load config (set writeToFile=true only in scripts to persist changes)
config = new StdConfig("config.toml", false);

// Get values for the current chain
uint256 myNumber = config.get("important_number").toUint256();
address weth = config.get("weth").toAddress();
address[] memory admins = config.get("whitelisted_admins").toAddressArray();

// Get values for a specific chain
bool isLive = config.get(1, "is_live").toBool();

// Check if a key exists
if (config.exists("optional_param")) {
// ...
}

// Get RPC URL for current or specific chain
string memory rpc = config.getRpcUrl();
string memory mainnetRpc = config.getRpcUrl(1);

// Get all configured chain IDs
uint256[] memory chainIds = config.getChainIds();
}
}
```

See the contract itself for supported TOML format and all available methods.

### `console.log`

Usage follows the same format as [Hardhat](https://hardhat.org/hardhat-network/reference/#console-log).
Expand Down