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.
- 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
.
- Solidity (Writing Smart Contract)
- Hardhat (using the hardhat-toolbox plugin)
- React
- Ethers.js
- Install current LTS for Node (preferrably using NVM)
- Install Hardhat with hardhat-toolbox
- Optional: If using vscode install Solidity and Hardhat extensions
git clone this repo
mv .env.bak .env
# modify the .env file as needed
cd boilerplate-contract-deployer
npm install
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
- 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
- Update your private key
Change the
PRIVATE_KEY
in.env
to use one of the following private key wallets provided in the console above - Migrate Smart Contracts
npx hardhat run src/backend/scripts/deploy.js --network localhost
- 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.
- Launching Front End
npm run start
- 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.
- Migrate Smart Contracts
npx hardhat run src/backend/scripts/deploy.js --network sepolia
- Launching Front End
npm run start # Browser should automatically open otherwise visit localhost:3000
Run unit tests against hardhat:
npx hardhat test
# optinally this can be done in parallel
npx hardhat test --parallel
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
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.
MIT