Welcome to the series on Celo Spark! In this mini-series, we will explore The Graph and its usefulness in addressing common pain points. We will also have a coding session with a special guest to integrate it into our NFT project. In this first part, we will set up our project and deploy a smart contract using Celo Composer and Hardhat.
- Open your console and navigate to the desired directory.
- Use Celo Composer to create a new project by running the following command:
celocli node:composer create celo-subgraph-box
For a detailed walkthrough, refer to the Celo Composer video in this series.
- Open the project folder and install the dependencies by executing:
cd celo-subgraph-box npm install
- Remove the example smart contracts provided with the project.
- Install the OpenZeppelin library by running:
npm install @openzeppelin/contracts
- Create a new contract named
CeloBox. This contract will be an ERC721 token that extends
Ownable. The maximum supply of tokens is set to 15, and only the owner can mint them one by one.
- Set the base URI for the token metadata by specifying the IPFS URL.
- Prepare the deployment script by creating a new environment file (e.g.,
.env) and filling it with the required data.
- Update the deployment script to verify the network in which you will deploy the smart contract.
- Check the script defined in the
package.jsonfile that will be used for deployment.
- Deploy the smart contract on the Alfajores network by running the following command:
If your contract is not verified, you can use the following commands for verification:
npx hardhat verify 'address' 'args' --network alfajores
npx hardhat --network alfajores sourcify
- Use CeloScan to mint the first NFT directly.
- Verify that the NFT minting event has been emitted, as this will be used by the subgraph.
- Access Graph Studio and use the Valora app for connection.
- Scan the QR code and sign the transaction to establish the connection.
- Create a new subgraph by setting the name and the chain.
- Create the subgraph.
Congratulations! You have successfully set up your project, deployed a smart contract on the Alfajores network, and minted your first NFT. In the next part of this mini-series, we will dive into the coding session with our special guest. Stay tuned for more exciting content!