Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereum-emissions-calculator

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-emissions-calculator - npm Package Compare versions

Comparing version 1.8.2-8 to 2.0.0

2

package.json
{
"name": "ethereum-emissions-calculator",
"version": "1.8.2-8",
"version": "2.0.0",
"description": "TypeScript utils to calculate the CO2 emissions of an Ethereum wallet. Powered by the Etherscan.io API.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

# Ethereum Carbon Emissions Calculator
Made with ♥ by [Offsetra.com](https://offsetra.com/about) for [carbon.fyi](https://carbon.fyi).
Questions, comments, forks and PRs all very much appreciated!
License: MIT.
License: **NON-COMMERCIAL USE ONLY**. Creative Commons BY-NC-SA.
To request a commercial-use license contact support@offsetra.com.
Please cite Offsetra if you use this in your project, we really appreciate it! 🙏
Questions, comments, forks and PRs all very much appreciated!
## Summary

@@ -48,9 +46,19 @@

console.log(emissions);
// {
// transactionType: "eth",
// kgCO2: 12345,
// transactionsCount: 69,
// gasUsed: 420,
// }
// returns:
export interface AddressEmissionsResult {
/** The transaction type which was queried. */
transactionType: CalculatorOptions["transactionType"];
/** The total carbon footprint for all transactions of the provided type, sent from the provided address. In Kilograms of CO2e */
kgCO2: number;
/** The total number of transactions included for this query. */
transactionsCount: number;
/** Total sum of Gas Used for all transactions */
gasUsed: number;
/** False means the 10k limit was hit, so only the most recent 10k transactions were analyzed. */
done: boolean;
/** The block number of the most recent transaction found in the query */
highestBlockNumber: number;
/** The block number of the oldest transaction found in the query */
lowestBlockNumber: number;
}
```

@@ -63,21 +71,7 @@

```typescript
import { calculateContractEmissions } from "ethereum-emissions-calculator";
import { address, etherscanAPIKey } from "data";
## Caveats & Breaking Changes
const emissions = await calculateContractEmissions({
transactionType: "eth", // "eth" | "erc20" | "erc721"
address, // 0x12345[...]
etherscanAPIKey,
});
As of version 2.0 and greater, each invocation of `calculateAddressEmissions()` or `calculateAddressEmissions()` will return a **maximum of 10k transactions**.
Before version 2.0, the calculator attempted to recursively fetch the remaining transactions until the entire history had been retrieved. This caused problems with huge addresses or lower-memory devices. It is now up to the developer to re-fetch the remaining transactions (the calculator now returns the `highestBlockNumber` and `lowestBlockNumber` to help you find the next chunk).
console.log(emissions);
// {
// transactionType: "eth",
// kgCO2: 12345,
// transactionsCount: 69,
// gasUsed: 420,
// }
```
## Methodology

@@ -87,3 +81,1 @@

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!

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc