Calling Methods
Every method from the Aptos NFT Trading SDK returns the transaction payload data that you need to pass into the wallet tx signing method.
Here is an example of how to call a method:
import { useWallet } from '@aptos-labs/wallet-adapter-react'
const { signAndSendTransaction } = useWallet()
const payload = await aptosTradingClient.buyListings({
listingIds: ["5381c4a4-5c42-424e-a10e-80d24fc411c2"]
})
await signAndSendTransaction(payload)
💡
Note: The SDK method returns the transaction payload data needed to sign the tx. It does not automatically submit the transaction.
In this example, the signAndSendTransaction
method is coming from the useWallet
hook from @aptos-labs/wallet-adapter-react
(See Docs Here (opens in a new tab)). You can also use the @aptos-labs/ts-sdk
(See Docs Here (opens in a new tab)) package to sign the transactions with the payload returned from the our SDK.
The listing ID in the example above comes from our NFT Data API.