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.
Field | Type | Description |
---|---|---|
cumulative_gas | string | The total gas consumed in this transaction |
epoch_num | string | The epoch number in which this transaction was confirmed |
success | boolean | The 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:
Field | Type | Description |
---|---|---|
accepted | boolean | Indicates whether the last transition in this transaction incurred a balance transfer |
event_logs | json-array | A list of event logs emitted by the contract during processing. Each log contains:
|
transitions | json-array | A list of internal transitions invoked during the processing of the transaction by the Scilla interpreter. Each transition contains:
|
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:
Field | Type | Description |
---|---|---|
errors | json-object | An 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. |
exceptions | json-array | A list of exceptions returned by the Scilla interpreter. Each exception contains:
|
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 $ZIL Deposit from Smart Contract Transactions
- Confirm that the success field is set to
true
. -
Traverse the transitions JSON array. For each transition, for a successful deposit of
$ZIL
via the smart contract, the following must be fulfilled:- _recipient corresponds to a known deposit address controlled by the exchange.
-
_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.
-
_amount is non-zero.
- 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
). - Continue traversing the remaining transitions and checking for more deposits.