├── .env.example ├── .github └── workflows │ └── test.yml ├── .gitignore ├── .gitmodules ├── README.md ├── foundry.toml ├── script └── PurchaseEdition.sol ├── src └── Contract.sol └── test └── Contract.t.sol /.env.example: -------------------------------------------------------------------------------- 1 | RPC_URL="https://eth-mainnet.alchemyapi.io/v2/YOUR-ALCHEMY-KEY" -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | FOUNDRY_PROFILE: ci 7 | 8 | jobs: 9 | check: 10 | strategy: 11 | fail-fast: true 12 | 13 | name: Foundry project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | with: 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | with: 23 | version: nightly 24 | 25 | - name: Run Forge build 26 | run: | 27 | forge --version 28 | forge build --sizes 29 | id: build 30 | 31 | - name: Run Forge tests 32 | run: | 33 | forge test -vvv 34 | id: test 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/* 8 | /broadcast/*/31337/ 9 | 10 | .env 11 | .env.* 12 | !.env.example -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "lib/zora-drops-contracts"] 5 | path = lib/zora-drops-contracts 6 | url = https://github.com/ourzora/zora-drops-contracts 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZORA Foundry Script Snippets 2 | 3 | Just a little playground showing how you can vibe with ZORA contracts from Foundry [scripts](https://book.getfoundry.sh/tutorials/solidity-scripting). Starting with some really simple things and y'know, maybe we'll go off from there 4 | 5 | ## Setup 6 | 7 | 1. [Install Foundry](https://book.getfoundry.sh/getting-started/installation) if you don't have it yet 8 | 2. Fill out some environment variables! 9 | 10 | ```bash 11 | RPC_URL="https://eth-mainnet.alchemyapi.io/v2/YOUR-ALCHEMY-KEY" 12 | ``` 13 | 14 | ## Scripts 15 | 16 | ### [Purchase an Edition](script/PurchaseEdition.sol) 17 | 18 | ```zsh 19 | forge script \ 20 | script/PurchaseEdition.sol:PurchaseEdition \ 21 | --rpc-url $RPC_URL \ 22 | --froms "0xYOUR_WALLET_ADDRESS" 23 | --interactives 1 \ 24 | --sig "run(address dropAddress, uint256 quantity)" \ 25 | "0xDROP_CONTRACT_ADDRESS" 1 \ 26 | -vvv \ 27 | --broadcast 28 | ``` 29 | 30 | btw this is kinda verbose because we're specifying a custom function signature for `run()`: if you hardcoded the variables (or loaded them with environment variables) it would be a little cleaner. 31 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | 6 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config -------------------------------------------------------------------------------- /script/PurchaseEdition.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.13; 3 | 4 | import "forge-std/Script.sol"; 5 | import {IERC721Drop} from "zora-drops-contracts/interfaces/IERC721Drop.sol"; 6 | 7 | contract PurchaseEdition is Script { 8 | function run(address dropAddress, uint256 quantity) public { 9 | IERC721Drop drop = IERC721Drop(dropAddress); 10 | 11 | vm.startBroadcast(); 12 | 13 | IERC721Drop.SaleDetails memory details = drop.saleDetails(); 14 | 15 | console.log("totalMinted:", details.totalMinted); 16 | console.log("maxSupply:", details.maxSupply); 17 | console.log("publicSalePrice:", details.publicSalePrice); 18 | 19 | drop.purchase(quantity); 20 | 21 | vm.stopBroadcast(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Contract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Contract {} 5 | -------------------------------------------------------------------------------- /test/Contract.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "forge-std/Test.sol"; 5 | 6 | contract ContractTest is Test { 7 | function setUp() public {} 8 | 9 | function testExample() public { 10 | assertTrue(true); 11 | } 12 | } 13 | --------------------------------------------------------------------------------