This repository contains a proposal on how to implement Renewable Energy Certificates (RECs) along with a marketplace to sell them.
⚠️ As Hyperspace does not support cross-contract calling today, we use a fusion of both Marketplace and REC contracts to ensure all tokens functionalities.
The RECs contract had a set of features that were define with the Filecoin Green team. The specification are:
-
The RECs should be a fungible token (FT) supply attached to a non-fungible token (NFT) to set metadata for the whole supply. A concept closely relating to semi-fungible tokens.
-
Whe minting RECs, it has to be possible to allocate part of it directly to a Storage Provider (SP).
-
The RECs FTs should be transferable by anyone, effectively making them available on the free market
Note: As the redemption should only be done by SPs in the same geographical region as the seller, any interface implementing the marketplace should ensure that the SPs can filter RECs based on geographical location and time frame.
-
The FTs should be redeemable by their owners, effectively committing on the usage of the renewable energy.
-
Some roles should be implemented to restrict operations:
- Minter: List of accounts allowed to mint tokens.
- Redeemer: List of accounts allowed to redeem RECs.
-
Once all the FTs are redeemed the minter has to be allowed to set a new metadata for the NFT.
The marketplace to be implemented allows owner of RECs to list the FTs for a given price.
Note: This contract is only for PoC usage. It only covers a happy path and does not handle cancellation of a listing for example.
We created a few hardhat tasks to interact with the Hyperspace network, the test network of the Filecoin ecosystem.
Install the dependencies with:
yarn install
Create a .env.local
file and set the PRIVATE_KEY
variable to a valid ethereum private key.
The list of available tasks are:
get-address
: Gets Filecoin f4 address and corresponding Ethereum addressset-role
: Mints and allocates RECsmint-allocate
: Mints and allocates RECsredeem
: Redeem owned supply of RECs tokenget-balance
: Calls the REC Contract to read the amount of RECs owned by the account.list-recs
: List RECs on a Marketplace contractbuy-recs
: Buy listed RECs on a Marketplace contractget-listed-recs
: Listed RECs on a Marketplace contract
For more information run:
yarn hardhat --help
yarn hardhat deploy
yarn hardhat test --network hardhat
To create this project we were inspired by the FEVM Hardhat Kit and Zondax filecoin-solidity repository.