ethereum-emissions-calculator
Advanced tools
Comparing version 1.8.2-8 to 2.0.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
21877
0
1
80
79