JustUzair / erc1155-with-factory-foundry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

Usage and Testing

Refer to deployed NFT contract and Token here

Upload the folder to ipfs containing the json files named in sequence like 0, 1, 2...

  • Refer to the following IPFS upload for the same:

  • Contract will internally handle the json files for uri

Installation

git clone https://github.com/KyteSocial/kyte_contracts.git
cd kyte_contracts
npm i
forge build

Running scripts in foundry

Running local testnet

  • anvil

Import Local Blockchain to Wallet for testing, add the follwing to networks in wallet

Network Name : Anvil Testnet

New RPC URL : http://localhost:8545/

Chain ID : 31337

Currency Symbol : ETH

Deploy NFT Collection to a local blockchain

  • forge script script/Deploy.NftCollection.s.sol  --rpc-url anvil_local --broadcast

Deploy NFT Collection to a mainnet or testnet

  •   forge script script/Deploy.NftCollection.s.sol  --rpc-url [mumbai |  base_sepolia |  optimism_sepolia |  eth_sepolia |  eth_mainnet |  base_mainnet |  polygon_mainnet | optimism_mainnet] --broadcast

Minting NFT to a chain using foundry script

  • forge script script/DeployAndMintFromCollection.s.sol  --rpc-url anvil_local --broadcast

Running foundry tests

  • forge test -vvv

Running a particular test in the test file

  • forge test --mt test_name -vvv

Etherscan Explorers

Deploy and Verify

Eth Sepolia

forge create --rpc-url eth_sepolia --private-key $PRIVATE_KEY src/NFTCollectionFactory.sol:NFTCollectionFactory \
 --constructor-args $(cast abi-encode --packed "constructor(address)" <ARGS_HERE>) \
 --verify --verifier blockscout --verifier-url https://sepolia.etherscan.io/api?

Blockscout explorers

Deploy and Verify

Base Sepolia

forge create --rpc-url base_sepolia --private-key $PRIVATE_KEY src/NFTCollectionFactory.sol:NFTCollectionFactory \
 --constructor-args $(cast abi-encode --packed "constructor(address)" <ARGS_HERE>) \
 --verify --verifier blockscout --verifier-url https://sepolia.etherscan.io/api?

Optimism Sepolia

forge create --rpc-url optimism_sepolia --private-key $PRIVATE_KEY src/NFTCollectionFactory.sol:NFTCollectionFactory \
 --constructor-args $(cast abi-encode --packed "constructor(address)" <ARGS_HERE>) \
 --verify --verifier blockscout --verifier-url https://optimism-sepolia.blockscout.com/api?

About


Languages

Language:Solidity 98.0%Language:Python 2.0%