Skip to content

Instantly share code, notes, and snippets.

@Rhynorater
Created October 11, 2021 06:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rhynorater/df20153bd9a5ec3b16b4ec5a7515e032 to your computer and use it in GitHub Desktop.
Save Rhynorater/df20153bd9a5ec3b16b4ec5a7515e032 to your computer and use it in GitHub Desktop.
Quick command-line script to predict the next contract address for an account based off its current nonce and address.
var web3 = require('web3');
var rlp = require('rlp');
var process = require( 'process' );
var nonce = parseInt(process.argv[3]);
var account = process.argv[2];
var d = web3.utils.sha3(rlp.encode([account, nonce]));
console.log("0x"+d.substring(d.length-40));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment