âĢ Sort ResultsLearn how to use Airstack to get token-bound account results sorted in ascending or descending order by the creation block timestamp.
Airstack provides easy-to-use APIs for enriching ERC6551 dapps and integrating on-chain and off-chain data.
Table Of Contents
In this guide you will learn how to use Airstack to:
Pre-requisites
Basic knowledge of GraphQL
Get Started
JavaScript/TypeScript/Python
If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:
npm yarn pnpm pip
React
Copy npm install @airstack/airstack-react
Node
Copy npm install @airstack/node
React
Copy yarn add @airstack/airstack-react
Node
Copy yarn add @airstack/node
React
Copy pnpm install @airstack/airstack-react
Node
Copy pnpm install @airstack/node
Then, add the following snippets to your code:
React Node Python
Copy import { init , useQuery } from "@airstack/airstack-react" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const Component = () => {
const { data , loading , error } = useQuery (query);
if (data) {
return < p >Data: { JSON .stringify (data)}</ p >;
}
if (loading) {
return < p >Loading...</ p >;
}
if (error) {
return < p >Error: { error .message}</ p >;
}
};
Copy import { init , fetchQuery } from "@airstack/node" ;
init ( "YOUR_AIRSTACK_API_KEY" );
const query = `YOUR_QUERY` ; // Replace with GraphQL Query
const { data , error } = await fetchQuery (query);
console .log ( "data:" , data);
console .log ( "error:" , error);
Copy import asyncio
from airstack . execute_query import AirstackClient
api_client = AirstackClient (api_key = "YOUR_AIRSTACK_API_KEY" )
query = """YOUR_QUERY""" # Replace with GraphQL Query
async def main ():
execute_query_client = api_client . create_execute_query_object (
query = query)
query_response = await execute_query_client . execute_query ()
print (query_response.data)
asyncio . run ( main ())
Other Programming Languages
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
đ¤ AI Natural Language â Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.
Get The Latest Token Bound Accounts Created
You can get the all the latest token-bound accounts created in descending order by createdAtBlockTimestamp
by setting the value to enum DESC
:
Try Demo
Code
Query Response
Copy query MyQuery {
Accounts(
input: {
order : { createdAtBlockTimestamp : DESC }
blockchain : ethereum
limit : 200
}
) {
Account {
id
standard
blockchain
tokenAddress
tokenId
address {
identity
blockchain
}
registry
implementation
salt
createdAtBlockNumber
createdAtBlockTimestamp
creationTransactionHash
deployer
updatedAtBlockNumber
updatedAtBlockTimestamp
}
}
}
Copy {
"data" : {
"Accounts" : {
"Account" : [
{
"id" : "a7ed516e2a9c49f1f18a7a62adabf08181f6ca6b1d2dc35a890df257ebeb02ff" ,
"standard" : "ERC6551" ,
"blockchain" : "ethereum" ,
"tokenAddress" : "0x51e613727fdd2e0b91b51c3e5427e9440a7957e4" ,
"tokenId" : "13015035" ,
"address" : {
"identity" : "0x0d6eb86ed9231e4ff679367c24480e79e452834d" ,
"blockchain" : "ethereum"
} ,
"registry" : "0x02101dfb77fde026414827fdc604ddaf224f0921" ,
"implementation" : "0x2d25602551487c3f3354dd80d76d54383a243358" ,
"salt" : "0" ,
"createdAtBlockNumber" : 17681775 ,
"createdAtBlockTimestamp" : "2023-07-13T02:57:59Z" ,
"creationTransactionHash" : "0xe017bbb147e3e6c345e41920aafd0cf5304863d93f606f2d192679f0299ca242" ,
"deployer" : "0x90bade35da052450b01e99b38cbb550bc3f1dd58" ,
"updatedAtBlockNumber" : 17681775 ,
"updatedAtBlockTimestamp" : "2023-07-13T02:57:59Z"
}
]
}
}
}
Get The Earliest Token Bound Accounts Created
You can get the all the earliest token-bound accounts created in descending order by createdAtBlockTimestamp
by setting the value to enum ASC
:
Try Demo
Code
Query Response
Copy query MyQuery {
Accounts(
input: {
order : { createdAtBlockTimestamp : ASC }
blockchain : ethereum
limit : 200
}
) {
Account {
id
standard
blockchain
tokenAddress
tokenId
address {
identity
blockchain
}
registry
implementation
salt
createdAtBlockNumber
createdAtBlockTimestamp
creationTransactionHash
deployer
updatedAtBlockNumber
updatedAtBlockTimestamp
}
}
}
Copy {
"data" : {
"Accounts" : {
"Account" : [
{
"id" : "37130b5894303a6d57d28bed00daa5583acc9fd0e2e475be825f65af765b76e4" ,
"standard" : "ERC6551" ,
"blockchain" : "ethereum" ,
"tokenAddress" : "0x26727ed4f5ba61d3772d1575bca011ae3aef5d36" ,
"tokenId" : "0" ,
"address" : {
"identity" : "0x5416e5dc14caa0950b2a24ede1eb0e97c360bcf5" ,
"blockchain" : "ethereum"
} ,
"registry" : "0x02101dfb77fde026414827fdc604ddaf224f0921" ,
"implementation" : "0x2d25602551487c3f3354dd80d76d54383a243358" ,
"salt" : "0" ,
"createdAtBlockNumber" : 17213826 ,
"createdAtBlockTimestamp" : "2023-05-08T05:53:59Z" ,
"creationTransactionHash" : "0xf998cb400eebe89aa1d369792daf4c202be74dcd88981b34eb49d510b7837332" ,
"deployer" : "0xa75b7833c78eba62f1c5389f811ef3a7364d44de" ,
"updatedAtBlockNumber" : 17213826 ,
"updatedAtBlockTimestamp" : "2023-05-08T05:53:59Z"
}
]
}
}
}
Developer Support
If you have any questions or need help regarding sorting ERC6551 token bound accounts data by creation block timestamp, please join our Airstack's Telegram group.
More Resources