Skip to content

Commit bc44590

Browse files
committed
merge docs
1 parent 29060a3 commit bc44590

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

book/src/framework/fork_storage.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Fork Testing (Mutating Storage)
2+
3+
We provide API to use `anvil_setStorageAt` more easily so in case you can't edit EVM smart contracts code you can still mutate your contract values.
4+
5+
You need to build your contract layout first
6+
```
7+
forge build || forge inspect Counter storageLayout --json > layout.json
8+
```
9+
10+
And then you can use `AnvilSetStorageAt` to override contract's storage data
11+
```
12+
r := rpc.New(rpcURL, nil)
13+
err = r.AnvilSetStorageAt([]interface{}{contractAddr, slot, data})
14+
```
15+
See [examples](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/evm_storage/layout_api_test.go) of how you can use API to encode/mutate different values.
16+
17+
Keep in mind that values <32 bytes are packed together, see `encodeCustomStructFunc` example and `offset` example to understnad how to change them properly.
18+
19+
```
20+
cd framework/evm_storage
21+
./setup.sh
22+
go test -v -run TestLayoutAPI
23+
./teardown.sh
24+
```
25+
26+
Read more about Solidity storage layout [here](https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#)

0 commit comments

Comments
 (0)