A prediction market for carbon offsets powered by Chainlink oracles and Gnosis’ new Mercury v2 smart contracts and conditional market makers. Users take carbon offset positions based on CO2 emissions being offset by the planting and growth of trees.
The FCLA Carbon Offsets Prediction Market enables environmentally conscious users to leverage carbon offset data to bet for or against the continued growth of specific forests. Via Chainlink’s network of Oracle Node Operators, forestry data is brought on-chain in an appropriately distributed manner. Forestry data is sourced via a (Chainlink-enabled) integration with EcoTree (see https://EcoTree.fr), a French forestry company which tracks and sells plots of forest throughout France. The prediction market architecture is based on Gnosis’ new Mercury v2 smart contracts and conditional market makers. The UI was built using React and Web3 best practices, including no built configuration, Typescript, Drizzle, Redux, Rimble and proper components architecture.
The current PM is the total amount of euros of all attested trees on EcoTree.
Gnosis uses the EcoTree Chainlinked Contract: https://rinkeby.etherscan.io/address/0xCCccCb48132191636B95aBF45e32BaFbf5A77f5c
Gnosis uses this Division Contract where EcoTree / AMF attest to divisions: https://rinkeby.etherscan.io/address/0x76b8e6AcB389090f38d37A82d521d8ef0D6E2318
Oracle for Gnosis PM that imports form Chainlink contract: https://rinkeby.etherscan.io/address/0xB4baf3B840bdD05f0154558B980AF50a0daB78b0
NFT's of trees: https://rinkeby.etherscan.io/tx/0x2fe5494f19c22b59ee9a9b82a76ac5eb3e78e9afe79cfae86996fd67f7d4dd79
Trees on Opensea: https://rinkeby.opensea.io/accounts/0x6ea295f8f0ea207bd2e4d07f13e003701e152b16
Carbon offset
- Ensure that your MetaMask is connected to the Rinkeby testnet and that you have some Rinkeby test ETH (you can get more here: https://faucet.rinkeby.io/).
- You need some test DAI to create positions on the FCLA PM. You can mint some to your MetaMask account via our faucet. Navigate here, select the
mint
function, enter your MetaMask address and the amount of testnet DAI you would like (NOTE: this number is denoted in Wei, for example if you enter25000000000000000000
you will receive 25DAI on the testnet). - Navigate to the FCLA PM, after signing the MetaMask connection dialog, you can then trade on any of the avaliable markets using your testnet DAI.
- (Optional) If you would like to display your testnet DAI balance inside of your MetaMask currency list, open the MetaMask dialog, click the three horizontal bars in the upper left, and then click
Add Token
at the bottom of that dialog. Next, click theCustom Token
tab and enter the testnet DAI address (0xEFC8876B9F411F1e610668CE62992886A65c913d
) in theToken Contract Address
field,DAI
as theToken Symbol
, and18
in theDecimals of Precision
field. You will now see your testnet DAI balance in the list of tokens when you click the three horizontal bars on the upper left of the MetaMask dialog.
Although not necessary for most users, it is possible to refresh the Chainlinked data that is cached inside the FCLA smart contract (e.g. when the Chainlinked geospatial endpoints contain fresh information). To update the Chainlinked data, please follow these instructions:
- Obtain some Rinkeby LINK tokens from the Chainlink faucet here: https://rinkeby.chain.link/
- To display your LINK balance inside of your MetaMask currency list, open the MetaMask dialog, click the three horizontal bars in the upper left, and then click
Add Token
at the bottom of that dialog. Next, click theCustom Token
tab and enter the LINK token address (0x01be23585060835e02b77ef475b0cc51aa1e0709
) in theToken Contract Address
field,LINK
as theToken Symbol
, and18
in theDecimals of Precision
field. You will now see your Rinkeby LINK balance in the list of tokens when you click the three horizontal bars on the upper left of the MetaMask dialog. - Inside the MetaMask dialog, send some newly acquired LINK tokens to the Rinkeby FCLA Chainlink contract address:
0xd8E1E592f77969607c65DA1683769614ACf6b4fC
. NOTE: each forest update within the FCLA contract currently costs 5 LINK tokens, so to update all five forests costs:5 * 5 = 25 LINK Tokens
. - To refresh the cached data from Chainlink, call the
refreshForests
function from the FCLA Chainlink contract here. In the_jobId
field enter0xb0bde308282843d49a3a8d2dd2464af1
(the correctjobId
for RinkebyGET
requests, see here for more information). In the_numForests
field enter the number of forests you would like to refresh (in index order), currently the maximum supported by the contract is all five forests (to update all forests' data simply enter5
). - Submit the function call with a sufficent amount of gas (the current version may require as much as
7000000
gas). Once submitted it may take some time to process, monitor the transaction on Etherscan. - Once confirmed, the forest data inside the FCLA contract will be refreshed and this will be reflected in the PM dApp: http://pm.flyingcarpet.network/
- Run
yarn install
- In a separate terminal, run
ganache-cli -d
- Run
npm run migrate
- Start the dev server with
npm start
It will generate a build folder inside the root with the styles, JS assets and contracts.
Go to pm.flyingcarpet.network
LSMR Contract deployed on https://rinkeby.etherscan.io/address/0xaf89C9677c69e11c15aB2651885387dfD4B2778F
.env
and .env.production
can overwrite environnement variables such as networkID for deployment etc.
Contract address is saved into src/build/contracts/Migrations.json
:
"networks": {
"1565085406360": {
"events": {},
"links": {
"Fixed192x64Math": "0xB349FB172D6D5f693b0aA1C6eEc4c61cFd6846f4"
}
}
If not saved during build process. The LSMR address needs to be saved into src/config.json
. It changes everytime migration is run.
Run npm run build-css
generate CSS assets separately.
Run npm run build-js
to generate JS assets separately.
For operating the LMSR market maker
npx truffle exec scripts/operate_lmsr.js
For resolving the decentralized oracles
npx truffle exec scripts/resolve_decentralized_oracles.js
Run:
rm -rf src/build
npm stop
npm run compile
npm run migrate
npm start
If, after installing a new module, you see an error of the following form:
npm ERR! path /root_path/flyingcarpet/prediction-market/node_modules/web3-providers-ws/node_modules/websocket
npm ERR! code EISGIT
npm ERR! git /root_path/flyingcarpet/prediction-market/node_modules/web3-providers-ws/node_modules/websocket: Appears to be a git repo or submodule.
npm ERR! git /root_path/flyingcarpet/prediction-market/node_modules/web3-providers-ws/node_modules/websocket
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.
It means that one (or multiple) of the websocket
module dependencies has been corrupted. Run the following to delete all websocket module dependencies (including sub-dependencies):
find . -name websocket -exec rm -rf {} \;
Next, proceed with the installation of your module (e.g.: npm install additional-module --save
). Afterwards, run the above (deletion) command again. Finally, you'll need to run:
npm i
Now the module dependency structure should be fixed with the new module installed.