Skip to content

Commit

Permalink
chore: adds foundry templates to quickstart templates (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter authored May 10, 2024
1 parent eb9e8bb commit 5dad8cc
Show file tree
Hide file tree
Showing 79 changed files with 770 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "templates/quickstart/foundry/hello-zksync/lib/forge-std"]
path = templates/quickstart/foundry/hello-zksync/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "templates/quickstart/foundry/factory/lib/forge-std"]
path = templates/quickstart/foundry/factory/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "templates/quickstart/foundry/testing/lib/forge-std"]
path = templates/quickstart/foundry/testing/lib/forge-std
url = https://github.com/foundry-rs/forge-std
1 change: 1 addition & 0 deletions templates/quickstart/foundry/factory/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WALLET_PRIVATE_KEY=0x
16 changes: 16 additions & 0 deletions templates/quickstart/foundry/factory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compiler files
cache/
out/
zkout/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
broadcast/
66 changes: 66 additions & 0 deletions templates/quickstart/foundry/factory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Foundry

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## 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 <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
10 changes: 10 additions & 0 deletions templates/quickstart/foundry/factory/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

[rpc_endpoints]
zkSyncSepoliaTestnet = "https://sepolia.era.zksync.dev"
inMemoryNode = "http://127.0.0.1:8011"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions templates/quickstart/foundry/factory/lib/forge-std
Submodule forge-std added at 978ac6
31 changes: 31 additions & 0 deletions templates/quickstart/foundry/factory/script/DeployFactory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "forge-std/console.sol";
import "../src/CrowdfundFactory.sol";
import "../src/CrowdfundingCampaign.sol";

contract DeployFactoryAndCreateCampaign is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("WALLET_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

// Deploy the CrowdfundingFactory contract
CrowdfundingFactory factory = new CrowdfundingFactory();

// Log the factory's address
console.log("CrowdfundingFactory deployed at: %s", address(factory));

// Define the funding goal for the new campaign
uint256 fundingGoalInWei = 0.01 ether;

// Use the factory to create a new CrowdfundingCampaign
factory.createCampaign(fundingGoalInWei);

// Not sure how to get the address of the new campaign
// TODO: Log the address of the new campaign

vm.stopBroadcast();
}
}
1 change: 1 addition & 0 deletions templates/quickstart/foundry/hello-zksync/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WALLET_PRIVATE_KEY=0x
16 changes: 16 additions & 0 deletions templates/quickstart/foundry/hello-zksync/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compiler files
cache/
out/
zkout/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
broadcast/
66 changes: 66 additions & 0 deletions templates/quickstart/foundry/hello-zksync/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## Foundry

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## 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 <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
10 changes: 10 additions & 0 deletions templates/quickstart/foundry/hello-zksync/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

[rpc_endpoints]
zkSyncSepoliaTestnet = "https://sepolia.era.zksync.dev"
inMemoryNode = "http://127.0.0.1:8011"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions templates/quickstart/foundry/hello-zksync/lib/forge-std
Submodule forge-std added at 978ac6
17 changes: 17 additions & 0 deletions templates/quickstart/foundry/hello-zksync/script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "../src/Crowdfund.sol";

contract DeployCrowdfundContract is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("WALLET_PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

uint256 fundingGoalInWei = 0.02 ether;
new CrowdfundingCampaign(fundingGoalInWei);

vm.stopBroadcast();
}
}
16 changes: 16 additions & 0 deletions templates/quickstart/foundry/testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compiler files
cache/
out/
zkout/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
broadcast/
Loading

0 comments on commit 5dad8cc

Please sign in to comment.