Skip to content

mixbe/contract-tutorial

Repository files navigation

Creating a new Hardhat project

mkdir hardhat-tutorial
cd hardhat-tutorial
yarn init
yarn add --dev hardhat
npx hardhat

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts

run

npx hardhat compile

npx hardhat test
# or
 yarn hardhat test
# or test one of tests
yarn hardhat test test/Token.js

# default is hardhat network
yarn hardhat run scripts/deploy.js

# select other networks
yarn hardhat run scripts/deploy.js --network ganache
yarn hardhat run scripts/1.deploy_box.ts --network ganache

yarn hardhat test test/Token_v2.js test/xxxxx

Test

yarn hardhat  test ./test/xxxxx.test.ts --network hardhat

reference

  1. hardhat tutorial
  2. Web3 Tutorial: write upgradeable smart contract (proxy) using OpenZeppelin
  3. Writing Upgradeable Contracts

blog

contract

defi

  1. defi by example
  2. GitHub of defi by example
  3. Public Bug Report: Uniswap's SwapRouter doesn't refund unspent ETH in partial swaps

money-legos

  1. studydefi/money-legos

1 - Learn how to create Merkle Trees for large airdrops (1-2 hours) 2 - Learn how Ethereum nodes store data and executes smart contracts (1-2 hours) 3 - Borrow a loan worth millions in crypto without paying a single cent using Aave Flash Loans (2-4 hours) 4 - Learn about the Re-Entrancy attack - that cost $60 million (1-2 hours) 5 - Read private data from smart contracts (not really private after all) (1-2 hours) 6 - Learn about delegatecall attacks - where one contract can change data in another (2-3 hours) 7 - Why you should never generate random numbers on-chain without an oracle (1-2 hours) 8 - How to prevent users from accessing a smart contract (1-2 hours) 9 - Why not to use tx.origin to determine the sender of a transaction (1-2 hours) 10 - Detect legit-looking contracts which are actually malicious (1-2 hours) 11 - Build smart contracts that can be upgraded over time (2-3 hours) 12 - Optimize your smart contracts to build the cheapest transactions possible (30-60 minutes) 13 - Pay for someone else's transactions gas fee using meta transactions (1-2 hours) 14 - How can miners make the blockchain play in their favor through slight adjustments (1-2 hours) 15 - Bribe miners to have them play by your rules (1-2 hours)

About

smart contract tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published