Initial call failure

Hello,
I want please to understand the lifecycle of the Contract Transaction
According to documentation-hub If the initial call fails (runs out of gas) the contract is not created. The owner loses the fee and the gas (to the miner) but the amount and the deposit are returned to the owner.

How can I indicate this scenario (the amount and the deposit are returned to the owner)?
Should the initial call failure be reflected on-chain?

Even if the the call to the init function fails for some reason (running out of gas, doing something that crashes, etc.) the contract_create transaction will be recorded on the chain. If it had not been recorded on-chain the fee and the gas would not be given to the miner. The result of the init function call is visible in the contract call state tree, where the call result is going to be error. (And, just as you write, another effect of the init call failing is that amount and deposit is not charged from the caller).

2 Likes

The result of the init function call is visible in the contract call state tree, where the call result is going to be error.

In my scenario I want to parse all aeternity transactions, block by block, from the Genesis block to the current one.
For example, the next transaction that I have to parse is a ContractCreateTx at block_height: 66877 , and the initial call of this contract is failed. (I can’t find a ContractCreateTx that failed so this one just for example)

How can I get the contract state tree of this contract to determine if the initial call is failed?

Here is the in-depth information for that transaction (it is not a ContractCreate, but a ContractCall - however the call_info is the same):

{"call_info":
  {"caller_id":"ak_mxCZ2rVRSjh6mXrey2vDujAvQiCkd51b5XdrrgrXWX4mQkzug",
   "caller_nonce":32,
   "contract_id":"ct_H9SVQ8btFSfPCM5rq5xXf2j5WxUh4DJ1zuvoshDhseEjhzUJP",
   "gas_price":1000000000,
   "gas_used":192,
   "height":66877,
   "log":[],
   "return_type":"ok",
   "return_value":"cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUTF3JV"}}

The return_type is ok if the init-call was successful, and error otherwise.

1 Like