Git Product home page Git Product logo

Comments (3)

yihau avatar yihau commented on July 19, 2024 2

This SDK haven't support GetTokenAccountsByOwner yet but I think getProgramAccounts can do the same thing like

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/portto/solana-go-sdk/client"
	"github.com/portto/solana-go-sdk/client/rpc"
	"github.com/portto/solana-go-sdk/common"
)

func main() {
	c := client.NewClient(rpc.DevnetRPCEndpoint)
	res, err := c.GetProgramAccountsWithConfig(
		context.Background(),
		common.TokenProgramID.ToBase58(),
		rpc.GetProgramAccountsConfig{
			Encoding: rpc.GetProgramAccountsConfigEncodingJsonParsed,
			Filters: []rpc.GetProgramAccountsConfigFilter{
				{
					DataSize: 165,
				},
				{
					MemCmp: &rpc.GetProgramAccountsConfigFilterMemCmp{
						Offset: 32,
						Bytes:  "your owner base58 address here",
					},
				},
			},
		},
	)
	if err != nil {
		log.Fatalf("failed to get program accounts, err: %v", err)
	}
	fmt.Println(res.Result)
}

Recently I'm refactoring rpc. It will be supported soon!

from solana-go-sdk.

seajmurphy avatar seajmurphy commented on July 19, 2024 1

thank you for the quick response @yihau 😃

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024 1

I've add it in v2.0.0 => v1.9.0 . I will do some mapping in the wrapped client for more convenient usage.

from solana-go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.