![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
ethereum-emissions-calculator
Advanced tools
Readme
Made with ♥ by Offsetra.com for carbon.fyi.
License: MIT.
Please cite Offsetra if you use this in your project, we really appreciate it! 🙏
Questions, comments, forks and PRs all very much appreciated!
JavaScript utility to calculate the CO2 emissions of any Ethereum address or contract.
The tool is written in TypeScript and powered by the the Etherscan.io API & an open-source carbon accounting methodology under development by Offsetra. We hope this tool is useful for raising awareness and understanding with regards to the rapidly growing carbon emissions of cryptocurrency mining.
This calculator should work in any client or server-side JavaScript environment.
npm install ethereum-emissions-calculator
The calculator exports two methods:
calculateAddressEmissions
calculateContractEmissions
calculateAddressEmissions
will only allocate emissions for outgoing (sent) transactions.
Provide an address
and a transactionType
, and the calculator will tell you how many emissions this represents in KG CO2e.
To calculate the sum total emissions for an address, you must combine the sum of eth
, erc20
, and erc721
emissions.
import { calculateAddressEmissions } from "ethereum-emissions-calculator";
import { address, etherscanAPIKey } from "data";
const emissions = await calculateAddressEmissions({
transactionType: "eth", // "eth" | "erc20" | "erc721"
address, // 0x12345[...]
etherscanAPIKey,
});
console.log(emissions);
// {
// transactionType: "eth",
// kgCO2: 12345,
// transactionsCount: 69,
// gasUsed: 420,
// }
The only difference between this method and calculateAddressEmissions
, is that this method will also calculate and add emissions from incoming transactions.
We have included this method at the request of platforms who are interested in calculating the collective impact of their contract, however for most cases we think calculateAddressEmissions
makes more sense (to avoid double-counting the same emissions-- sender takes responsibility!)
import { calculateContractEmissions } from "ethereum-emissions-calculator";
import { address, etherscanAPIKey } from "data";
const emissions = await calculateContractEmissions({
transactionType: "eth", // "eth" | "erc20" | "erc721"
address, // 0x12345[...]
etherscanAPIKey,
});
console.log(emissions);
// {
// transactionType: "eth",
// kgCO2: 12345,
// transactionsCount: 69,
// gasUsed: 420,
// }
The total emissions are derived from the amount of gas
used for each transaction.
See https://carbon.fyi/learn for a brief intro and link to more in-depth explainers.
We would like to integrate the actuall carbon accounting methodology and hash-rate calculations into this repository at some point in the near future. Let us know if you'd like to put in a PR to help us along!
FAQs
TypeScript utils to calculate the CO2 emissions of an Ethereum wallet. Powered by the Etherscan.io API.
The npm package ethereum-emissions-calculator receives a total of 29 weekly downloads. As such, ethereum-emissions-calculator popularity was classified as not popular.
We found that ethereum-emissions-calculator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.