Skip to content

srpvpn/tensor-go-core

Repository files navigation

Tensor Go Core

A Go SDK for interacting with the Tensor marketplace on Solana blockchain. This project provides both API client functionality and high-level marketplace operations.

Overview

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

Features

API Client

  • REST API client for Tensor marketplace
  • User portfolio and data retrieval
  • Configurable HTTP transport with authentication

Marketplace Services

  • 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

Installation

go get github.com/srpvpn/tensor-go-core

Quick Start

Basic API Usage

package 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))
}

Marketplace Operations

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)
}

Key Concepts

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.

Configuration

Network Support

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"))

API Reference

Available Operations

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

Development Status

Completed

  • ✅ Core SDK structure
  • ✅ REST API client
  • ✅ Basic listing service (legacy metadata)
  • ✅ Basic buying service (legacy metadata)
  • ✅ Mainnet and devnet support

In Progress

  • 🔄 Compressed metadata support
  • 🔄 Additional service methods

Testing

Run the test suite:

go test ./test/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Ensure all tests pass
  5. Submit a pull request

License

This project is licensed under the terms specified in the LICENSE file.

Support

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

About

Tensor Go SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages