3

I've been testing payments for shopping cart on a private chain. I create and deploy contracts to disburse payments among sellers. So if a shopper buys same items again the contracts for two carts become identical. What I've found is that addresses for identical contracts become identical. As far as I understand, contract's address should not depend upon contract's code. So my question is what am I missing? The geth version I am using is Geth/v1.8.19-stable-dae82f09/linux-amd64/go1.10.4. Here are receipts of two deployment transactions that deployed two contracts into the same address:

> eth.getTransactionReceipt('0xEB556C5C72EF32DA30D902E3740938990682356644A913CB746D562F867A5F0A') ;
{
  blockHash: "0xc10d1434e0ec4b8179c7f1c8d96a341be3f4feb89772dcba87a71b870c7201a1",
  blockNumber: 32159,
  contractAddress: "0x380cccc971cc411ebdf7fd288420310901fcdbe6",
  cumulativeGasUsed: 677993,
  from: "0x5151510a0b0a011bc31690f3a3597d59afdd911c",
  gasUsed: 677993,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x1",
  to: null,
  transactionHash: "0xeb556c5c72ef32da30d902e3740938990682356644a913cb746d562f867a5f0a",
  transactionIndex: 0
}
> eth.getTransactionReceipt('0x5BEC8AB685A585E2163AEAC60AD1ACCF0D7FC42D8AECBDBCA246CD477BF62EEC') ;
{
  blockHash: "0xa84390432bc702d92acca47389e1f2dabc7f7b5aba4cd37903c4f6bf85715fc6",
  blockNumber: 28628,
  contractAddress: "0x380cccc971cc411ebdf7fd288420310901fcdbe6",
  cumulativeGasUsed: 677993,
  from: "0x5151510a0b0a011bc31690f3a3597d59afdd911c",
  gasUsed: 677993,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x1",
  to: null,
  transactionHash: "0x5bec8ab685a585e2163aeac60ad1accf0d7fc42d8aecbdbca246cd477bf62eec",
  transactionIndex: 0
}

  • 1
    Did you close and reopen the network in between your attempts? If yes, then obviously you'd get the same address (most likely also when the byte code of the two contracts is not identical). It's not a public network, where things constantly change, people deploy other contracts or submit new transaction. So deterministic behavior is pretty expected. In your case, deploying a contract, then starting over and deploying another contract - you should expect that they will reside at the same address. – goodvibration Dec 8 '18 at 21:27
  • 4
    Ethereum contract address depends on the sender address and the nonce of that address. I would check the nonce to see if it is being incremented between creation of the contracts. – Shawn Tabrizi Dec 8 '18 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.