Token Transaction API
The Transaction API provides access to transaction data on the blockchain. Transactions are the fundamental unit of account on a blockchain and represent the transfer of value from one address to another.
The Transaction API allows users to query for transaction data by specifying filters such as transaction hash, sender or receiver address, gas price, and more. The API also provides information about the block that the transaction was included in, including block number and block timestamp.
Latest Transactions
This query is using the Transactions API to retrieve transaction data from the Binance Smart Chain (BSC) blockchain network in real-time. You can find the query here
Click to expand GraphQL query
query {
EVM(dataset: realtime, network: bsc) {
Transactions(
limit: { count: 100 }
orderBy: [{ descending: Block_Number }, { descending: Transaction_Index }]
) {
Block {
Time
Number
}
Transaction {
Hash
Cost
}
}
}
}
Parameters:
dataset: The data source to be used by the query (in this case, "realtime")network: The blockchain network to be queried (in this case, "bsc")limit: Limits the number of returned results to 100.orderBy: Sorts the results by two fields, in descending order:Block_NumberandTransaction_Index.
Results:
Block: The block information of each transaction, including the block number and timestamp.Transaction: The transaction hash and cost (gas used multiplied by the gas price)
Latest Transactions From or To an Address
This query retrieves 100 recent transactions where the specified address is either the sender (From) or the receiver (To). It is achieved by using the any filter which serves as the OR condition. It can help monitor incoming and outgoing transactions of a particular address.
You can run the query here
Click to expand GraphQL query
{
EVM(dataset: archive, network: eth) {
Transactions(
limit: {count: 100}
where: {any: [{Transaction: {From: {is: "0x21a31ee1afc51d94c2efccaa2092ad1028285549"}}}, {Transaction: {To: {is: "0x21a31ee1afc51d94c2efccaa2092ad1028285549"}}}]}
) {
Block {
Time
Number
}
Transaction {
Hash
Cost
To
From
}
}
}
}
Get Transaction Details using Hash
The below query retrieves transaction details using the transaction hash. The where clause filters transactions based on the Hash field, which is set to 0xc3684c0ea63c0e081fb779bb8feaa5e5109ccc70ef30f17f4eea041ec5ea0bc7.
You can find the query here
query MyQuery {
EVM(dataset: combined, network: eth) {
Transactions(
where: {Transaction: {Hash: {is: "0xc3684c0ea63c0e081fb779bb8feaa5e5109ccc70ef30f17f4eea041ec5ea0bc7"}}}
) {
Block {
Time
Number
}
Transaction {
From
To
Hash
Value
}
}
}
}
Next available nonce
The following query helps you determine the next available nonce for an Ethereum account by getting the latest transaction in the mempool (broadcasted transactions). The returned nonce is the highest nonce used by the account in the mempool. To get the next available nonce for a new transaction, you should increment this value by 1. You can find the query here
query MyQuery {
EVM(mempool: true, network: eth) {
Transactions(limit: {count: 1}, orderBy: {descending: Block_Time}) {
Transaction {
Nonce
}
}
}
}
Transaction Value in USD
In the below query we will use the field Transaction_ValueInUSD to get the total amount sent to a particular address in USD.
You can find the query here
query MyQuery {
EVM(network: eth) {
in_txs: Transactions(
where: {Transaction: {To: {is: "0xdac17f958d2ee523a2206206994597c13d831ec7"}}}
) {
sum(of: Transaction_ValueInUSD)
}
}
}
Internal Transactions
A single transaction on a smart contract can result in multiple internal transactions, which interact with different smart contracts. The below query gets all internal transactions for a particular tx filtered using hash.
You can run the query here
query MyQuery {
EVM(network: eth) {
Calls(
where: {Transaction: {Hash: {is: "0xd1a49976cb217c92eea2bf897d8fe760333047fb555c261f7d2c96ea52901434"}}}
) {
Call {
Create
Index
From
To
ValueInUSD
Value
Output
Signature {
Signature
Name
}
}
Transaction {
Hash
}
}
}
}
Response
- Call
- Create: Indicates if the call created a contract.
- Index: The index of the call within the transaction.
- From: The address from which the internal transaction was sent.
- To: The recipient address of the internal transaction.
- Output: The output data of the call.
- Signature: Contains signature information.
- Signature: The signature of the call.
- Name: The name of the function called.
- Transaction
- Hash: The hash of the main transaction.
Contract Calls and Internal Transactions of a Wallet
To study how a wallet or bot works, you need more than its transaction list: you need every contract its transactions called, the function name and signature of each call, and the ETH value moved. The Calls cube has one row per call, including internal calls, so filtering by Transaction: {From: ...} returns the full call trace of every transaction the wallet sent.
The query below returns the latest calls made inside transactions sent by an active MEV bot address in the last 7 days. Replace the address with the wallet you want to study.
Call.Depthis0for the call the wallet made itself and grows for each nested internal call.Call.Tois the contract that was called andCall.Signature.Nameis the function, for exampleswap,transferoruniswapV3SwapCallback.Call.Valueis the ETH sent with the call andCall.ValueInUSDis its USD value.NameandSignatureare empty when the call could not be decoded. AddSignatureHashto get the 4-byte function selector in that case. Two situations: when the contract has no published ABI,SignatureHashstill holds the selector and you can look it up or match it yourself; when the call has no selector at all (a precompile such as0x…0004, or a bot contract that reads raw calldata),SignatureHashis empty too.
{
EVM(network: eth) {
Calls(
where: {Transaction: {From: {is: "0xae2fc483527b8ef99eb5d9b44875f005ba1fae13"}}, Block: {Time: {since_relative: {days_ago: 7}}}}
limit: {count: 100}
orderBy: {descending: Block_Time}
) {
Block {
Time
}
Transaction {
Hash
To
}
Call {
Index
Depth
From
To
Value
ValueInUSD
Success
Signature {
Name
Signature
}
}
}
}
}
Which Contracts and Functions a Wallet Calls Most
To see a wallet's pattern instead of single calls, group the same calls by contract and function. The query below counts calls and distinct transactions per contract and function for the same wallet over the last 7 days, so the liquidity pools, tokens and routers it uses most come first.
{
EVM(network: eth) {
Calls(
where: {Transaction: {From: {is: "0xae2fc483527b8ef99eb5d9b44875f005ba1fae13"}}, Block: {Time: {since_relative: {days_ago: 7}}}}
limit: {count: 20}
orderBy: {descendingByField: "calls"}
) {
Call {
To
Signature {
Name
Signature
SignatureHash
}
}
calls: count
transactions: uniq(of: Transaction_Hash)
}
}
}
The same queries work on other EVM chains: change network to bsc, base, arbitrum, matic or optimism and use a wallet from that chain. For the tokens the wallet sent and received, see Latest transfers in and out, and for its DEX trades, see the Ethereum Trades Of An Address API.
Ready to run this in production?
Get an API key and run these queries in minutes, or talk to us about plans and enterprise delivery.