solana-go icon indicating copy to clipboard operation
solana-go copied to clipboard

How to use filters with rpc.GetProgramAccountsOpts

Open m4thfr34k opened this issue 2 years ago • 0 comments

Ask - Do you have an example of using GetProgramAccountsWithOpts that includes the dataslice and memcmp filters?

I am trying to use DataSlice and Filters with GetProgramAccountsWithOpts and I'm sure I'm making some rookie mistake here with the format but I can't figure out the proper format to include the memcmp filter. Thank you.

out, err := client.GetProgramAccountsWithOpts(
		context.TODO(),
		solana.MustPublicKeyFromBase58("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
		&rpc.GetProgramAccountsOpts{
			Encoding:   solana.EncodingBase64Zstd,
			Commitment: rpc.CommitmentFinalized,
			DataSlice: &rpc.DataSlice{
				Offset: pointer.ToUint64(0),
				Length: pointer.ToUint64(1024),
			},
			//TODO: what is the correct format for filters
			Filters: ,
		},
	)

m4thfr34k avatar May 23 '22 15:05 m4thfr34k