π»Decarbonize Your Travel
Create, mint, and deploy an NFT to decarbonize your travel using Co2.storage, the FVM Hyperspace Testnet & Remix:
Overview
Create your Decarbonized Travel Asset using form.co2.storage.
Connect to the Filecoin Hyperspace testnet & get some TFIL from the faucet
Create & customize a DecarbonizedTravelNFT Contract in Solidity using Open Zeppelin Contracts Wizard
Deploy the DecarbonizedTravelNFT Contract to the Filecoin Virtual Machine (FVM) Hyperspace Testnet with Remix
Interact with the DecarbonizedTravelNFT Contract & mint your NFT using the asset created on co2.storage.
Create your Decarbonized Travel Asset using form.co2.storage
For this tutorial, we'll be creating an NFT that represents your travel decarbonized on the Filecoin Network.
Fill out the first three fields of the decarbonization form.
Attendee Name is your name
Emissions Description is a short summary of the travel you are decarbonizing, including your name, the event, and the mode of travel
Emissions Amount kg is the amount of CO2 emitted by your travel. For flights, use the ICAO Calculator.
We will retire an offset for you on the Regen Network and add its transaction hash in the sheet. If you want to look it up, use the explorer at https://www.mintscan.io/regen/txs/<TxHash> (example)
Complete the decarbonized travel form to generate an asset on Co2.storage attesting that your travel was decarbonized. In the provenance section, enter your name and choose CC-O.
Note the CID (Content Identifier) that is returned. We'll need this CID later when we mint the NFT.
Connect to the Filecoin Hyperspace testnet & get some TFIL from the faucet
We need to point your wallet to the Filecoin Network, specifically the Hyperspace testnet. Weβll use a website called chainlist.org to give MetaMask the information it needs quickly.
Connect to the Filecoin Hyperspace testnet
Go to chainlist.org & enable the Testnets toggle and enter Filecoin into the search bar.
Scroll down to find the Filecoin β Hyperspace testnet & connect your wallet to the testnet.
Connect network through Metamask & approve when prompted:
In MetaMask click Next:
Get some TFIL from the faucet:
Test-filecoin (TFIL) is FIL that has no value in the real world, and developers use it for testing. Weβll grab some TFIL now.
Go to hyperspace.yoga and click Faucet from the menu:
Create a DecarbonizedTravelNFT Contract in Solidity
The DecarbonizedTravelNFT Smart Contract is based on Open Zeppelin's implementation of ERC721 but uses the ERC721URIStorage version, which includes the metadata standard extensions (so we can pass in our IPFS-addressed metadata - which we've saved on CO2.Storage, to the contract).
We'll be using the Open Zeppelin Contracts Wizard to create our DecarbonizedTravelNFT Contract. Follow along below ππΌ.
Using Open Zeppelin Contracts Wizard:
Head to the Open Zeppelin wizard and select the option for ERC721 as seen below.
Provide this URL as the base URI for the contract: https://ipfs.io/ipfs/QmWAtvTBkUKeifvUSu6XA2uFDUQBgmL3U1pTnbgqrHhton?filename=decarbonized%20travel%20photo.png
The DecarbonizedTravelNFT Contract:
Deploy the DecarbonizedTravelNFT Contract to the Filecoin Virtual Machine (FVM) Hyperspace Testnet
Requirements
We'll be deploying this contract to the Filecoin Virtual Machine Hyperspace Testnet. To deploy to Hyperspace Testnet we'll need to have:
Set up & connected Metamask Wallet to Hyperspace Testnet
Received some test tFIL funds from a faucet (Yoga or Zondax)
Create your workspace
The development environment weβre going to be using is called Remix. Letβs create a new workspace to create our ERC-721 Decarbonized Travel NFT.
Open remix.ethereum.org & click the + icon next to Workspaces to create a new workspace:
Customize the Decarbonized NFT contract
In the editor panel, replace MyToken with whatever youβd like to name your NFT Contract. In this example, weβll use DecarbonizedTravelNFT.
Compile the Decarbonized NFT contract
Click the green play symbol at the top of the workspace to compile your contract. You can also press CMD + s on MacOS or CTRL + s on Linux and Windows.
Deploy the Decarbonized NFT contract
Now that weβve successfully compiled our contract, we need to deploy it to the Filecoin Hyperspace testnet! This is where our previous MetaMask setup comes into play.
Click the Deploy tab from the left.
Interact with the DecarbonizedTravelNFT Contract & mint your NFT
Now that weβve compiled and deployed the contract, itβs time to actually interact with it! Weβre going to call a method within the deployed contract to mint an NFT.
Mint your DecarbonizedTravelNFT
Back in Remix, open the Deployed Contracts dropdown, within the Deploy sidebar tab.
Add to Metamask & import your NFT:
Currently, MetaMask has no idea what our NFT is or what it even does. We can fix this by explicitly telling MetaMask the address of our contract.
Go back to Remix and open the Deploy sidebar tab. Under Deployed Contracts, you should see your contract address at the top. Click the copy icon to copy the address to your clipboard:
β¨ You should now be able to see that you have 1 Decarbonized Travel NFT within your wallet! β¨
Last updated