Documentation Index
Fetch the complete documentation index at: https://docs.sendai.fun/llms.txt
Use this file to discover all available pages before exploring further.
Interact with Tensor Trade marketplace to list and manage NFTs. This implementation provides functionality for listing NFTs for sale and canceling existing listings.
Core Features
-
Listing Management
- List NFTs for sale
- Cancel listings
- Price setting
- Ownership verification
-
Token Account
- Associated token validation
- Ownership checks
- Balance verification
- Account creation
Usage
List NFT for Sale
// List NFT
const signature = await agent.tensorListNFT(
new PublicKey("nft-mint-address"),
1.5 // Price in SOL
);
Cancel Listing
// Cancel listing
const signature = await agent.tensorCancelListing(
new PublicKey("nft-mint-address")
);
Example Prompts
Natural Language Prompts
"List my NFT for 2 SOL on Tensor"
"Cancel my NFT listing on Tensor"
"Put NFT up for sale at 1.5 SOL"
"Remove NFT listing from marketplace"
List NFT
{
"nftMint": "nft-mint-address",
"price": 1.5
}
Cancel Listing
{
"nftMint": "nft-mint-address"
}
Implementation Details
Listing Process
interface ListingParams {
nftMint: PublicKey; // NFT mint address
nftSource: PublicKey; // Token account
owner: PublicKey; // Owner address
price: BN; // Price in lamports
tokenProgram: PublicKey; // Token program ID
payer: PublicKey; // Transaction payer
}
// Price conversion
const priceInLamports = new BN(price * 1e9);
Ownership Verification
// Get Associated Token Account
const ata = await getAssociatedTokenAddress(
nftMint,
ownerAddress
);
// Verify ownership
const tokenAccount = await getAccount(
connection,
ata
);
if (!tokenAccount || tokenAccount.amount <= 0) {
throw new Error("NFT not owned");
}
Error Handling
try {
const tx = await agent.tensorListNFT(mint, price);
} catch (error) {
if (error.message.includes("NFT not found")) {
// Handle missing NFT
} else if (error.message.includes("Invalid mint")) {
// Handle invalid address
}
}
Best Practices
-
Listing Management
- Verify ownership first
- Check token accounts
- Validate prices
- Monitor transactions
-
Token Handling
- Verify mint addresses
- Check balances
- Validate accounts
- Handle permissions
-
Transaction Processing
- Build transactions properly
- Include all signers
- Handle timeouts
- Monitor status
Common Issues
-
Listing Issues
- Invalid mint address
- NFT not owned
- Price formatting
- Account mismatch
-
Cancellation Issues
- Listing not found
- Permission denied
- Network errors
- Transaction failures
-
Account Issues
- Missing ATA
- Zero balance
- Wrong owner
- Program mismatch
Success Response
{
status: "success",
message: "NFT listed successfully",
transaction: "transaction-signature",
price: 1.5,
nftMint: "mint-address"
}
Error Response
{
status: "error",
message: "Error message",
code: "ERROR_CODE"
}
SDK Integration
TensorSwap SDK Setup
const provider = new AnchorProvider(
connection,
wallet,
AnchorProvider.defaultOptions()
);
const tensorSwapSdk = new TensorSwapSDK({ provider });
Transaction Building
// Build transaction
const { tx } = await tensorSwapSdk.list(params);
// Create and send transaction
const transaction = new Transaction();
transaction.add(...tx.ixs);
return await connection.sendTransaction(
transaction,
[wallet, ...tx.extraSigners]
);
Advanced Features
-
Custom Token Programs
- SPL Token support
- Program validation
- Account creation
- Balance management
-
Authorization
- Auth data handling
- Permission checks
- Signature validation
- Access control
-
Price Management
- Lamport conversion
- Price validation
- Fee calculation
- Slippage protection
Resources