Clone the repository and install dependencies.
Important: use npm version 16!
npm install
Create the .env
file based on .env.example
file.
cp .env.example .env
Edit the .env
file. It's necessary to get the wallet's private key. The wallet must have CELO to deploy the contracts.
# CELO
ALFAJORES_ADDRESS_PK=
CELO_ADDRESS_PK=
First, deploy the contracts.
npx hardhat --network alfajores deploy
And verify them in blockchain explorer.
npx hardhat --network alfajores sourcify
First, deploy the contracts.
npx hardhat --network celo deploy
And verify them in blockchain explorer.
npx hardhat --network celo sourcify
It's necessary, after deployment, to set on the ERC721 contract the Sweepstake contract address.
Edit the scripts/configure-contract.js
to check if the tokenURI
suffix, default is ipfs://
(line 17).
npx hardhat --network (alfajores|celo) run script/configure-contracts.js
Web3 uses the ABI file to interact with the contract. First, compile the contracts on the local network.
npx hardhat compile
It's necessary to use only two ABI files: artifacts/contracts/EsolidarSweepstake.sol/EsolidarSweepstake.json
and artifacts/contracts/ERC721EsolidarSweepstake.sol/ERC721EsolidarSweepstake.json
. Edit these two files and copy only the ABI object:
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
etc...
]
Paste on the Next.js ABI file inside src/ABI
folder.
To run the test script:
npx hardhat test test/esolidar-sweepstake.test.js