@Test public void testCreateContractAddress() { String address = "0x19e03255f667bdfd50a32722df860b1eeaf4d635"; assertThat(generateContractAddress(address, BigInteger.valueOf(209)), is("0xe41e694d8fa4337b7bffc7483d3609ae1ea068d5")); assertThat(generateContractAddress(address, BigInteger.valueOf(257)), is("0x59c21d36fbe415218e834683cb6616f2bc971ca9")); }
public static byte[] generateContractAddress(byte[] address, BigInteger nonce) { List<RlpType> values = new ArrayList<>(); values.add(RlpString.create(address)); values.add(RlpString.create(nonce)); RlpList rlpList = new RlpList(values); byte[] encoded = RlpEncoder.encode(rlpList); byte[] hashed = Hash.sha3(encoded); return Arrays.copyOfRange(hashed, 12, hashed.length); }
ContractUtils { public static byte[] generateContractAddress(byte[] address, BigInteger nonce) { List<RlpType> values = new ArrayList<>(); values.add(RlpString.create(address)); values.add(RlpString.create(nonce)); RlpList rlpList = new RlpList(values); byte[] encoded = RlpEncoder.encode(rlpList); byte[] hashed = Hash.sha3(encoded); return Arrays.copyOfRange(hashed, 12, hashed.length); } }
ContractUtils { public static byte[] generateContractAddress(byte[] address, BigInteger nonce) { List<RlpType> values = new ArrayList<>(); values.add(RlpString.create(address)); values.add(RlpString.create(nonce)); RlpList rlpList = new RlpList(values); byte[] encoded = RlpEncoder.encode(rlpList); byte[] hashed = Hash.sha3(encoded); return Arrays.copyOfRange(hashed, 12, hashed.length); }  }
ContractUtils { public static byte[] generateContractAddress(byte[] address, BigInteger nonce) { List<RlpType> values = new ArrayList<>(); values.add(RlpString.create(address)); values.add(RlpString.create(nonce)); RlpList rlpList = new RlpList(values); byte[] encoded = RlpEncoder.encode(rlpList); byte[] hashed = Hash.sha3(encoded); return Arrays.copyOfRange(hashed, 12, hashed.length); }  static byte[] generateContractAddress(byte[] address, BigInteger nonce); static String generateContractAddress(String address, BigInteger nonce); }
ContractUtils { public static byte[] generateContractAddress(byte[] address, BigInteger nonce) { List<RlpType> values = new ArrayList<>(); values.add(RlpString.create(address)); values.add(RlpString.create(nonce)); RlpList rlpList = new RlpList(values); byte[] encoded = RlpEncoder.encode(rlpList); byte[] hashed = Hash.sha3(encoded); return Arrays.copyOfRange(hashed, 12, hashed.length); }  static byte[] generateContractAddress(byte[] address, BigInteger nonce); static String generateContractAddress(String address, BigInteger nonce);  }