Track Events like NFT Drop, ENS Registration with Bitquery NFT API
NFT events are important data for building functionality related to NFTs. This is because NFT events provide a way to track and respond to changes on the blockchain in real time. Transactions can be broken down in detail with the help of event data.
In this blog, we will see how we can use Bitquery NFT APIs to get any on-chain NFT event information.
Getting Started
To get started for free, please create an account here with your email: https://ide.bitquery.io/
NFT Events API
Tracking NFT Drops
NFT drops are highly anticipated events where new NFT collections are released to the public. NFT drops can be very competitive. To increase your chances of getting your hands on the latest NFTs, it is important to track NFT drops and be ready to mint when they go live.
Bitquery’s NFT API will now show you a list of all of the NFT mint events that have occurred for the Seadrop collection in real-time. Below is the screenshot of the Opensea SeaDrop Explorer Page:
To track only say a particular event like SeaDropMint
we use smartContractEvents method.
The following GraphQL query will return a list of the latest NFT mint events
You can get the query here
query MyQuery {
ethereum {
smartContractEvents(
smartContractEvent: {is: "SeaDropMint"}
options: {limit: 10, desc: "block.timestamp.time"}
) {
smartContractEvent {
name
signature
}
smartContract {
contractType
address {
address
}
}
transaction {
hash
}
block {
timestamp {
time
}
}
}
}
}
You can track related events like PublicDropUpdated, PayerUpdated, DropURIUpdated,
AllowListUpdated by using the same query described above with the event name changed.
In addition to tracking NFT drops, you can also use the Bitquery NFT API to track other important NFT data, such as NFT ownership, NFT transfers, and NFT sales.
Tracking Royalty
Royalties help creators receive compensation for their work even after an NFT is resold. In this section we will explore how to track royalties for NFTs, both default and customized.
Default Royalty
Default royalties are typically set by the creators of NFTs and are automatically applied to every subsequent sale of the NFT. These royalties ensure that creators receive a percentage of the proceeds whenever their NFT changes hands. To track default royalties for NFTs, we can use Bitquery's NFT API. Here's an example query:
query MyQuery {
ethereum(network: ethereum) {
smartContractCalls(
smartContractMethod: {is: "royaltyInfo"}
options: {limit: 10, desc: "block.timestamp.time"}
) {
block {
timestamp {
time
}
}
arguments {
value
argument
argumentType
}
transaction {
hash
txFrom {
address
}
}
smartContractMethod {
name
}
smartContract {
address {
address
annotation
}
}
caller {
address
}
}
}
}
This query retrieves data about royalty information using the "royaltyInfo" method from smart contracts on the Ethereum network. It includes details such as the timestamp, arguments (including the token ID and royalty value), transaction hash, and the addresses involved in the transaction.
Custom Royalties
In addition to default royalties, some NFT marketplaces and platforms allow creators to customize royalty percentages for each sale of their NFTs. To track customized royalties on Rarible NFTs, you can use Bitquery's NFT API. Here's an example query:
query MyQuery {
ethereum(network: ethereum) {
smartContractCalls(
smartContractMethod: {is: "setDefaultRoyalty"}
options: {limit: 10, desc: "block.timestamp.time"}
) {
block {
timestamp {
time
}
}
arguments {
value
argument
argumentType
}
transaction {
hash
txFrom {
address
}
}
smartContractMethod {
name
}
smartContract {
address {
address
annotation
}
}
caller {
address
}
}
}
}
This query focuses on retrieving royalty information from Rarible NFTs, providing insights into the specific royalty percentages and other transaction-related details.
Tracking ENS: Ethereum Name Service Listing
The Ethereum Name Service (ENS) is a Web3 domain name system that allows users to register and use human-readable names for Ethereum addresses and other resources.
To track ENS registrations with Bitquery, simply navigate to the ENS page on the Bitquery Explorer. On this page, you will see a live feed of all recent ENS registrations, as well as a list of the most popular ENS names like vitalik.eth
You can use the ENS API to get details of all ENS listings, including the name, owner, and expiration date. For example, the query below will return the 10 most recent ENS registrations, ordered by creation date. You can modify the query to return more or fewer registrations or to order the results by a different field. Run it here.
query MyQuery {
ethereum {
arguments(
smartContractEvent: {is: "NameRegistered"}
smartContractAddress: {is: "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85"}
options: {limit: 10, desc: "block.timestamp.time"}
) {
block {
timestamp {
time
}
}
callDepth
caller {
address
annotation
}
transaction {
hash
}
value {
value
}
argument {
name
type
}
}
}
}
Once you have the results of your query, you can use them to track ENS listings. For example, you could create a spreadsheet to track the registrations, or you could use a data visualization tool to create a chart or graph. You could also use the results to create a notification system that alerts you when new ENS registrations are made.
Tracking NFT Loans
In this section we'll explore how to track NFT loans on the Blur and X2Y2 platforms using Bitquery's NFT API.
Latest Loans taken on Blur
Blur uses the Blend protocol to enable NFT loans. We will use Bitquery’s BLUR API to get information on Blend loans and offers.
For example in this query ( run on V2 APIs) , we look for the “LoanOfferTaken” events and set the smart contract to the Blur: Blend Contract to get loan events on the marketplace. You can run the query here.
We are using Logheader to query smart contract events because it’s a delegated proxy contract.
{
EVM(dataset: combined, network: eth) {
Events(
where: {LogHeader: {Address: {is: "0x29469395eaf6f95920e59f858042f0e28d98a20b"}}, Log: {Signature: {Name: {is: "LoanOfferTaken"}}}}
limit: {count: 10}
orderBy: {descending: Block_Time}
) {
Block {
Number
}
Transaction {
Hash
}
Log {
SmartContract
Signature {
Name
Signature
}
}
Arguments {
Name
Index
Type
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_Address_Value_Arg {
address
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
}
}
}
}
}
Latest Loans Taken on X2Y2
X2Y2 is another platform that offers NFT-based loans. To track the latest loans initiated on X2Y2, we can use Bitquery's NFT API. For example, we can look for "LoanStarted" events within the X2Y2 smart contract. Here's a sample query:
query MyQuery {
ethereum(network: ethereum) {
smartContractEvents(
smartContractEvent: {is: "LoanStarted"}
options: {limit: 10, desc: "block.timestamp.time"}
smartContractAddress: {is: "0xB81965DdFdDA3923f292a47A1be83ba3A36B5133"}
) {
arguments {
argument
value
}
smartContractEvent {
name
}
smartContract {
address {
address
}
}
transaction {
hash
}
block {
timestamp {
time
}
}
}
}
}
As you can see it provides information such as the loan ID, borrower, lender, borrowed asset, NFT asset, offer type, and more. You can run this query here.
Building an Event Alert System
We offer websockets to keep alive the connection between Bitquery APIs and your system, so you can track the events in real-time. Read the full docs here: https://docs.bitquery.io/docs/start/websocket/
Subscribe to our newsletter
Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.