[Ethereum] Transaction receipt has contractAddress as null

go-ethereumreceiptssoliditystructtransactions

I see that my transaction is mined. I am trying to store some data into a struct. The mining is successful, however, in the transaction receipt i see that the contract address is null. Is that an error?
Also, when i try to get the data from the struct again, i dont get any data.

transaction receipt : 
{
  blockHash: "0x6835e94160e4db15196bae0718fcec9ea5e3ae94aa83fa9a837d49b736155276",
  blockNumber: 1135,
  contractAddress: null,
  cumulativeGasUsed: 52773,
  from: "0x627263e6a7e435feb257f9f17032026635b6bb4e",
  gasUsed: 52773,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: "0x19a02c583d8855081cb16f2a3e5bded4b896f8c2db1e58aacb75738401f5cf9c",
  to: "0x031bad0e974ee22016e4578ceec980c35fa19e1e",
  transactionHash: "0x6420fba51c596055d917c8f7abb67164435c675b212188dd41efd9c8f334a9c7",
  transactionIndex: 0
}


transaction receipt : 
{
  blockHash: "0x6835e94160e4db15196bae0718fcec9ea5e3ae94aa83fa9a837d49b736155276",
  blockNumber: 1135,
  from: "0x627263e6a7e435feb257f9f17032026635b6bb4e",
  gas: 90000,
  gasPrice: 20000000000,
  hash: "0x6420fba51c596055d917c8f7abb67164435c675b212188dd41efd9c8f334a9c7",
  input: "0x136bbb5b000000000000000000000000e52743fbbc67a95283c7c1fed1764275e484a9f900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000647616e657368000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044d616c6500000000000000000000000000000000000000000000000000000000",
  nonce: 24,
  r: "0x1b5086663b5f034731625e1b3894834bdef2e8fe1d4bef8fc674d601b55fa200",
  s: "0x1b667db9dcc05a253d1b80812e85c8c07bab44226235f23f186b294c7161ace",
  to: "0x031bad0e974ee22016e4578ceec980c35fa19e1e",
  transactionIndex: 0,
  v: "0x2a",
  value: 0

}

However, i am not getting the data i stored in the struct back.
I am unable to understand what is going wrong.

Best Answer

A contract is created (also called deployed) by sending the contract's byte code to Ethereum address 0x0 (that is, the to field will be 0x0).

If the contract creation succeeds, then (and only then) will there be a value in the contractAddress field of the transaction's receipt. That value will the the address of the newly created contract. Subsequent calls to that contract's address will always have 'null' in the contractAddress field of a receipt.

In other words, the contractAddress field could have been called newlyCreateContractAddress. Read more here: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt

Related Topic