Skip to content

glonlas/hardhat-base-template

 
 

Repository files navigation

Hardhat Base Solidity framework template

A BoilerPlate Template Project To start building on Base With Solidity, Hardhat, and Typescript. All you have to do is create a new repository from the template and start coding your smart contracts.

Table of content

Hardhat Configuration

  • Typechain plugin enabled (typescript type bindings for smart contracts)
  • hardhat-deploy plugin enabled
  • Testing environment configured and operational, with test coverage
  • Prettier and eslint configured for project files and solidity smart contract
  • Solhint configured for enforcing best practices
  • Github actions workflows prepared for CI/CD
  • Prepared Smart Contract Examples, Tests, Deployments and Tasks for Common ERC Standards (ERC20, ERC721, ERC1155)

Check the Hardhat documentation for more information.

https://hardhat.org/getting-started/

Supported Networks

Ethereum

  • Ethereum Mainnet
  • Ethereum Sepolia Testnet

Base

  • Base Mainnet
  • Base Sepolia Testnet

Polygon

  • Polygon Mainnet
  • Polygon Mumbai Testnet

Local development

  • Hardhat Network (localhost)

Feel free to add more networks in hardhat.config.ts file.

1. Getting started

1.1. Install Dependencies

npm install

2. Environment Setup

Copy .env.example to .env and edit it. Make sure you include either MNEMONIC or PRIVATE_KEY in your .env file.

3. Create and compile your Contracts

Add your contract in the folder /contracts (see the demo example), and your tests in /test.

Then compile your Solidity contract to verify you have no error.

npm run compile

4. Deploy and Verify your smart contract

4.1. Deploy contract

To deploy on Base Sepolia Testnet

npx hardhat run scripts/deploy.ts --network base-sepolia

To deploy on Base Mainnet

npx hardhat run scripts/deploy.ts --network base-mainnet

4.2. Verify the contract on Mainnet

To Verify your contract on Base Sepolia Testnet

npx hardhat verify --network base-sepolia <contract address>

To Verify your contract on Base Mainnet

npx hardhat verify --network base-mainnet <contract address>

5. Utils

This framework comes with few utility scripts to help you to test your solution.

5.1 Airdrop your token

The scripts/airdrop.ts allows you to enter a list of recipients and the amount of token for each of them.

To airdrop on Base Sepolia

npx hardhat run scripts/airdrop.ts --network base-sepolia

To airdrop on Base Sepolia

npx hardhat run scripts/airdrop.ts --network base-mainnet

6. Blocked with your code?

We have tailored a ChatGPT only for Base: "Build on Base Assistant".
This GPT is made to know Base tokens and contract addresses, as well to help you in all steps of your development.

Appendix

Appendix 1: Project Structure

.
├── contracts
│   └── DemoERC20Token.sol
├── deployments
├── hardhat.config.ts
├── scripts
│   ├── airdrop.ts
│   └── deploy.ts
├── tasks
│   └── utils
│       ├── account.ts
│       ├── balance.ts
│       ├── block-numbers.ts
│       └── send-eth.ts
└── test
    └── DemoERC20Token.ts

Appedix 2: Testing

Run Tests

npm run test

Run Coverage

npm run coverage

Appendix 3: Project Hygiene

Prettier - Non Solidity Files

npm run format:check
npm run format:write

Lint - Non Solidity Files

npm run lint:check
npm run lint:fix

Prettier - Solidity

npm run sol:format:check
npm run sol:format:write

Solhint - Enforcing styles and security best practices

npm run solhint

Credits

All credit for this framework goes to:

About

Hardhat (typescript) template for Base blockchain deployment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.6%
  • Solidity 4.4%