Initialization

This page will walk you through setting up your first ERC404 token project.

Setup The .env File

In order to protect sensitive data, we use a .env file to store things like private keys, API keys and the base token URI.

You will see a .env.example file in the projects root directory, you can rename this file to simply .env, or create a new file called .env and copy the contents of the example file.

Enter your details into the correct fields, for instance your Alchemy API key and Etherscan API Key. Along with the private key of your deployer wallet.

Once the .env file is correctly filled out yu can proceed to compilation and deployment.

Update Your Contract Details

Navigate to your contracts folder and open the unfound.sol contract.

ERC404-V1/contracts/unfound.sol

This is a basic implementation to get started and can be expanded upon with new desired functionality.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "./ERC404.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

contract Unfound is ERC404 {
    using Strings for uint256;

    string public dataURI;

    // Change token parameters to your desired output
    // Token Name (Demo)
    // Token Ticker (DEMO)
    // Token Decimal (18)
    // Total Supply to Mint (8)
    
    constructor(address _owner) ERC404("Demo", "DEMO", 18, 8, _owner) {
        balanceOf[_owner] = 8 * 10 ** 18;
    }

    function setDataURI(string memory _dataURI) public onlyOwner {
        dataURI = _dataURI; 
    }

    function setNameSymbol(string memory _name, string memory _symbol) public onlyOwner {
        _setNameSymbol(_name, _symbol);
    }

    function tokenURI(uint256 id) public view override returns (string memory) {
        return string(abi.encodePacked(dataURI, Strings.toString(id), ".json"));
    }

}

Once you have set your desired token settings, save the file and move on to compilation.

Compiling

We have setup Hardhat Tasks to help with the deployment and execution of the contract. The first step is to compile your contract.

The contract should compile with no errors, if for some reason you have compilation errors, double check your token parameters for syntax errors or missing characters.

Deploy Contract to Sepolia Network

If you choose to deploy to a different network than Sepolia, change the --network flag to desired network. If all worked as expected you will see the newly created contract address in the terminal. Now your ready to start executing your new contract.

Last updated