An open API service indexing awesome lists of open source software.

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.

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
```