Skip to content

Instantly share code, notes, and snippets.

@sterlu
Created March 4, 2024 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sterlu/901893ac0ca75e3aa0c12e436bcd2204 to your computer and use it in GitHub Desktop.
Save sterlu/901893ac0ca75e3aa0c12e436bcd2204 to your computer and use it in GitHub Desktop.
const rlp = require("rlp");
const web3Utils = require("web3-utils");
/**
* Calculates address of contract created by deployerAddr if CREATE is used (not CREATE2)
**/
const calcAddress = (deployerAddr, nonce) => {
const rlpEncoded = Buffer.from(rlp.encode([deployerAddr, nonce])).toString('hex');
const address = '0x' + web3Utils.sha3('0x' + rlpEncoded).substr(66 - 40);
return address;
}
// List first 300k DsProxy addresses (not all of them already exist)
const dsProxyFactoryAddr = '0xa26e15c895efc0616177b7c1e7270a4c7d51c997';
for (var i = 1; i <= 300_000; i++) {
// #1 is DsProxyCache, DsProxies start from #2
// #3953 is mislabeled on Etherscan causing misnumbered labels for all after it
console.log(`${i},\t${calcAddress(dsProxyFactoryAddr, i)}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment