Commit cf401213145158aadf470ff99c38962a1d0e7d12
Utils: include deployed contract address calculation
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: 04af14cd7056250c22a08f3950f10cfa2dcbb8c8
Files changed
utils.js | changed |
utils.js | ||
---|---|---|
@@ -1,7 +1,14 @@ | ||
1 | +const ethUtils = require('ethereumjs-util') | |
2 | +const Address = require('./address.js') | |
3 | + | |
1 | 4 | var Utils = {} |
2 | 5 | |
3 | 6 | Utils.isWASMCode = function (code) { |
4 | 7 | return code.slice(0, 4).toString() === new Uint8Array([0, 0x61, 0x73, 0x6d]).toString() |
5 | 8 | } |
6 | 9 | |
10 | +Utils.newAccountAddress = function (sender, data) { | |
11 | + return new Address('0x' + ethUtils.sha3(Buffer.concat([ sender.toBuffer(), Buffer.from(data) ])).slice(0, 20).toString('hex')) | |
12 | +} | |
13 | + | |
7 | 14 | module.exports = Utils |
Built with git-ssb-web