Transaction Module
Transaction module handles blockchain transaction operations and queries.
To learn more about how to use the AI Agent SDK to interact with the transaction module, please visit AI Agent SDK Transaction Queries.
3.1 Get Transaction By Hash
Fetches a transaction by hash.
Function Name
get_transaction_by_hashArguments
hash (str): The hash of the transaction.Example Code
from crypto_com_developer_platform_client import Transaction tx = Transaction.get_transaction_by_hash('example-hash') print(tx)
Returns
The transaction details.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'transaction': {'_type': 'TransactionResponse', 'accessList': example-list, 'blockNumber': example-block-number, 'blockHash': 'example-hash', 'blobVersionedHashes': example-hashes, 'chainId': 'example-chain0id', 'data': 'example-data', 'from': 'example-from', 'gasLimit': 'example-gas-limit', 'gasPrice': 'example-gas-price', 'hash': 'example-hash', 'maxFeePerGas': 'example-fee', 'maxPriorityFeePerGas': 'example-fee', 'maxFeePerBlobGas': example-fee, 'nonce': example-nonce, 'signature': {'_type': 'signature', 'networkV': 'example-V', 'r': 'example-r', 's': 'example-s', 'v': example-v}, 'to': 'example-to', 'index': example-index, 'type': example-type, 'value': 'example-value'}}}
Function Name
getTransactionByHashArguments
{string} txHash: Transaction hash.Example Code
import { Transaction } from '@crypto.com/developer-platform-client'; const tx = await Transaction.getTransactionByHash('example-hash'); console.log(tx);
Returns
{Promise<ApiResponse<TransactionByHash>>}: A promise that resolves to the transaction resultExample Return
{ status: 'Success', data: { transaction: { _type: 'TransactionResponse', accessList: example-list, blockNumber: example-block-number, blockHash: 'example-hash', blobVersionedHashes: example-hashes, chainId: 'example-chain-id', data: 'example-data', from: 'example-from', gasLimit: 'example-gas-limit', gasPrice: 'example-gas-price', hash: 'example-hash', maxFeePerGas: 'example-fee', maxPriorityFeePerGas: 'example-fee', maxFeePerBlobGas: example-fee, nonce: example-nonce, signature: [example-singature], to: 'example-to', index: example-index, type: example-type, value: 'example-value' } } }
3.2 Get Transaction Status
Fetches transaction status by hash.
Function Name
get_transaction_statusArguments
hash (str): The hash of the transaction.Example Code
from crypto_com_developer_platform_client import Transaction status = Transaction.get_transaction_status('example-hash') print(status)
Returns
The transaction status.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'status': 1}}
Function Name
getTransactionStatusArguments
{string} txHash: Transaction hash.Example Code
import { Transaction } from '@crypto.com/developer-platform-client'; const status = await Transaction.getTransactionStatus('example-hash'); console.log(status);
Returns
Promise<ApiResponse<TransactionStatus>>}: A promise that resolves to the transaction status.Example Return
{ status: 'Success', data: { status: 1 } }
3.3 Get Transaction Count
Fetches transaction count for a wallet.
Function Name
get_transaction_countArguments
wallet_address (str): The address to get the transaction count for.Example Code
from crypto_com_developer_platform_client import Transaction count = Transaction.get_transaction_count('example-wallet') print(count)
Returns
The transaction count for the wallet address.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'count': example-count}}
Function Name
getTransactionCountArguments
{string} walletAddress: Wallet address.Example Code
import { Transaction } from '@crypto.com/developer-platform-client'; const count = await Transaction.getTransactionCount('example-address'); console.log(count);
Returns
{Promise<ApiResponse<TransactionCount>>}: A promise that resolves to the transaction count.Example Return
{ status: 'Success', data: { count: example-number } }
3.4 Get Gas Price
Fetches current gas price.
Function Name
get_gas_priceExample Code
from crypto_com_developer_platform_client import Transaction price = Transaction.get_gas_price() print(price)
Returns
The current gas price.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'gasPrice': 'example-gas-price'}}
Function Name
getGasPriceExample Code
import { Transaction } from '@crypto.com/developer-platform-client'; const gasPrice = await Transaction.getGasPrice(); console.log(gasPrice);
Returns
{Promise<ApiResponse<GasPrice>>}: A promise that resolves to the gas price.Example Return
{ status: 'Success', data: { gasPrice: 'example-gas-price' } }
3.5 Get Fee Data
Fetches current fee data.
Function Name
get_fee_dataExample Code
from crypto_com_developer_platform_client import Transaction data = Transaction.get_fee_data() print(data)
Returns
The current fee data.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'feeData': {'_type': 'FeeData', 'gasPrice': 'example-gas-price', 'maxFeePerGas': 'example-fee', 'maxPriorityFeePerGas': 'example-fee'}}}
Function Name
getFeeDataExample Code
import { Transaction } from '@crypto.com/developer-platform-client'; const feeData = await Transaction.getFeeData(); console.log(feeData);
Returns
{Promise<ApiResponse<FeeData>>}: A promise that resolves to the fee data.Example Return
{ status: 'Success', data: { feeData: { _type: 'FeeData', gasPrice: 'example-gas-price', maxFeePerGas: 'example-fee', maxPriorityFeePerGas: 'example-fee' } } }
3.6 Estimate Gas
Estimates gas for a transaction.
Function Name
estimate_gasArguments
payload (dict): The payload for gas estimation, including fields like `from`, `to`, `value`, `gasLimit`, `gasPrice`, `data`.Example Code
from crypto_com_developer_platform_client import Transaction gas = Transaction.estimate_gas({'from': 'example-from', 'to': 'example-to', 'value': 'example-value', 'gasLimit': 'example-gas-limit', 'gasPrice': 'example-gas-price', 'data': 'example-data'}) print(gas)
Returns
The estimated gas information.Errors
ValueError: If the Transaction class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': {'gasLimit': 'example-gas-limit'}}
Function Name
estimateGasArguments
{object} payload: Transaction payload (from, to, value, gasLimit, gasPrice, data).Example Code
import { Transaction } from '@crypto.com/developer-platform-client'; const estimation = await Transaction.estimateGas({from: 'example-from', to: 'example-to', value: 'example-value', gasLimit: 'example-gas-limit', gasPrice: 'example-gas-price', data: 'example-data'}); console.log(estimation);
Returns
{Promise<ApiResponse<EstimateGasData>>}: A promise that resolves to the estimate gas data.Example Return
{ status: 'Success', data: { gasLimit: 'example-gas-limit' } }
Last updated
Was this helpful?