The Indexer SUI Market SDK is a Typescript SDK which enables the ability to execute any SUI NFT marketplace transaction across any marketplace. Each method in the SDK returns the Transaction Block you need to pass into signAndExecuteTransactionBlock().

Getting Started

The SUI Market SDK is built on top of the Indexer GraphQL API, so you’ll need an Indexer API Key and API User to use the SDK. You can explore the GraphQL API here: https://www.indexer.xyz/api-explorer

Getting Started with the Indexer GraphQL API

Initialize the Client

You need to pass in your API Key and API User to create an instance of the SuiMarketClient. The SDK uses these headers to fetch necessary data from our GraphQL API in order to create the payload for the transaction.

import { SuiMarketClient } from "@indexer-xyz/sui"

const suiMarketClient = new SuiMarketClient({
	apiKey: YOUR_API_KEY,
  apiUser: YOUR_API_USER
})

Calling Methods

const transactionBlock = await suiMarketClient.buyListings({
  listingIds: [listing.id],
  walletAddress: '0x...',
})
await suiSignAndExecuteTransactionBlock({ transactionBlock })

Note that the methods return a Sui Transaction Block that you need to pass into the wallet signing method with whichever client library you are using. In this example, the suiSignAndExecuteTransactionBlock() method is coming from the useWalletKit() hook from @mysten/wallet-kit

The listing ids in the example above (and the nft ids and bid ids in future examples below) come from the Indexer GraphQL API.

The walletAddress is the signer’s SUI wallet address

Available Methods

buyListings()

const transactionBlock = await suiMarketClient.buyListings({
  listingIds: [listing1.id, listing2.id],
  walletAddress: connectedWalletId,
})
await suiSignAndExecuteTransactionBlock({ transactionBlock })

Pass in one or multiple listing ids listing1.id and listing2.id are uuids from the GraphQL API listings entity Note that the listing could be on any SUI marketplace.

listNfts()

List an NFT. If NFT is already listed, it will relist it.

const txBlock = await suiMarketClient.listNfts({
  nfts: [
    {
      id: nft.id,
      listPrice: price,
    },
  ],
  walletAddress: connectedWalletId,
})
await suiSignAndExecuteTransactionBlock({ transactionBlock })

Pass in one or multiple nfts nft.id is a uuid from the GraphQL API nfts entity listPrice: The list price in APT

unlistListings()