8
8
refs :
9
9
- https://github.com/foundry-rs/foundry
10
10
- https://book.getfoundry.sh/
11
- date : 2023-08-14
11
+ date : 2025-03-28
12
12
draft : false
13
13
---
14
14
@@ -28,8 +28,6 @@ We can set the environment variable for **Ethereum RPC URL** to interact the Eth
28
28
export ETH_RPC_URL=" http://10.0.0.1:12345/path/to/rpc"
29
29
```
30
30
31
- <br />
32
-
33
31
## Investigating a Chain
34
32
35
33
** ` cast ` ** command of Foundry performs Ethereum RPC calls.
@@ -51,8 +49,6 @@ cast block-number
51
49
cast block
52
50
```
53
51
54
- <br />
55
-
56
52
## Investigating Account
57
53
58
54
``` bash
@@ -62,17 +58,22 @@ cast balance 0x123...
62
58
cast balance beer.eth
63
59
```
64
60
65
- <br />
66
-
67
61
## Investigating Contract
68
62
69
63
``` sh
70
64
# Get the source code of a contract from Etherscan
71
- cast etherscan-source < contract_address>
72
- cast etherscan-source 0x123...
65
+ cast source < contract_address> -e < etherscan_api_key>
73
66
```
74
67
75
- <br />
68
+ ## Call Functions
69
+
70
+ If we know the functions of a target contract, we can simply call them. Note that these command do NOT send transactions, so cannot change states or values in the contract.
71
+
72
+ ``` bash
73
+ cast call --private-key < private_key_addr> < contract_addr> " getFlag()(string memory)"
74
+
75
+ cast call --private-key < private_key_addr> < contract_addr> " isSolved()(bool)"
76
+ ```
76
77
77
78
## Send Transactions
78
79
@@ -92,4 +93,6 @@ cast send --private-key 0x123... 0xabc... "dummy()"
92
93
# Send Ether to call the receive function
93
94
cast send --private-key < private_key_addr> < contract_addr> --value 10gwei
94
95
cast send --private-key 0x123... 0xabc... --value 10gwei
95
- ```
96
+ ```
97
+
98
+ If we got error like unsupported feature: eip1559 , add ` --legacy ` flag for the command.
0 commit comments