Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 757353a

Browse files
committed
Merge branch 'main' into heather/review
2 parents 0b4d1a6 + 64eea72 commit 757353a

File tree

16 files changed

+163
-45
lines changed

16 files changed

+163
-45
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
3-
url = https://github.com/foundry-rs/forge-std
3+
url = https://github.com/foundry-rs/forge-std

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,32 @@ Example `chainweb.config.json`:
4040

4141
```json
4242
{
43-
"anvil": {
44-
"numberOfChains": 5,
45-
"chainwebChainIdOffset": 20,
46-
"chainIdOffset": 62600
47-
},
48-
"sandbox": {
49-
"numberOfChains": 5,
50-
"chainwebChainIdOffset": 20,
51-
"chainIdOffset": 1789,
52-
"externalHostUrl": "http://localhost:1848/chainweb/0.0/evm-development"
53-
}
43+
"anvil": {
44+
"numberOfChains": 5,
45+
"chainwebChainIdOffset": 20,
46+
"chainIdOffset": 62600
47+
},
48+
"testnet": {
49+
"numberOfChains": 5,
50+
"chainwebChainIdOffset": 20,
51+
"chainIdOffset": 5920,
52+
"externalHostUrl": "https://evm-testnet.chainweb.com/chainweb/0.0/evm-testnet"
53+
}
5454
}
5555
```
5656

5757
#### Configuration Parameters
5858

59-
| Parameter | Type | Description |
60-
| ----------------------- | -------- | ------------------------------------------------------------------ |
61-
| `numberOfChains` | `number` | Number of chains to initialize and fork |
62-
| `chainwebChainIdOffset` | `number` | Starting Chainweb chain ID to map from |
63-
| `chainIdOffset` | `number` | Base chain ID offset for EVM chain IDs |
64-
| `externalHostUrl` | `string` | External Chainweb host URL |
59+
| Parameter | Type | Description |
60+
| ----------------------- | -------- | --------------------------------------- |
61+
| `numberOfChains` | `number` | Number of chains to initialize and fork |
62+
| `chainwebChainIdOffset` | `number` | Starting Chainweb chain ID to map from |
63+
| `chainIdOffset` | `number` | Base chain ID offset for EVM chain IDs |
64+
| `externalHostUrl` | `string` | External Chainweb host URL |
6565

6666
**Important**: This configuration is only used when running scripts with `ChainwebScript`. When running tests with `ChainwebTest`, the configuration parameters are passed directly to the constructor and the config file is ignored.
6767

68+
**note:** If you cloned the repo and want to run tests/scripts for the example project first go to `/examples/Counter` path. otherwise you do not need to do this step.
6869

6970
### Tests
7071

@@ -144,18 +145,18 @@ The script uses the following environment variables:
144145
Run script with default configuration (uses "anvil" environment):
145146

146147
```bash
147-
forge script --multi src/example/script/Counter.s.sol:CounterScript \
148+
forge script --multi script/Counter.s.sol:CounterScript \
148149
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
149150
--broadcast
150151
```
151152

152-
Run script with a specific environment from config (e.g., "sandbox"):
153+
Run script with a specific environment from config (e.g., "testnet"):
153154

154155
Note: Before runing this script, clone and start the sandbox [repo](https://github.com/kadena-io/kadena-evm-sandbox).
155156

156157
```bash
157-
CHAINWEB=sandbox forge script --multi src/example/script/Counter.s.sol:CounterScript \
158-
--private-key 0xe711c50150f500fdebec57e5c299518c2f7b36271c138c55759e5b4515dc7161 \
158+
CHAINWEB=testnet forge script --multi script/Counter.s.sol:CounterScript \
159+
--private-key <your_private_key> \
159160
--broadcast --legacy
160161
```
161162

@@ -189,4 +190,4 @@ chainid = chain_id + index
189190
190191
```
191192

192-
You can configure the `chain_id` in your `foundry.toml` file. Each test or script chain will increment from this base value. The default value is `31337` in Foundry.
193+
Which `chain_id` comes from `foundry.toml` file (default = `31337`). Each test or script chain will increment from this base value.

examples/Counter/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

examples/Counter/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Foundry
2+
3+
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
4+
5+
Foundry consists of:
6+
7+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
11+
12+
## Documentation
13+
14+
https://book.getfoundry.sh/
15+
16+
## Usage
17+
18+
### Build
19+
20+
```shell
21+
$ forge build
22+
```
23+
24+
### Test
25+
26+
```shell
27+
$ forge test
28+
```
29+
30+
### Format
31+
32+
```shell
33+
$ forge fmt
34+
```
35+
36+
### Gas Snapshots
37+
38+
```shell
39+
$ forge snapshot
40+
```
41+
42+
### Anvil
43+
44+
```shell
45+
$ anvil
46+
```
47+
48+
### Deploy
49+
50+
```shell
51+
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52+
```
53+
54+
### Cast
55+
56+
```shell
57+
$ cast <subcommand>
58+
```
59+
60+
### Help
61+
62+
```shell
63+
$ forge --help
64+
$ anvil --help
65+
$ cast --help
66+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"anvil": {
3+
"numberOfChains": 5,
4+
"chainwebChainIdOffset": 20,
5+
"chainIdOffset": 62600
6+
},
7+
"sandbox": {
8+
"numberOfChains": 5,
9+
"chainwebChainIdOffset": 20,
10+
"chainIdOffset": 1789,
11+
"externalHostUrl": "http://localhost:1848/chainweb/0.0/evm-development"
12+
},
13+
"testnet": {
14+
"numberOfChains": 5,
15+
"chainwebChainIdOffset": 20,
16+
"chainIdOffset": 5920,
17+
"externalHostUrl": "https://evm-testnet.chainweb.com/chainweb/0.0/evm-testnet"
18+
}
19+
}

examples/Counter/foundry.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"../../lib/forge-std": {
3+
"rev": "60acb7aaadcce2d68e52986a0a66fe79f07d138f"
4+
},
5+
"lib/forge-std": {
6+
"tag": {
7+
"name": "v1.10.0",
8+
"rev": "8bbcf6e3f8f62f419e5429a0bd89331c85c37824"
9+
}
10+
}
11+
}

examples/Counter/foundry.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[profile.default]
2+
ffi = true
3+
src = "src"
4+
out = "out"
5+
libs = ["lib"]
6+
fs_permissions = [{ access = "read", path = "./chainweb.config.json" }]
7+
8+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

examples/Counter/lib/forge-std

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../lib/forge-std
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../..

examples/Counter/remappings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
kadena-io/foundry-chainweb/=lib/foundry-chainweb/src
2+
forge-std/=lib/forge-std/src

0 commit comments

Comments
 (0)