eth-co2
eth-co2.js
is a JavaScript library to enable offsetting of CO2
emissions via the Ethereum blockchain. It is part of the CO2ken
project. More information is available in our
introductory blog
post. You
can also follow us on Twitter.
N.B. This library is currently pre-alpha, and currently only usable on the Rinkeby network! If you are interested in using it, please let us know.
Building
npm run build
Example usage
Calculating the cost of offsetting CO2 emissions
For example, to calculate the cost of offsetting a flight from London to New York:
;; ; const dapp = async { let provider = web3currentProvider; windowprice = await ; let flightEmissions = 500; // approx kg CO2 emissions from LON -> NYC flight let co2kenPrice = await ; // Cost in DAI to offset 1 ton of CO2 let offsetCost = flightEmissions / 1000 * co2kenPrice;}; ;
Check total supply of CO2kens
; let supply = await ;
Check total balance of payments to CO2ken contract
; let balance = await ;
Pay DAI to offset carbon emissions
; await ;
Obtain gas footprint
; let gasFootprint = await ; // CO2 emissions per gas
Estimate emissions from a transaction
let emissions = gasUsed * gasFootprint;let offsetCost = emissions * co2kenPrice;
Wrap it all up for convenience
; let emissions = await ;