File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ # This script verifies the bytecode of a contract onchain matches the bytecode in the artifact
4
+ # It takes the following arguments:
5
+ # 1. The transaction hash of the contract deployment
6
+ # 2. The RPC URL to use
7
+ # 3. The name of the contract
8
+
9
+ # Note that this script doesn't take into account any link libraries that are used in the contract
10
+
3
11
args=(" $@ " )
4
12
5
13
if [ ${# args[@]} -ne 3 ]; then
@@ -12,27 +20,18 @@ RPC=${args[1]}
12
20
CONTRACT_NAME=${args[2]}
13
21
14
22
ONCHAIN=$( cast tx $TX --rpc-url $RPC --json | jq -r ' .input' | sed ' s/^0x//' )
15
- echo " $ONCHAIN " > onchain_creation.hex
16
23
17
24
ART=out/$CONTRACT_NAME .sol/$CONTRACT_NAME .json
18
25
19
26
CREATION=$( jq -r ' .bytecode.object' " $ART " | sed ' s/^0x//' )
20
27
21
- TAIL=${ONCHAIN: ${# CREATION} }
22
28
CODE_ONCHAIN=${ONCHAIN: 0: ${# CREATION} }
23
29
24
-
25
-
26
30
cast keccak $CODE_ONCHAIN
27
31
cast keccak $CREATION
28
32
29
- if [[ $CODE_ONCHAIN == $CREATION ]]; then
30
- echo " ✅ Code match" ;
31
- else
32
- echo " ❌ Code mismatch" ;
33
+ if [[ $CODE_ONCHAIN == $CREATION ]]; then
34
+ echo " ✅ Code match"
35
+ else
36
+ echo " ❌ Code mismatch"
33
37
fi
34
-
35
-
36
-
37
-
38
-
You can’t perform that action at this time.
0 commit comments