binodnp / erc20-snapshot Goto Github PK
View Code? Open in Web Editor NEWCreates a snapshot of any ERC20 token in JSON or CSV format
Home Page: http://linkedin.com/in/binodnirvan/
Creates a snapshot of any ERC20 token in JSON or CSV format
Home Page: http://linkedin.com/in/binodnirvan/
After I run "erc20-snapshot", I got this error blow.
/opt/homebrew/lib/node_modules/erc20-snapshot/node_modules/web3-eth-contract/lib/index.js:50
throw new Error('Please use the "new" keyword to instantiate a web3.eth.Contract() object!');
^
Error: Please use the "new" keyword to instantiate a web3.eth.Contract() object!
at Eth.Contract (/opt/homebrew/lib/node_modules/erc20-snapshot/node_modules/web3-eth-contract/lib/index.js:50:15)
at Eth.Contract (/opt/homebrew/lib/node_modules/erc20-snapshot/node_modules/web3-eth/lib/index.js:289:22)
at module.exports.getContract (/opt/homebrew/lib/node_modules/erc20-snapshot/contract.js:12:29)
at Object. (/opt/homebrew/lib/node_modules/erc20-snapshot/events/blockchain.js:8:41)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/opt/homebrew/lib/node_modules/erc20-snapshot/index.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/erc20-snapshot/balances.js b/node_modules/erc20-snapshot/balances.js
index e781348..7fd62d7 100644
--- a/node_modules/erc20-snapshot/balances.js
+++ b/node_modules/erc20-snapshot/balances.js
@@ -10,6 +10,7 @@ module.exports.createBalances = async data => {
const wallet = event.to;
let deposits = (balances.get(wallet) || {}).deposits || new BigNumber(0);
+
let withdrawals = (balances.get(wallet) || {}).withdrawals || new BigNumber(0);
if (event.value) {
@@ -35,6 +36,7 @@ module.exports.createBalances = async data => {
setWithdrawals(event);
}
+
for (const [key, value] of balances.entries()) {
if (key === "0x0000000000000000000000000000000000000000") {
continue;
@@ -44,7 +46,7 @@ module.exports.createBalances = async data => {
closingBalances.push({
wallet: key,
- balance: balance.div(10 ** parseInt(data.decimals)).toFixed(data.decimals)
+ balance: balance.div(10 ** parseInt(data.decimals)).toFixed(18)
});
}
diff --git a/node_modules/erc20-snapshot/contract.js b/node_modules/erc20-snapshot/contract.js
index abea66b..bf47db2 100644
--- a/node_modules/erc20-snapshot/contract.js
+++ b/node_modules/erc20-snapshot/contract.js
@@ -9,6 +9,6 @@ const web3 = new Web3(new Web3.providers.HttpProvider((Config || {}).provider ||
const contractAddress = (Config || {}).contractAddress;
module.exports.getContract = () => {
- const contract = web3.eth.Contract(Parameters.abi, contractAddress);
+ const contract = new web3.eth.Contract(Parameters.abi, contractAddress);
return contract;
};
diff --git a/node_modules/erc20-snapshot/events/block-by-block.js b/node_modules/erc20-snapshot/events/block-by-block.js
index 25100d7..352cb53 100644
--- a/node_modules/erc20-snapshot/events/block-by-block.js
+++ b/node_modules/erc20-snapshot/events/block-by-block.js
@@ -11,6 +11,7 @@ const range = (start, end) => {
module.exports.tryBlockByBlock = async (contract, start, end, symbol) => {
const blocks = range(start, end);
+ console.log('blocks: ', blocks);
let counter = 0;
for await (const i of blocks) {
diff --git a/node_modules/erc20-snapshot/events/block-reader.js b/node_modules/erc20-snapshot/events/block-reader.js
index cccc91b..b4daaaa 100644
--- a/node_modules/erc20-snapshot/events/block-reader.js
+++ b/node_modules/erc20-snapshot/events/block-reader.js
@@ -16,7 +16,7 @@ const getMinimal = pastEvents => {
transactionHash: tx.transactionHash,
from: tx.returnValues["0"],
to: tx.returnValues["1"],
- value: tx.returnValues["2"]._hex
+ value: tx.returnValues["2"]
};
});
};
diff --git a/node_modules/erc20-snapshot/events/blockchain.js b/node_modules/erc20-snapshot/events/blockchain.js
index 3756939..c0ad4c4 100644
--- a/node_modules/erc20-snapshot/events/blockchain.js
+++ b/node_modules/erc20-snapshot/events/blockchain.js
@@ -61,7 +61,7 @@ module.exports.get = async () => {
var fromBlock = parseInt(Config.fromBlock) || 0;
const blocksPerBatch = parseInt(Config.blocksPerBatch) || 0;
const delay = parseInt(Config.delay) || 0;
- const toBlock = blockHeight;
+ const toBlock = parseInt(Config.toBlock) || blockHeight;
const lastDownloadedBlock = await LastDownloadedBlock.get(symbol);
diff --git a/node_modules/erc20-snapshot/index.js b/node_modules/erc20-snapshot/index.js
index bce42cf..107fac5 100755
--- a/node_modules/erc20-snapshot/index.js
+++ b/node_modules/erc20-snapshot/index.js
@@ -10,6 +10,7 @@ const start = async () => {
await Config.checkConfig();
const format = Config.getConfig().format;
const result = await Events.get();
console.log("Calculating balances of %s (%s)", result.name, result.symbol);
const balances = await Balances.createBalances(result);
This issue body was partially generated by patch-package.
Spent couple of hours fixing a lot of bugs successfully, updated many things to be able to fetch data at all just to see that the transactions are calculated WRONG.
Just a warning for everyone coming by.
Improve it.
I was trying to use the erc20-snapshot GitHub repository and ran into some issues. I suspect this is due to broken dependencies.
Note: I have a config.json in my directory from where I ran the erc20-snapshot command.
The current error I get is this:
Configuration file was not found.
Configuration file was not found.
web3-shh package will be deprecated in version 1.3.5 and will no longer be supported.
web3-bzz package will be deprecated in version 1.3.5 and will no longer be supported.
/usr/local/lib/node_modules/erc20-snapshot/node_modules/web3-eth-contract/lib/index.js:51
throw new Error('Please use the "new" keyword to instantiate a web3.eth.Contract() object!');
^
Error: Please use the "new" keyword to instantiate a web3.eth.Contract() object!
at Eth.Contract (/usr/local/lib/node_modules/erc20-snapshot/node_modules/web3-eth-contract/lib/index.js:51:15)
at Eth.Contract (/usr/local/lib/node_modules/erc20-snapshot/node_modules/web3-eth/lib/index.js:257:22)
at Object.module.exports.getContract (/usr/local/lib/node_modules/erc20-snapshot/contract.js:12:29)
at Object. (/usr/local/lib/node_modules/erc20-snapshot/events/blockchain.js:8:41)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/usr/local/lib/node_modules/erc20-snapshot/index.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.