Skip to content

Latest commit

 

History

History
128 lines (102 loc) · 6.39 KB

get-a-transaction-receipt.md

File metadata and controls

128 lines (102 loc) · 6.39 KB

Get a transaction receipt

The transaction receipt gives you information about a transaction including whether or not the transaction reached consensus on the network. You request the receipt for every transaction type and there is currently no transaction fee associated with this network request.

{% hint style="info" %} Receipts can be requested from a Hedera network for up to 3 minutes. {% endhint %}

Transaction Receipt Contents

The transaction receipt returns the following information about a transaction:

  • Whether the transaction reached consensus or not (success or fail)
  • The newly generated account ID, topic ID, token ID, file ID, schedule ID, scheduled transaction ID or smart contract ID
  • The exchange rate
  • The topic running hash
  • The topic sequence number
  • The total supply of token
  • The serial numbers for of the newly created NFTs after a token mint transaction was executed

Transaction Signing Requirements

  • Transaction receipt requests do not have an associated fee at this time so there is no signature requirement
Constructor Description
new TransactionReceiptQuery() Initializes the TransactionReceiptQuery Object
  • Transaction ID: The ID of the transaction to return the receipt for
  • Include Duplicates: Whether or not to include the receipts for duplicate transactions
  • Include Children: Whether or not to include the receipt for children transactions triggered by a parent transaction
MethodTypeRequirement
setTransactionId(<transactionId>)TransactionIDRequired
setIncludeDuplicates(<value>)booleanOptional
setIncludeChildren(<value>)booleanOptional

{% tabs %} {% tab title="Java" %}

new TransactionReceiptQuery()
    .setTransactionId(transactionId)
    .execute(client)

{% endtab %}

{% tab title="JavaScript" %}

new TransactionReceiptQuery()
    .setTransactionId(transactionId)
    .execute(client)

{% endtab %}

{% tab title="Go" %}

hedera.NewTransactionReceiptQuery().
    SetTransactionId(transactionId).
    Execute(client)

{% endtab %} {% endtabs %}

Helper Methods

MethodTypeDescription
<TransactionResponse>.getReceipt(<client>)TransactionReceiptReturns the receipt of a transaction
<TransactionResponse>.getReceipt(<client, timeout>)Client, DurationRequest the receipt from the network for this duration
<TransactionResponse>.getReceiptQuery()TransactionReceiptQueryReturns the TransactionReceiptQuery response for a transaction. This will not error on bad status like RECEIPT_NOT_FOUND and will return information about a failed transaction if necessary.
<TransactionResponse>.getReceiptAsync(<client, timeout>)Client, DurationRequest receipt asynchronously for the provided duration
<TransactionReceipt>.statusStatusWhether the transaction reached consensus or not
<TransactionReceipt>.accountIdAccountIdThe newly generated account ID
<TransactionReceipt>.topicIdTopicIdThe newly generated topic ID
<TransactionReceipt>).fileIdFileIdThe newly generated file ID
<TransactionReceipt>).contractIdContractIdThe newly generated contract ID
<TransactionReceipt>).tokenIdTokenIdThe newly generated token ID
<TransactionReceipt>).scheduleIdScheduleIdThe newly generated schedule ID
<TransactionReceipt>).scheduledTransactionIdTransactionIdThe generated scheduled transaction ID
<TransactionReceipt>).exchangeRateExchangeRateThe exchange rate in hbar, cents, and expiration time
<TransactionReceipt>.topicRunningHashByteStringThe topic running hash
<TransactionReceipt>.topicSequenceNumberlongThe topic sequence number
<TransactionReceipt>.totalSupplylongThe total supply of a token
<TransactionReceipt>.serialsList<long>The list of newly created serial numbers upon execution of a token mint transaction.

{% tabs %} {% tab title="Java" %}

//Get the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);

System.out.println("The transaction receipt: " +receipt);

//v2.0.0

{% endtab %}

{% tab title="JavaScript" %}

//Get the receipt of the transaction
const receipt = await txResponse.getReceipt(client);

console.log("The transaction receipt: " +receipt);

//v2.0.0

{% endtab %}

{% tab title="Go" %}

//Request the receipt of the transaction
receipt, err := txResponse.GetReceipt(client)

if err != nil {
    panic(err)
}

fmt.Printf("The transaction receipt %v\n", receipt)

//v2.0.0

{% endtab %} {% endtabs %}

{% tabs %} {% tab title="Sample Output:" %}

TransactionReceipt{
     status=SUCCESS,
     exchangeRate=ExchangeRate{
          hbars=1,
          cents=12, 
          expirationTime=2100-01-01T00:00:00Z
     }, 
     accountId=null,
     fileId=null, 
     contractId=null, 
     topicId=null, 
     tokenId=null, 
     topicSequenceNumber=null, 
     topicRunningHash=null, 
     totalSupply=0, 
     scheduleId=0.0.2531
     schdeduledTransactionId=null,
     serials=[]
    }

{% endtab %} {% endtabs %}