Skip to content

Commit 7bb7a21

Browse files
committed
feat(foundry): Added foundry match bytecode script
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
1 parent a2c7557 commit 7bb7a21

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/veryfyBytecode.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
args=("$@")
4+
5+
if [ ${#args[@]} -ne 3 ]; then
6+
echo "Usage: $0 <tx_hash> <rpc_url> <contract_name>"
7+
exit 1
8+
fi
9+
10+
TX=${args[0]}
11+
RPC=${args[1]}
12+
CONTRACT_NAME=${args[2]}
13+
14+
ONCHAIN=$(cast tx $TX --rpc-url $RPC --json | jq -r '.input' | sed 's/^0x//')
15+
echo "$ONCHAIN" > onchain_creation.hex
16+
17+
ART=out/$CONTRACT_NAME.sol/$CONTRACT_NAME.json
18+
19+
CREATION=$(jq -r '.bytecode.object' "$ART" | sed 's/^0x//')
20+
21+
TAIL=${ONCHAIN:${#CREATION}}
22+
CODE_ONCHAIN=${ONCHAIN:0:${#CREATION}}
23+
24+
25+
26+
cast keccak $CODE_ONCHAIN
27+
cast keccak $CREATION
28+
29+
if [[ $CODE_ONCHAIN == $CREATION ]]; then
30+
echo "✅ Code match";
31+
else
32+
echo "❌ Code mismatch";
33+
fi
34+
35+
36+
37+
38+

0 commit comments

Comments
 (0)