zytfo / solidity-learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

solidity-learning

Foundry (foundry-f23)

  1. forge init - create a new project
  2. forge compile - compile contract
  3. forge create SimpleStorage --rpc-url http://127.0.0.1:7545 --interactive - via Ganache
  4. anvil; forge create SimpleStorage --interactive - via Anvil (anvil in another tab)
  5. forge script script/DeploySimpleStorage.s.sol - run forge script on termoral anvil
  6. forge script script/DeploySimpleStorage.s.sol --rpc-url http://127.0.0.1:8545 --broadcast --private-key <private key from anvil> - run forge script on existing anvil (check broadcast folder)
  7. cast --to-base 0x714c2 dec - convert hex to dec
  8. source .env - load env vars into shell, to use as $PRIVATE_KEY
  9. cast send 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "store(uint256)" 123 --rpc-url $RPC_URL --private-key $PRIVATE_KEY - send method on deployed contract from terminal
  10. cast call 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 "retrieve()" - call method from terminal
  11. forge fmt - format all solidity code

foundry-fund-me-f23

[https://www.evm.codes/](EMV OP CODES GAS)

  1. forge init - init a new project
  2. forge test - run test
  3. forge install smartcontractkit/chainlink-brownie-contracts --no-commit - install chainlink libs
  4. Add into foundry.toml: remappings = ["@chainlink/contracts/=lib/chainlink-brownie-contracts/contracts/",]
  5. forge remappings > remappings.txt - add remappings for libs
  6. forge test -vv - run tests with console.log
  7. !!!forge test -vvv --fork-url $SEPOLIA_RPC_URL - run tests on forked sepolia
  8. forge coverage --fork-url $SEPOLIA_RPC_URL - show coverage on forked sepolia
  9. chisel - run solidity line-by-line executor
  10. forge snapshot - get gas spend for every function
  11. forge test --mt testWithdrawWithASingleFunder -vv - run a particular test
  12. forge inspect FundMe storageLayout - get storage layout
  13. forge install cyfrin/foundry-devops --no-commit - install devops
  14. cast sig "fund()" - find hex function selector
  15. cast --calldata-decode "fund()" 0xb60d4288 - decode hex data

About


Languages

Language:Solidity 97.0%Language:Makefile 3.0%