🟒
Filecoin Green Documentation
  • πŸ“—Filecoin Green Documentation
  • ♻️Storage Providers Green Guidance Documentation
    • 🌐Introduction
    • 🌍Filecoin Green
      • πŸ”±Filecoin Green Pledge
    • πŸ“‘Storage Provider’s Tiered Sustainability Claims
    • πŸ“‹Storage Providers Sustainability Criteria
      • GHG Emissions Accounting
        • How Storage Providers should Calculate Emissions
      • Renewable Energy Procurement
        • How Storage Providers should Procure Renewable Energy
          • Renewable Electricity Sourcing Methods
            • Spotlight: DCENT
          • Additional methods for procuring renewable energy
            • Spotlight: Zero Labs
          • Credible Claims Requirements
          • Energy Sources and Technologies
      • Additional Reporting Criteria and Reporting Cadence
        • Water Use
        • Hardware Waste
        • Reporting Periods and Cadence
    • πŸ”†Conclusion
    • πŸ—ƒοΈAdditional Resources
      • Annex 1: Carbon Accounting Methodologies Hierarchy
      • Annex 2: Details on Storage Provider’s Tiered Sustainability Claims
      • Annex 3: Filecoin Green Reporting Portal
      • Annex 4: Treatment of Carbon Credits
  • βš™οΈFilecoin Green API Docs
    • πŸ”§List of APIs
      • ⚑Energy Consumption API
      • 🌿Green Scores API
      • πŸ“ˆRenewable Energy Certificates API
      • ↔️Filecoin Miner ID <-> Peer ID relation API
  • πŸ–₯️Filecoin Green UI Tools
    • πŸ”CID.place
    • πŸ“ƒREC Browser
    • πŸ“ˆMetered Energy Consumption
    • πŸ“©CSV Export utility
    • πŸ‘ΎCO2.Storage
  • πŸ“šAdditional Resources
  • πŸ‘ΎCO2.Storage Docs
    • 🧐About
    • βš™οΈData Model
    • βš’οΈUI: Getting Started
    • πŸ—οΈSetting Up the CLI
    • ✍️Template Author's Guide
    • πŸ’₯Examples
    • 🌱Build a Web UI
    • πŸ–₯️UI Functionality
    • ⌨️API Functionality
    • πŸŽ†Configuring IPFS Nodes
    • ‼️FAQ
    • πŸ—ΊοΈDevelopment Roadmap
    • πŸ—»Decarbonize Your Travel
    • πŸ’‘Energy Validation Process (EVP) Schema
Powered by GitBook
On this page
  • Installing CO2.Storage
  • Set Up Environment Variables
  • Try Out Examples
  1. CO2.Storage Docs

Setting Up the CLI

PreviousUI: Getting StartedNextTemplate Author's Guide

Last updated 1 year ago

The steps below will walk you through installing the js implementation of CO2.Storage, setting up your environment variables, and testing everything. You'll then be able to use CO2.Storage to search, load, create and sign assets and templates in your javascript projects.

This assumes you have git and node-js installed. The tutorial was developed on macOS using the Terminal.

Installing CO2.Storage

1) Download the repo by running:

git clone https://github.com/protocol/co2-storage.git

2) Navigate to the cli folder:

cd co2-storage
cd cli

3) Install dependencies:

npm install

For reference, see the npm package

Set Up Environment Variables

4) In co2-storage/cli, you should find a file named .env.example. Copy it, and rename to .env

We're going to use the .env file to store private keys. If handled properly, this will not expose your keys. The .env file is included in , which will prevent it from being uploaded to git. If you want to check how the private keys are used, examine the function authenticateWithPK in . If this is unfamiliar to you, use test accounts.

5) You should have a file that looks like this image. We're going to fill in the private keys necessary to use co2.storage.

6) Get "PK" from Metamask. In the browser plugin, go to menu > Account details > Export Private Key. Metamask will ask you for your account password. Copy the Metamask private key into PK in the .env file.

If your private key doesn't start with '0x' then append this at the beginning. This was not required with previous package versions, but is now (Q3 2023).

7) Get ESTUARY_API_KEY and FG_TOKEN from co2.storage. Log in to co2.storage with the same Metamask account you just got PK from. Click on the green button in the upper right hand corner, which should be labeled with your walled address 0x...

This will take you to a page with two different tokens. Use "My API token" as FG_TOKEN and "My Estuary Key" as ESTUARY_API_KEY.

The Estuary key should start with "EST" and end with "ARY" because the Estuary engineering team is clever.

Go to Dashboard > API Keys. Click on the name of your account, which in the image below is CO2_storage_test. Copy the key to INFURA_API_KEY.

9) Check the keys in your .env file. All four should have different formats. If two of the keys look the same, you probably had a problem copy pasting. It happens. Save the file.

Try Out Examples

10) To run search_templates using the co2.storage ipfs node, first open search_templates.js in the examples folder. Comment out lines 5 and 6, which tell the script to use local addresses for the IPFS node and for the FG API. Then un-comment lines 7-8, which will tell the script to use the co2.storage node.

The lines should look like this:

// const ipfsNodeAddr = "/ip4/127.0.0.1/tcp/5001"
// const fgApiUrl = "http://localhost:3020"
const ipfsNodeAddr = "/dns4/web1.co2.storage/tcp/5002/https"
const fgApiUrl = "https://web1.co2.storage"

11) Going back to the command line, make sure you're in the folder co2-storage/cli. Then run:

npm run search_templates

Within a few seconds, this should give you a list of templates available on the 'sandbox' chain πŸŽ‰

12) To run other scripts in the examples folder, you'll have to configure each one to use the co2.storage IPFS node or use your own node. If you've done this and set up the .env file correctly, you should be able to run all of the scripts.

Scripts like add_asset and add_template require authentication, because co2-storage tracks who added what information using the index chain. Scripts that are read only, like search_templates and get_asset, do not require authentication so you should be able to use them without setting up the .env file as above.

8) Almost done! For the last key, you need an Infura account. Go to and log in or make a new account.

Test out some of the example scripts in to make sure that your environment is set up properly and see how to use the js api!

There are two ways of using the js-api: either with your own IPFS node, or with the IPFS node provided by co2.storage. In step 10, we assume you haven't set up your own IPFS node and tell the example scripts to use the co2.storage node. If you do want to run your own IPFS node, see .

πŸ‘Ύ
πŸ—οΈ
infura.io
co2-storage/cli/src/examples
Configuring IPFS Nodes
co2-storage/js-api
.gitignore
Auth.js