Just a simple project for me to practice the basic workflows of Foundry development.
-
Start an Anvil instance (on another terminal) by running
anvil. You should get a bunch of public keys and private keys as well as the text "Listening on 127.0.0.1:8545". -
Make a
.envfile at project root and place one of Anvil's provided private keys (e.g.PRIVATE_KEY=0x1234...). -
Run the following to deploy:
forge script script/Counter.s.sol --broadcast --rpc-url http://localhost:8545
-
(optional) Check that the contract is there by doing a
cast call:cast call <contract_deployed_address> "number()(uint256)" --rpc-url http://localhost:8545
-
(optional) Send a transaction to the contract by doing a
cast send:cast send <contract_deployed_address> "increment()" --rpc-url http://localhost:8545 --private-key <private_key_from_anvil>
$ forge build$ forge test$ forge fmt$ forge snapshot$ anvil$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>$ cast <subcommand>$ forge --help
$ anvil --help
$ cast --help