Skip to content

Commit dfdcbfe

Browse files
update readme
1 parent 35d94c1 commit dfdcbfe

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

contracts/README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,33 @@ This project requires Go 1.21 or later. Install from [golang.org](https://golang
2020

2121
The Solidity compiler version 0.8.30 is required to compile contracts. In CI, this is installed automatically via the [setup-solc](https://github.com/ARR4N/setup-solc) GitHub Action.
2222

23-
For local development, you can install solc via:
24-
- **macOS**: `brew install solidity` (or `brew install [email protected]` for version 0.8.x)
23+
For local development, install solc 0.8.30:
24+
- **macOS**: `brew install solidity`
2525
- **Linux**: Follow instructions at [solidity docs](https://docs.soliditylang.org/en/latest/installing-solidity.html)
26-
- **CI**: Automatically installed via GitHub Actions (version 0.8.30)
26+
- **CI**: Automatically installed via GitHub Actions
27+
28+
After installation, create a version-specific alias or symlink:
29+
```bash
30+
# Option 1: Symlink (works in all contexts including go generate)
31+
sudo ln -sf $(which solc) /usr/local/bin/solc-v0.8.30 # Linux
32+
sudo ln -sf $(which solc) /opt/homebrew/bin/solc-v0.8.30 # macOS (Homebrew)
33+
34+
# Option 2: Shell alias (interactive shells only)
35+
echo "alias solc-v0.8.30='solc'" >> ~/.bashrc # or ~/.zshrc
36+
```
2737

2838
### Solidity and Avalanche
2939

3040
It is also helpful to have a basic understanding of [Solidity](https://docs.soliditylang.org) and [Avalanche](https://docs.avax.network).
3141

3242
## Dependencies
3343

34-
Clone the repo and initialize submodules:
44+
Clone the repo and install dependencies:
3545

3646
```bash
3747
git clone https://github.com/ava-labs/subnet-evm.git
38-
cd subnet-evm
39-
git submodule update --init --recursive
48+
cd subnet-evm/contracts
49+
npm ci # Installs OpenZeppelin and other Node.js dependencies
4050
```
4151

4252
## Compiling Contracts
@@ -55,18 +65,23 @@ This will:
5565
1. Compile all Solidity contracts in `contracts/contracts/` to ABIs and bytecode
5666
2. Generate Go bindings in `contracts/bindings/`
5767

58-
The compilation artifacts are stored in `contracts/artifacts/` (gitignored).
68+
The compilation artifacts (`.abi` and `.bin` files) are stored in `contracts/artifacts/` (gitignored).
69+
The generated Go bindings in `contracts/bindings/` are committed to the repository.
5970

6071
### Manual Compilation
6172

62-
To manually compile contracts:
73+
To manually compile contracts and generate bindings:
6374

6475
```bash
6576
cd contracts
66-
go generate ./contracts/compile.go # Compile Solidity contracts
67-
go generate ./bindings/bindings.go # Generate Go bindings
77+
npm ci # Install dependencies if not already done
78+
go generate ./... # Compile contracts and generate bindings
6879
```
6980

81+
All compilation and code generation is configured in `contracts/contracts/compile.go` using `go:generate` directives. The directives execute in order:
82+
1. First, `solc` compiles `.sol` files to `.abi` and `.bin` files in `artifacts/`
83+
2. Then, `abigen` generates Go bindings from the artifacts to `bindings/*.go`
84+
7085
## Write Contracts
7186

7287
`AllowList.sol` is the base contract which provided AllowList precompile capabilities to inheriting contracts.

0 commit comments

Comments
 (0)