Skip to content

advra/boilerplate-contract-deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boilerplate Contract Deloyer

By Abstract Core Systems

This is a boilerplate ethereum smart contract deployer. The project is structured with a front end and backend. It provides the base template to deploy to ethereum localhost or ethereum testnet on sepolia via Infura. Special credits to Space Riders NFT which the example contract Abstract Space Riders NFT is based off of.

TODO

  • contract deployement
  • full test coverage
  • deployment scripts
  • logging
  • working react front end (almost complete)

Note: The AbstractSpaceRider example contract is deployed to sepolia at 0xb8090eebe1fe886d8543dc933d6069ef717fa4b0.

I. Technology Stack & Tools

II. Requirements For Initial Setup

  • Install current LTS for Node (preferrably using NVM)
  • Install Hardhat with hardhat-toolbox
  • Optional: If using vscode install Solidity and Hardhat extensions

III. Setting Up

1. Clone/Download the Repository

git clone this repo
mv .env.bak  .env 
# modify the .env file as needed

2. Install Dependencies:

cd boilerplate-contract-deployer
npm install

3. Deploying

3a. Localhost Network

Note: Everytime local hardhat node is deployed you need to re-deploy the contract (make sure you delete the folder located in src/frontend/contractsData

  1. Startup local node blockchain
    cd boilerplate-contract-deployer
    rm -rf /src/frontend/contractsData/*.json
    # Make sure you run this at the root of the project otherwise the private key from .env may not load properly!
    npx hardhat node
  2. Update your private key Change the PRIVATE_KEY in .env to use one of the following private key wallets provided in the console above
  3. Migrate Smart Contracts
    npx hardhat run src/backend/scripts/deploy.js --network localhost
  4. Connect development blockchain accounts to Metamask
    • Copy private key of the addresses and import to Metamask
    • Connect your metamask to hardhat blockchain, network 127.0.0.1:8545.
    • If you have not added hardhat to the list of networks on your metamask, open up a browser, click the fox icon, then click the top center dropdown button that lists all the available networks then click add networks. A form should pop up. For the "Network Name" field enter "Hardhat". For the "New RPC URL" field enter "http://127.0.0.1:8545". For the chain ID enter "31337". Then click save.
  5. Launching Front End
    npm run start

3b. Sepolia Test Net

  1. Update your private key
    • Copy private key of the addresses and import to Metamask
    • Connect your metamask to hardhat blockchain, network 127.0.0.1:8545.
    • If you have not added hardhat to the list of networks on your metamask, open up a browser, click the fox icon, then click the top center dropdown button that lists all the available networks then click add networks. A form should pop up. For the "Network Name" field enter "Hardhat". For the "New RPC URL" field enter "http://127.0.0.1:8545". For the chain ID enter "31337". Then click save.
  2. Migrate Smart Contracts
    npx hardhat run src/backend/scripts/deploy.js --network sepolia
  3. Launching Front End
    npm run start
    # Browser should automatically open otherwise visit localhost:3000

IV. Other Useful Commands

1. Running Unit Tests

Run unit tests against hardhat:

npx hardhat test 
# optinally this can be done in parallel
npx hardhat test --parallel

2. Etherscan Verficiation:

When deploying on chain you can optionally verify your contract using hardhat's etherscan verify plugin. Make sure you set your ETHERSCAN_API_KEY in the .env file (you can obtain an etherscan apikey by creating an account on etherscan).

Note: Make sure you use constructor arguments that match your contracts constructor in both the .sol and in deploy.js

npx hardhat verify <YOUR_DEPLOYED_CONTRACT_ADDRESS> <OPTIONAL_CONSTRUCTOR_ARGS> --network sepolia
## Example Without consturctor args
## npx hardhat verify 0xb8090EeBe1fE886D8543dc933D6069ef717FA4B0 --network sepolia
## Example with constructor args
## npx hardhat verify --contract src/backend/contracts/AbstractSRNFT.sol:AbstractSRNFT 0xb8090EeBe1fE886D8543dc933D6069ef717FA4B0 0x07814fD88beA3167474A1761b8A923cb782B3715 --network sepolia

V. Other Notes:

If you get error rpc-internal on metamask or node an error that shows nonce too high you need to go to metamask and "Clear Recent Activities" to reset the nonce for that account.

License

MIT