Understanding Transaction Receipts


Transaction Receipts

Confirmed transactions come with a receipt under the result field when fetching the transaction in JSON format.

Basic Fields

The following are the fields a receipt may have. These fields generally apply to both payment and contract transactions.

FieldTypeDescription
cumulative_gasstringThe total gas consumed in this transaction
epoch_numstringThe epoch number in which this transaction was confirmed
successbooleanThe result of this transaction (true on success)

For example:

"receipt": {
"cumulative_gas": "10481",
"epoch_num": "586524",
"success": true
},

Additional Fields

For smart contract transactions, additional information relating to smart contract execution is contained in additional fields under the "receipt".

Successful Transactions

If a transaction is successful (i.e., the success field is true), these fields will be present:

FieldTypeDescription
acceptedbooleanIndicates whether the last transition in this transaction incurred a balance transfer
event_logsjson-arrayA list of event logs emitted by the contract during processing. Each log contains:
  1. _eventname: [string] The name of the event
  2. address: [string] The address of the contract that emitted this event
  3. params: [json-array] A list of parameters under the transition. Each entry contains:
    • vname: [string] The name of the variable
    • type: [string] The type of the variable
    • value: [string] The value of the variable
transitionsjson-arrayA list of internal transitions invoked during the processing of the transaction by the Scilla interpreter. Each transition contains:
  1. addr: [string] The address of the contract account that emitted this transition
  2. depth: [int] The depth of the current transition. The transitions directly emitted by the recipient in the transaction will be in depth 0. If those transitions in depth 0 invoked transitions from other contracts, those will be in depth 1. And so on and so forth.
  3. msg: [json-object] The message field emitted by the Scilla interpreter, which includes:
    • _amount: [string] The balance transferred from this transition
    • _recipient: [string] The recipient of this transition, which can either be a wallet account or contract account
    • _tag: [string] The contract-defined transition name
    • params: [json-array] A list of parameters under the transition. Each entry contains:
      • vname: [string] The name of the variable
      • type: [string] The type of the variable
      • value: [string] The value of the variable

For example:

"receipt": {
"accepted": true,
"cumulative_gas": "878",
"epoch_num": "589742",
"event_logs":[
{
"_eventname":"RecordsSet",
"address":"0x708bfbba57436ed45efc13df9fab4249a354e06b",
"params":[
{
"type":"ByStr20",
"value":"0x9611c53be6d1b32058b2747bdececed7e1216793",
"vname":"registry"
},
{
"type":"ByStr32",
"value":"0x2bb13c9b0a5dd28d42b470e2073df14608a9056310988b84b24dc342211e0627",
"vname":"node"
}
]
},
],
"success": true,
"transitions": [
{
"addr": "0x9a65df55b2668a0f9f5f749267cb351a37e1f3d9",
"depth": 0,
"msg": {
"_amount": "50000000000000",
"_recipient": "0xc0e28525e9d329156e16603b9c1b6e4a9c7ed813",
"_tag": "onFundsReceived",
"params": [
"vname": "emp_addr",
"type": "ByStr20",
"Value": "0x00345678901234567890123456789012345678ab"
]
}
}
]
}

Unsuccessful Transactions

If a transaction is unsuccessful (i.e., the success field is false), no balance transfer will be executed. Additionally, these fields will be present:

FieldTypeDescription
errorsjson-objectAn object containing a key-value field. The key [string] indicates the depth at which the error occurred. The value part is a JSON array that lists the error codes [int] reported. The list of possible error codes can be found here.
exceptionsjson-arrayA list of exceptions returned by the Scilla interpreter. Each exception contains:
  1. line”: [int] The line in the Scilla contract code where the exception was detected
  2. message: [string] The message describing the exception

For example:

"receipt": {
"cumulative_gas": "1220",
"epoch_num": "588004",
"errors": {
"0": [
7
]
},
"exceptions": [
{
"line": 87,
"message": "Exception thrown: (Message [(_exception : (String \"Error\")) ; (code : (Int32 -2))])"
},
{
"line": 100,
"message": "Raised from IsAdmin"
},
{
"line": 137,
"message": "Raised from ConfigureUsers"
}
],
"success": false
}

Recommended Steps for Exchanges Polling for Incoming Deposit from Smart Contract Transactions

  1. Confirm that the success field is set to true.
  2. Traverse the transitions JSON array. For each transition, for a successful deposit of $ZIL via the smart contract, the following must be fulfilled:
    1. _recipient corresponds to a known deposit address controlled by the exchange.
    2. _tag is either AddFunds or empty.
      note

      _tag can be found under msg field. If either _tag or msg is not present, there is no incoming deposit from this particular transition.

    3. _amount is non-zero.
    4. Check the _recipient and _amount to complete the information on the balance transfer.
      In such a case, you can confirm that there is a deposit to address **_recipient** with value **_amount** (in `Qa`).
    5. Continue traversing the remaining transitions and checking for more deposits.