A Go SDK for interacting with the Tensor marketplace on Solana blockchain. This project provides both API client functionality and high-level marketplace operations.
Tensor Go Core is a comprehensive Go library that enables developers to:
- Interact with Tensor's REST API endpoints
- Execute marketplace operations (listing, buying, bidding) through high-level services
- Manage NFT transactions on Solana with minimal setup
- REST API client for Tensor marketplace
- User portfolio and data retrieval
- Configurable HTTP transport with authentication
- Listing Service: Create and manage NFT listings
- Buying Service: Purchase NFTs from the marketplace
- Automatic Account Resolution: SDK handles all necessary account derivations
- Transaction Building: Automatic transaction construction and signing
go get github.com/srpvpn/tensor-go-corepackage main
import (
"context"
"github.com/srpvpn/tensor-go-core/sdk"
"github.com/srpvpn/tensor-go-core/api/data_api/user"
)
func main() {
c := client.New("", "your-api-key")
ctx := context.Background()
portfolio, code, err := c.User.GetPortfolio(ctx, &user.PortfolioRequest{
Wallet: "your-wallet-address",
})
if err != nil {
panic(err)
}
fmt.Printf("Portfolio retrieved: %d items\n", len(portfolio))
}package main
import (
"context"
"github.com/srpvpn/tensor-go-core/sdk"
)
func main() {
// Create SDK client with RPC connection
c := client.New("", "",
client.WithRPCURL("https://api.devnet.solana.com"))
ctx := context.Background()
// List an NFT for sale
listParams := &marketplace.ListLegacyParams{
Seller: sellerPrivateKey,
Mint: nftMintAddress,
Price: 1000000000, // 1 SOL in lamports
}
listOp, err := c.Marketplace.Listing.NewListLegacyOp(ctx, listParams)
if err != nil {
panic(err)
}
// Execute the listing operation
signature, err := c.Marketplace.Do(ctx, listOp)
if err != nil {
panic(err)
}
fmt.Printf("NFT listed successfully: %s\n", signature)
}The SDK is built around two main components that serve different purposes:
-
API Client: This is a standard REST client for interacting with Tensor's backend servers. It's used for fetching data that is already indexed by Tensor, such as user portfolios, activity. It does not interact with the Solana blockchain directly.
-
Marketplace Client (client.Marketplace): This client interacts directly with the Solana blockchain via an RPC endpoint. It is used to create, sign, and send transactions for on-chain operations like listing, buying, and bidding on NFTs.
The SDK supports both mainnet and devnet:
// Mainnet (default)
client := client.New("", "",
client.WithRPCURL("https://api.mainnet-beta.solana.com"))
// Devnet
client := client.New("", "",
client.WithRPCURL("https://api.devnet.solana.com"))| Service | Method | Description | Status |
|---|---|---|---|
| Listing | NewListLegacyOp |
List NFT for sale (legacy metadata) | ✅ Complete |
| Buying | NewBuyLegacyOp |
Buy NFT (legacy metadata) | ✅ Complete |
| Listing | NewListOp |
List NFT for sale (compressed metadata) | 🔄 In Progress |
| Buying | NewBuyOp |
Buy NFT (compressed metadata) | 🔄 In Progress |
| Bidding | NewBidOp |
Place bid on NFT | 📋 Planned |
| Management | EditListing |
Edit listing parameters | 📋 Planned |
| Management | DelistNFT |
Remove listing | 📋 Planned |
- ✅ Core SDK structure
- ✅ REST API client
- ✅ Basic listing service (legacy metadata)
- ✅ Basic buying service (legacy metadata)
- ✅ Mainnet and devnet support
- 🔄 Compressed metadata support
- 🔄 Additional service methods
Run the test suite:
go test ./test/- Fork the repository
- Create a feature branch
- Make your changes
- Ensure all tests pass
- Submit a pull request
This project is licensed under the terms specified in the LICENSE file.
For questions and support:
- Check the test files for usage examples
- Review the service implementations for detailed API information
- Open an issue for bugs or feature requests