Mission 3

Establish a Lunar Economy with $MOON Token

Mission Incomplete

Smart Contract

In this part of the mission you will be creating a token on the Base network and then indexing the data into The Graph. This mission will be a little more complex than the previous ones, but don't worry, we will walk you through it step by step.

1Environment Setup

Before you begin, make sure you are in the proper branch.

Clone the repository:

git clone https://github.com/kmjones1979/graphbuilders-basecamp mission-3-moon

Navigate into the project directory:

cd mission-3-moon

Checkout the branch:

git checkout mission-3-moon

Install the dependencies:

yarn install

Start your local blockchain:

yarn chain

Deploy your contract (in a new terminal):

yarn deploy

Start your frontend (in a new terminal):

yarn start

Now that our environment is setup, let's begin the mission.

2Starting Contract Code

The starting smart contract code for this mission is as follows:


contract Moon is Ownable{

    address public burner = 0x0000000000000000000000000000000000000000;

    constructor() Ownable(burner) {}

    receive() external payable {}
}

Next, we will be updating the smart contract to inherit the ERC-20 standard. The ERC-20 standard is the most popular standard for creating a token on Ethereum. It defines a set of functions that a token contract must implement.

1Add the ERC-20 Standard to the Moon Contract

To complete this task, follow these steps:

  • Import the ERC-20 contract from OpenZeppelin
  • Inherit the ERC-20 contract from OpenZeppelin
  • Initialize the ERC-20 contract with the name and symbol
  • Mint the initial supply to your wallet

Deploy your changes:

yarn deploy --reset

✅ Success will look like this:

deployed at 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 with 747494 gas

You can then navigate to the "Debug Contracts" tab in Scaffold-ETH and perform some transactions with your token. You should test the approve function as well as the transfer function.

Now that your contract is deployed, let's create an extended subgraph.

Need Help?

Join our Telegram support channel: