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:

git clone https://github.com/<YOUR_GITHUB_USERNAME>/fre-tokens-quickstart

Open in Code Editor

cd fre-tokens-quickstart
cursor .

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.

cp sample.env .env
.env
ETH_RPC_URL=
PRIV_KEY=
TOKEN_ADMIN=
ETHERSCAN_API_KEY=

Next, make your environment variables available to the command line for running the scripts to deploy your token contract.

source .env

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).

forge script script/QuickstartERC721.s.sol:DeployQuickstartERC721 --rpc-url $ETH_RPC_URL --private-key $PRIV_KEY --broadcast --verify

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:

example output
[] Compiling...
[] Compiling 11 files with Solc 0.8.27
[] Solc 0.8.27 finished in 1.64s
Compiler run successful!
Script ran successfully.

== Logs ==
  QuickstartERC721 deployed at: 0x_YOUR_CONTRACT_ADDRESS

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.

cast send 0x_YOUR_CONTRACT_ADDRESS "adminMint(address,uint256)" $TOKEN_ADMIN 10000000000000000000000 --private-key $PRIV_KEY --rpc-url $ETH_RPC_URL

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:

cast call 0x_YOUR_CONTRACT_ADDRESS "balanceOf(address)(uint256)" $TOKEN_ADMIN --rpc-url $ETH_RPC_URL

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!