Shyft
Start BuildingSupportWebsite
  • Welcome
    • 👋Introducing Shyft
    • 🏗️Start Building
  • Solana Infrastructure
    • 🚁Shyft RPCs
  • Yellowstone gRPC Network
    • Decoding gRPC Latency
    • ⚡gRPC Docs
      • Introduction
      • Authentication
      • Subscribe Requests
      • FAQ
      • Getting Started
        • Initializing the Yellowstone Client
        • Making a gRPC connection
        • Adding a Reconnection Mechanism
        • 🔥Replaying Slots with Solana yellowstone gRPCs
        • Modifying your Subscribe Request
        • Closing a gRPC Connection
      • Subscribing to Transactions
        • All Transactions of an address
        • Subscribing to all transactions of a Liquidity Pool
        • Subscribing to all transactions of multiple addresses
        • Subscribing to all transactions of a Token
      • Subscribing to Accounts
        • Account Updates for a Program
        • Account Updates for an Address
        • Account updates using memcmp
      • Streaming Blocks & BlocksMeta
        • Streaming Block Updates
        • Subscribing to BlocksMeta
      • Modifying & Unsubscribing
  • Solana defi data
    • DeFI APIs
      • Get Pool By Address
      • Get Pools By Token Pair
      • Get All Pools for a Token
      • Get Liquidity Details of a Pool
  • Callbacks
    • ☎️What are Callbacks?
      • Transaction Callbacks
      • Account Callbacks
    • 📔Callback APIs
      • Response Structure
      • List Callbacks
      • Register callback
      • Remove callback
      • 🔥Pause a callback
      • 🔥Resume a callback
      • Update Callbacks
      • Add Addresses
      • Remove addresses
  • Solana Super Indexers
    • 🌩️GraphQL APIs
      • Getting Started
      • Building Queries
      • Paginating Response
      • Applying Filters
      • Ordering and Sorting Data
    • 📀Case Studies
      • Tensor
        • Get Active Listings of a Wallet
        • Get Active Bids of a Wallet
        • Get Active Listings of a Collection
        • Get all Bids of a Collection
        • Get all Pools of a Margin Account
        • Get all Pools by Owner
      • Raydium
        • Get Pool By Address
        • Get Pools By Token Address
        • Get Pools Created Between Time
        • Get Pool Burn Percentage
        • Get Liquidity Details of a Pool
        • Get Pool and OpenBook Market Info
        • Get Token Supply Percentage In Pool
      • Orca Whirlpool
        • Get Pool by Address
        • Get Pool by Token Address
        • Get Positions for a Pool
        • Get Positions for a Wallet
        • Get Liquidity Details of a Pool
      • Kamino
        • Get Borrow Details of a Wallet
        • Get Deposit Details of a Wallet
        • Get Reserve Details
      • Cross Marketplace Queries
        • Get active listings across marketplaces for a wallet
        • Get listings for a collection across marketplaces
        • Get floor price of a collection
      • Cross Defi Queries
        • Fetch Liquidity Pools for Token
      • Native Staking
        • Get Stakes for a Wallet
        • Get Stakes For Validator
      • Governance/Realms
        • Get DAO Token Owners
        • Get Proposals For Governing Mint
        • Get All Proposals For DAO
        • Get DAO Treasury Info
        • Get All Active Proposals For Wallet
      • Meteora
        • Get All LB Position Pairs
        • Get Position of a User Wallet
        • Get Pool by Token Addresses
        • Get All Deposits for a User
        • Get All Withdraws for a User
        • Get All Fees Claimed by a User
        • Get All User Positions and Deposits for a Pool
        • Get All User Positions and Withdrawals for a Pool
      • Fluxbeam
        • Get Pool by Address
        • Get Pool by Token Addresses
      • Drift
        • Get User account for Delegate
        • Get User accounts based on authority
        • Get User details based on Referrer
        • Get Borrow/Deposit Amount for an User
        • Get PrepPositions for an User Account
        • Getting OrderId and userOrderId
        • Get OpenOrders for a User Account
      • 🔥Pumpswap
        • 🔥Get Pool by Address
        • 🔥Get Pool by Creator Address
        • 🔥Get Pools by Token Addresses
      • Raydium Launchpad
        • Get Bonding Curve Details by Pool Address
        • Get All Pools for a Creator
        • Get Pools by Token Addresses
        • Get Migration details of a Pool
  • Solana APIs
    • API Reference
    • Transactions
      • Parsed Transaction Structure
      • Transaction APIs
        • History
        • Parse Signature
        • Parse Multiple Signatures
        • Send
        • Send Multiple
    • NFT
      • 🔥Create Gasless
      • Create
      • Read All
      • Burn
      • 🔥Burn Multiple NFTs V2
      • Update
      • 🔥Create NFT from Metadata
      • 🔥Read Wallet Nfts
      • 🔥Read Selected NFTs
      • 🔥Get NFT Owners
      • 🔥Update NFT Metadata Uri
      • 🔥Update V2
      • Search
      • Transfer
      • Transfer Multiple NFTs
      • Mint
      • Read
    • Wallet
      • Get Balance
      • Get Token Balance
      • Get All Tokens Balance
      • Get Portfolio
      • Resolve Address
      • Get All Domains
      • Get Stake Accounts
    • Fungible Tokens
      • Create
      • Mint
      • Burn
      • 🔥Update
      • Get Token Info
      • Transfer
      • Airdrop
  • 📘Dev Guides
    • 📀gRPC Case Studies
      • Pumpfun
        • Streaming and Parsing Pump.fun Transactions
        • Streaming and Parsing Pump.fun Accounts
        • Detecting new Token launches on Pump.fun
        • Detecting Buy/Sell Transactions on Pump.fun
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
      • PumpSwap AMM
        • Streaming and Parsing Pump Swap Transactions
        • Streaming and Parsing Pump Swap AMM Accounts
        • Detecting Buy/Sell Transactions on Pump Swap AMM
        • Detecting tokens migrating from Pump.fun to Pump Swap AMM
Powered by GitBook
On this page

Was this helpful?

  1. Solana Super Indexers
  2. Case Studies
  3. Tensor

Get Active Bids of a Wallet

Illustrates how we can get active NFT Bids for a single wallet on Tensor using GraphQl

In the Tensor marketplace, users can bid on both NFTs and cNFTs. Tensor has two different programs that keep track of these bids.

  • The bids on cNFTs are managed and stored in the bidState account of the Tensor_CNFT program

  • The bids on NFTs are handled by the bidState account of the Tensor_bid program.

Cross program query is possible here. You can query both programs in a single graphQl call.

With SHYFT’s SuperIndexer we can query both of these programs in a single query, while also applying the where filter on the bidder field of the bidState field of Tensor_bid program and the owner field of the Tensor_CNFT program . This would give us all the bids by one particular bidder wallet.

The target field of the Tensor_CNFT program can have two possible keys, assetId and whitelist. 'assetId' indicates the bid is on a single NFT, and 'whitelist' indicates the bid is on a whitelist account equivalent to a collection.

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();
{ //response shortened for visibility
  "data": {
    "tensor_bid_BidState": [
      {
        "bidAmount": 1500000000,
        "bidder": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "expiry": 1740103769,
        "nftMint": "tpLApHuN2pwyAJd2bByxTsitzXWL5LaH5YqwFZMx1Kt",
        "pubkey": "6tJFEvJtgbBpoWCovwH291vWGA14Je1Baja5i4xyR5Fj"
      },
      {
        "bidAmount": 200000000,
        "bidder": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "expiry": 1714172253,
        "nftMint": "7zdU6BZVZCSfGKPSs2LwXYMqKzodrmxFJeZG85qyHjf2",
        "pubkey": "4wijcue36SGQ8bLyB2j3ZqdigN5mEvT8PV8tfJfLk3uE"
      }
    ],
    "TENSOR_CNFT_bidState": [
      {
        "target": {
            "assetId": {}
      },
        "targetId": "ECiihNS3R9PrKMLTBAA6RPCb4b27McxvjuX2f9ndnJg2",
        "owner": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "pubkey": "GaEU91W1WJ5diBvBbP4XWBuGnfGTduQkpi9F7VsAzbGH",
        "expiry": 1740553188,
        "currency": null,
        "bidId": "ECiihNS3R9PrKMLTBAA6RPCb4b27McxvjuX2f9ndnJg2",
        "amount": 2250000000
      },
      {
        "target": {
          "assetId": {}
      },
        "targetId": "Dzn7k3qUC9nj1nVvH1jsNYKbHrJazW78zwhFTxe5ywFF",
        "owner": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "pubkey": "QgmyTZLWLYmLLTncyZiVfkjRhcmymPHoXavTqr6H9ka",
        "expiry": 1740519924,
        "currency": null,
        "bidId": "Dzn7k3qUC9nj1nVvH1jsNYKbHrJazW78zwhFTxe5ywFF",
        "amount": 10000000
      }
    ]
  }
}

Active bids for a wallet on Tensor Bid (Non-compressed NFTs)

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 operationsDoc = `
  query MyQuery {
    tensor_bid_BidState(
      where: {bidder: {_eq: "12LtD1mjCoo3G79rmq9N98Zgmq4qatwcMAxt1VnJrD8o"}}
    ) {
      bidAmount
      bidder
      expiry
      nftMint
      pubkey
    }
  }
`;

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();
{
  "data": {
    "tensor_bid_BidState": [
      {
        "bidAmount": 1500000000,
        "bidder": "12LtD1mjCoo3G79rmq9N98Zgmq4qatwcMAxt1VnJrD8o",
        "expiry": 1739712261,
        "nftMint": "6hu69KxxXNATFFv5RScJVNu1AMLmBXdFSVGqjsKrdD78",
        "pubkey": "AuqeTsxV5p4RHnsBPyzgZkT3XR24srjiGzbvkifQxdnf"
      },
      {
        "bidAmount": 137000000,
        "bidder": "12LtD1mjCoo3G79rmq9N98Zgmq4qatwcMAxt1VnJrD8o",
        "expiry": 1739775972,
        "nftMint": "DVhpDyG8nT8J5Q5XAUkf8Sj5pJHt2a6DCS8tLP1ZfaQG",
        "pubkey": "Etw93NNH4bHh2ChhygVP3w5HTocPLJWnc73BNTECFUGu"
      }
    ]
  }
}

Active bids for a wallet on Tensor CNFTs (Compressed NFTs)

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 operationsDoc = `
  query MyQuery {
    TENSOR_CNFT_bidState(
      where: {target: {_has_key: "assetId"}, owner: {_eq: "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F"}}
    ) {
      target
      targetId
      owner
      pubkey
      expiry
      currency
      bidId
      amount
    }
  }
`;

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();
{ //response shortened
  "data": {
    "TENSOR_CNFT_bidState": [
      {
        "target": {
            "assetId": {}
      },
        "targetId": "ECiihNS3R9PrKMLTBAA6RPCb4b27McxvjuX2f9ndnJg2",
        "owner": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "pubkey": "GaEU91W1WJ5diBvBbP4XWBuGnfGTduQkpi9F7VsAzbGH",
        "expiry": 1740553188,
        "currency": null,
        "bidId": "ECiihNS3R9PrKMLTBAA6RPCb4b27McxvjuX2f9ndnJg2",
        "amount": 2250000000
      },
      {
        "target": {
          "assetId": {}
      },
        "targetId": "Dzn7k3qUC9nj1nVvH1jsNYKbHrJazW78zwhFTxe5ywFF",
        "owner": "HGjJQTpMHisEekSoPsFvBadHeDauyY9CopAEZSBUSt8F",
        "pubkey": "QgmyTZLWLYmLLTncyZiVfkjRhcmymPHoXavTqr6H9ka",
        "expiry": 1740519924,
        "currency": null,
        "bidId": "Dzn7k3qUC9nj1nVvH1jsNYKbHrJazW78zwhFTxe5ywFF",
        "amount": 10000000
      }
    ]
  }
}
PreviousGet Active Listings of a WalletNextGet Active Listings of a Collection

Last updated 1 year ago

Was this helpful?

📀