Skip to content

Commit 9576190

Browse files
committed
better abi export, added upgrade docs
1 parent 45b119b commit 9576190

File tree

15 files changed

+1940
-1936
lines changed

15 files changed

+1940
-1936
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
"editor.defaultFormatter": "JuanBlanco.solidity"
88
},
99
"solidity.formatter": "forge",
10-
"solidity.compileUsingRemoteVersion": "v0.8.26",
1110
"solidity.defaultCompiler": "localFile",
11+
// remappings.txt here fixes random errors
12+
"solidity.remappingsUnix": [
13+
"forge-std/=lib/forge-std/src/",
14+
"@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
15+
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
16+
"@openzeppelin/foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/"
17+
],
1218
"material-icon-theme.files.associations": {
1319
".gas-snapshot": "bench-ts"
1420
}

README.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ To interact with the blockchain, we require an RPC endpoint. You can get one fro
105105

106106
You will use this endpoint for the commands that interact with the blockchain, such as deploying and upgrading; or while doing fork tests.
107107

108-
### Deploy & Verify Contract
108+
### Deploy Contract
109109

110110
Deploy the contract with:
111111

@@ -116,9 +116,23 @@ forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> \
116116
--broadcast
117117
```
118118

119-
You can see deployed contract addresses under the [`deployments/<chainid>.json`](./deployments/)
119+
You can see deployed contract addresses under the [`deployments/<chainid>.json`](./deployments/) folder.
120120

121-
You can verify the contract during deployment by adding the verification arguments as well:
121+
You will need the contract ABIs to interact with them as well, thankfully there is a nice short-hand command to export that:
122+
123+
```sh
124+
forge inspect <CONTRACT_NAME> abi > ./deployments/abis/<CONTRACT_NAME>.json
125+
```
126+
127+
### Verify Contract
128+
129+
Verification requires the following values, based on which provider you are using:
130+
131+
- **Provider**: can accept any of `etherscan`, `blockscout`, `sourcify`, `oklink` or `custom` for more fine-grained stuff.
132+
- **URL**: based on the chosen provider, we require its URL as well, e.g. `https://base-sepolia.blockscout.com/api/` for `blockscout` on Base Sepolia
133+
- **API Key**: an API key from the chosen provider, must be stored as `ETHERSCAN_API_KEY` in environment no matter whicih provider it is!.
134+
135+
You can actually verify the contract during deployment by adding the verification arguments as well:
122136

123137
```sh
124138
forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> \
@@ -129,51 +143,33 @@ forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> \
129143
--verifier-url <VERIFIER_URL>
130144
```
131145

132-
You can verify an existing contract with:
146+
Alternatively, you can verify an existing contract (perhaps deployed from a factory) with:
133147

134148
```sh
135149
forge verify-contract <CONTRACT_ADDRESS> ./src/<CONTRACT_NAME>.sol:<CONTRACT_NAME> \
136-
--verifier blockscout \
137-
--verifier-url <VERIFIER_URL>
150+
--verifier blockscout --verifier-url <VERIFIER_URL>
138151
```
139152

140-
Note that the `--verifier-url` value should be the target explorer's homepage URL. Some example URLs are:
141-
142-
- `https://base.blockscout.com/api/` for Base (Mainnet)
143-
- `https://base-sepolia.blockscout.com/api/` for Base Sepolia (Testnet)
144-
145-
> [!NOTE]
146-
>
147-
> URL should not contain the API key! Foundry will read your `ETHERSCAN_API_KEY` from environment.
148-
149-
> [!NOTE]
150-
>
151-
> The `--verifier` can accept any of the following: `etherscan`, `blockscout`, `sourcify`, `oklink`. We are using Blockscout most of the time.
152-
153-
After deployment, we need to take care of two things:
153+
### Upgrade Contract
154154

155-
- **ABIs**: to interact with the contracts
156-
- **Artifacts**: required if we need to upgrade in future
155+
Upgrading an existing contract is done as per the instructions in [openzeppelin-foundry-upgrades](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades) repository.
157156

158-
We have a post-deployment script that outputs these files under the [`deployments/abis`](./deployments/abis/) folder:
157+
First, we create a new contract with its name as `ContractNameV2`, and then we execute the following command:
159158

160159
```sh
161-
# requires NodeJS
162-
./post-deploy.sh
160+
forge script ./script/Deploy.s.sol:Upgrade<CONTRACT_NAME> \
161+
--rpc-url <RPC_URL> \
162+
--account <WALLET_NAME> --broadcast \
163+
--sender <WALLET_ADDRESS> \
164+
--verify --verifier blockscout \
165+
--verifier-url <VERIFIER_URL>
163166
```
164167

165-
### Upgrade Contract
166-
167-
Upgrading an existing contract is done as per the instructions in [openzeppelin-foundry-upgrades](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades) repository.
168-
169-
To upgrade, you must
170-
171168
> [!NOTE]
172169
>
173-
> The `--sender <ADDRESS>` field is mandatory when deploying a contract, it can be obtained with:
170+
> The `--sender <ADDRESS>` field is mandatory when deploying a contract, it can be obtained with the command below, which will prompt for keystore password:
174171
>
175172
> ```sh
176-
> # will prompt for password
177173
> cast wallet address --account <WALLET_NAME>
178174
> ```
179175

broadcast/Deploy.s.sol/84532/run-latest.json

Lines changed: 68 additions & 68 deletions
Large diffs are not rendered by default.

deployments/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
31337.json
1+
31337/

0 commit comments

Comments
 (0)