https://github.com/adrianmcli/foundry-counter
Just working through some basic workflows.
https://github.com/adrianmcli/foundry-counter
Last synced: about 1 year ago
JSON representation
Just working through some basic workflows.
- Host: GitHub
- URL: https://github.com/adrianmcli/foundry-counter
- Owner: adrianmcli
- Created: 2023-11-14T21:50:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-14T22:03:17.000Z (over 2 years ago)
- Last Synced: 2025-01-17T04:44:25.571Z (about 1 year ago)
- Language: Solidity
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Foundry Counter Example
Just a simple project for me to practice the basic workflows of Foundry development.
## Manual Testing with Anvil
1. 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".
2. Make a `.env` file at project root and place one of Anvil's provided private keys (e.g.`PRIVATE_KEY=0x1234...`).
3. Run the following to deploy:
```bash
forge script script/Counter.s.sol --broadcast --rpc-url http://localhost:8545
```
4. (optional) Check that the contract is there by doing a `cast call`:
```bash
cast call "number()(uint256)" --rpc-url http://localhost:8545
```
5. (optional) Send a transaction to the contract by doing a `cast send`:
```bash
cast send "increment()" --rpc-url http://localhost:8545 --private-key
```
## Usage
### Build
```shell
$ forge build
```
### Test
```shell
$ forge test
```
### Format
```shell
$ forge fmt
```
### Gas Snapshots
```shell
$ forge snapshot
```
### Anvil
```shell
$ anvil
```
### Deploy
```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key
```
### Cast
```shell
$ cast
```
### Help
```shell
$ forge --help
$ anvil --help
$ cast --help
```