Skip to content

Latest commit

 

History

History
144 lines (116 loc) · 10.7 KB

get-a-transaction-record.md

File metadata and controls

144 lines (116 loc) · 10.7 KB

Get a transaction record

You can request a transaction record for up to 3 minutes after a transaction has reached consensus. This query returns a maximum of 180 records per request. The transaction record provides the following information about a transaction:

Transaction Record Contents

PropertyDescription
Transaction IDThe ID of the transaction.
Consensus timestampThe time the transaction reached consensus and was added to the ledger.
Contract Call ResultRecord of the value returned by the smart contract function (if it completed and didn't fail) from ContractCallTransaction.
Contract Create ResultRecord of the value returned by the smart contract constructor (if it completed and didn't fail) from ContractCreateTransaction.
ReceiptThe receipt of the transaction.
Transaction FeeThe transaction fee that was charged.
Transaction HashThe transaction hash.
Transaction MemoThe transaction memo if there was one added.
TransfersA list of transfers made in the transaction. The list of transfers includes a payment made to the node, the service fee, and transaction fee.
Token TransfersA list of the token transfers .
ScheduleRefThe schedule ID of the schedule transaction the record represents.
Assessed Custom FeesThis field applies to tokens that have custom fees and returns the custom fee(s) assessed in a token transfer transaction. This includes the amount, token ID, fee collector account ID (if applicable), and effective payer account ID. The effective payer accounts are accounts that were charged the custom fees.
Automatic AssociationsThe token(s) that were auto associated to the account in this transaction, if any
AliasIn the record of an internal AccountCreateTransaction triggered by a user transaction with a (previously unused) alias, the new account's alias.
Parent Consensus TimestampThe parent consensus timestamp is found in the record of a child transaction. The parent consensus timestamp is the consensus timestamp related to the parent transaction to this child transaction.
Ethereum HashThe keccak256 hash of the ethereumData. This field will only be populated for EthereumTransaction.
Paid Staking RewardsList of accounts with the corresponding staking rewards paid as a result of a transaction. See HIP-406.
Network: previewnet/testnet
PRNG BytesIn the record of a PRNG transaction with no output range, a pseudorandom 384-bit string. See HIP-351.
Network: previewnet
PRNG NumberIn the record of a PRNG transaction with an output range, the output of a PRNG whose input was a 384-bit string. See HIP-351.
Network: previewnet
Pending AirdropThe pending airdrops are a result of the transaction.
Include ChildrenWhether or not to include the record for children transactions triggered by a parent transaction.
Include DuplicatesWhether or not to include the receipts for duplicate transactions.
Reject AirdropTransfer one or more tokens or token balances held by the requesting account to the treasury for each token type.

Transaction Signing Requirements

  • The client operator account private key is required to sign
Constructor Description
new TransactionRecordQuery() Initializes the TransactionRecordQuery Object
MethodTypeRequirement
setTransactionId(<transactionId>)TransactionIdRequired
setIncludeChildren(<value>)booleanOptional
setIncludeDuplicates(<value>)booleanOptional

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

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

{% endtab %}

{% tab title="JavaScript" %}

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

{% endtab %}

{% tab title="Go" %}

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

{% endtab %} {% endtabs %}

Methods

MethodTypeRequirement
<TransactionResponse>.getRecord(<client>)TransactionRecordRequired
<TransactionRecord>.transactionIdTransactionIdOptional
<TransactionRecord>.consensusTimestampInstantOptional
<TransactionRecord>.contractFunctionResultContractFunctionResultOptional
<TransactionRecord>.receiptTransactionReceiptOptional
<TransactionRecord>.transactionFeeHbarOptional
<TransactionRecord>.transactionHashByteStringOptional
<TransactionRecord>.transactionMemoStringOptional
<TransactionRecord>.transfersList<Transfer>Optional
<TransactionRecord>.tokentransfersMap<TokenId, Map<AccountId, List<Long>>>Optional
<TransactionRecord>.scheduleRefScheduleIdOptional
<TransactionRecord>.assessedCustomFeesList<AssessedCustomFees>Optional
<TransactionRecord>.automaticTokenAssociationsList<TokenAssociation>Optional
<TransactionRecord>.ethereumHashByteStringOptional
<TransactionRecord>.parentConsensusTimestampInstantOptional
<TransactionRecord>.paidStakingRewardsList<Transfer>Optional
<TransactionRecord>.prngBytesByteStringOptional
<TransactionRecord>.prngNumberIntegerOptional

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

//Create a transaction
AccountCreateTransaction transaction = new AccountCreateTransaction()
        .setKey(newKey.getPublicKey())
        .setInitialBalance(new Hbar(1));

//Sign with the client operator account key and submit to a Hedera network
TransactionResponse txResponse = transaction.execute(client);

//Request the record of the transaction
TransactionRecord record = txResponse.getRecord(client);

System.out.println("The transaction record is " +record);

//v2.0.0

{% endtab %}

{% tab title="JavaScript" %}

//Create a transaction
const transaction = new AccountCreateTransaction()
        .setKey(newKey.getPublicKey())
        .setInitialBalance(new Hbar(1));

//Sign with the client operator account key and submit to a Hedera network
const txResponse = await transaction.execute(client);

//Request the record of the transaction
const record = await txResponse.getRecord(client);

console.log("The transaction record is " +record);

//v2.0.0

{% endtab %}

{% tab title="Go" %}

//Create a transaction
transaction := hedera.NewAccountCreateTransaction().
		SetKey(privateKey.PublicKey()).
		SetInitialBalance(hedera.NewHbar(1000))

//Sign with the client operator account key and submit to a Hedera network
txResponse, err := transaction.Execute(client)

//Request the record of the transaction
record, err := txResponse.GetRecord(client)

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

//v2.0.0

{% endtab %} {% endtabs %}

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

TransactionRecord{
     receipt=TransactionReceipt{
          status=SUCCESS, 
          exchangeRate=ExchangeRate{
               hbars=30000, cents=116646, 
               expirationTime=2020-09-04T03:00:007
          }, 
         accountId=0.0.97001, 
         fileId=null, 
         contractId=null, 
         topicId=null, 
         topicSequenceNumber=null
    },                  
    transactionHash=e005670a1f49c4fd776b2d432db3e5cb31441 bb5a35bff412ec3b41cb1 3366ce00b5c1b9900aad1467f9709a649ccc20, 
     consensusTimestamp=2020-11-05T08:34:31.107311002Z,
     transactionId=0.0.9401@160456525 8.479476328,
     transactionMemo=, 
     transactionFee=0.25401241 ℏ, 
     contractFunctionResult=null, 
     transfers=[
          Transfer{accountId=0.0.5, amount=0.01501152 ℏ}, (node fee)
          Transfer{accountId=0.0.98, amount=0.23900089 ℏ}, (service fee)
          Transfer{accountId=0.0.9401, amount=-1.25401241 ℏ}, (transaction fee) initial balance of new account
          Transfer{accountId=0.0.97001, amount=1 ℏ} (Initial balance of the new account)
     ]
     tokenTransfers={},
     scheduleRef=null,
     assessedCustomFees=[],
     automaticTokenAssociations=[TokenAssociation{
          tokenId=0.0.27335, accountId=0.0.27333}]
}

{% endtab %} {% endtabs %}