Deploy ERC-721 Token
How to deploy an ERC-721 NFT contract that hooks into the Forte Rules Engine
Introduction
In this guide, you will learn how to deploy an ERC-721 token contract that hooks into the Forte Rules Engine. The approach will leverage Open Zeppelin’s version 4.9.6 contracts package. This guide will deploy to the Base Sepolia testnet, which requires you to have some testnet ETH available.
Get Started
If you’ve already completed the ERC-20 Token Quickstart, you can skip the next steps and jump to the Deploy ERC-721 Token Contract section.
Create a copy of this template repository in your own github account by navigating here: https://github.com/thrackle-io/fre-tokens-quickstart and clicking the “Use this template” button on GitHub.
Next, clone the freshly created repository to your local machine:
Open in Code Editor
Setting up the .env
File
The project includes a sample.env
to get you started. Copy that to a new file named .env
and fill in the values.
Next, make your environment variables available to the command line for running the scripts to deploy your token contract.
Deploy ERC-721 Token Contract
An example ERC-721 contract named QuickstartERC721.sol
is available in the /src
directory. You can open it up to take a closer look and even apply customizations to meet your needs. Once you’re ready to deploy the contract you can do so with the following command (run from the same terminal window you sourced the .env file within).
This will deploy the contract to the Base Sepolia testnet and publish the source code for it to https://sepolia.basescan.org. The terminal where you run the above command will include output similar to the following:
Notice the highlighted line that indicates the deployed contract address. You can search that on the testnet explorer and even interact with it via the contract tab.
Test the Mint Function
There are two mint functions on this token contract. The first named adminMint
is only callable by the TOKEN_ADMIN
you previously set in the environment file. Test out calling this function and minting yourself some test tokens.
There is a second public mint
function that is callable by anyone, but does require paying. The default price in the contract is 0.0001
ETH. You can also try this function out by calling it from account different than the token admin.
Check Balance
You’ll see some output in the terminal indicating the status of the contract call. When successful you can refresh the transactions tab on the testnet explorer to see your transaction indexed there as well.
Check the balance of your wallet to ensure those tokens were minted:
Next Steps
Now that you have a rules ready ERC-721 token deployed it’s time to deploy the client specific contracts that connect this token to the Forte Rules Engine!