Get Active Bids of a Wallet
Illustrates how we can get active NFT Bids for a single wallet on Tensor using GraphQl
async function fetchGraphQL(operationsDoc, operationName, variables) {
const result = await fetch(
"https://programs.shyft.to/v0/graphql?api_key=YOUR-API-KEY&network=mainnet-beta",
{
method: "POST",
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName
})
}
);
return await result.json();
}
const bidder = "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F";
//enter bidder wallet address for which you want to fetch bids
const operationsDoc = `
query MyQuery {
tensor_bid_BidState(
where: {bidder: {_eq: ${JSON.stringify(bidder)}}
) {
bidAmount
bidder
expiry
nftMint
pubkey
}
TENSOR_CNFT_bidState(
where: {target: {_has_key: "assetId"}, owner: {_eq: ${JSON.stringify(bidder)}}}
) {
target
targetId
owner
pubkey
expiry
currency
bidId
amount
}
}
`;
//querying both programs in gQl call
function fetchMyQuery() {
return fetchGraphQL(
operationsDoc,
"MyQuery",
{}
);
}
async function startFetchMyQuery() {
const { errors, data } = await fetchMyQuery();
if (errors) {
// handle those errors like a pro
console.error(errors);
}
// do something great with this precious data
console.log(data);
}
startFetchMyQuery();Active bids for a wallet on Tensor Bid (Non-compressed NFTs)
Active bids for a wallet on Tensor CNFTs (Compressed NFTs)
Last updated