๐Ÿ“”Deploying Contracts

Deploying Contracts using Hardhat

You can deploy your contracts in 3Base using hardhat.

What is Hardhat?

Hardhat is a development environment for Ethereum. It helps developer manage and automate building smart contracts. It consists of different components for editing, compiling, debugging and deploying your smart contracts and dApps, all of which work together to create a complete development environment.

Creating a Hardhat Project

  1. Create a directory for you project

//make adirectory and go inside it 
mkdir 3Base_Project && cd 3Base_Project
  1. Initialize the project with hardhat

npx hardhat init 
  1. Choose the Configuration of your hardhat project, a sample typescript project(recommended)

Creating Your Smart Contract

  1. Add your contracts to the contracts folder or

  2. Create a contracts directory, if there is none

  1. Create your contract in the contracts directory

Creating Your Configuration File

  1. Create a secrets.json file to store your private key

  1. Add your private key to secrets.json

  1. Add secrets.json to .gitignore, to avoid pushing your private key to github

  2. Modify the hardhat.config.ts file as below

Deploying Your Smart Contract

  1. Compile your contract

  1. Create a scripts directory and create your deployment scripts

  1. Create a deployment script, like the one below

  1. Deploy your_contract.sol using the command below

Last updated

Was this helpful?