This is a starter kit for interacting with Flare blockchain. It provides example code for interacting with enshrined Flare protocol, and useful deployed contracts. It also demonstrates, how the official Flare smart contract periphery package can be used in your projects.
If you are new to Hardhat please check the Hardhat getting started doc
-
Clone and install dependencies:
git clone https://github.com/flare-foundation/flare-hardhat-starter.git cd flare-hardhat-starter
and then run:
yarnor
npm install --force -
Set up
.envfilecp .env.example .env -
Change the
PRIVATE_KEYin the.envfile to yours -
Compile the project
yarn hardhat compileor
npx hardhat compileThis will compile all
.solfiles in your/contractsfolder. It will also generate artifacts that will be needed for testing. ContractsImports.solimport MockContracts and Flare related mocks, thus enabling mocking of the contracts from typescript. -
Run Tests
yarn hardhat testor
npx hardhat test -
Deploy
Check the
hardhat.config.tsfile, where you define which networks you want to interact with. Flare mainnet & test network details are already added in that file.Make sure that you have added API Keys in the
.envfilenpx hardhat run scripts/tryDeployment.ts
├── contracts: Solidity smart contracts
├── scripts: Typescript scripts that interact with the blockchain
├── test
├── hardhat.config.ts
├── package.json
├── README.md
├── tsconfig.json
└── yarn.lock
Before opening a pull request, lint and format the code. You can do that by running the following commands.
yarn format:fixyarn lint:fixIf you want to start building your projects from a repository that is already setup to work with Flare correctly, but you do not want to keep any of the examples, these are the files you should delete:
- all files in the
contracts/folder - all files in the
scripts/folder, except for thescripts/fdcExample/Base.tswhich might come in useful
A shell command that does this is:
rm -rf contracts/* & mv scripts/fdcExample/Base.ts ./Base.ts & rm -rf scripts/* & mv ./Base.ts scripts/Base.ts