Like typescript package do we have go package that generates clients for solana anchor programs?

  • did you ever find a solution to this? Apr 17 at 4:22

2 Answers 2


You can use anchor-go which takes the IDL created by anchor to generate clients.


Anchor automatically generates IDLs as well as typescript types when you build your programs. You can either use IDLs directly or wrap them around additional layers of SDK abstraction as required.

The only very minor caveat is that anchor exports the entire program as a single type definition. In order to extract individual types from the single type definition, you need to do something like this:

   import { IdlAccounts } from "@coral-xyz/anchor";
   import { LibreplexMetadata } from "@libreplex/idls/lib/types/libreplex_metadata"
   export type Group = IdlAccounts<LibreplexMetadata>["group"];


LibreplexMetadata is the anchor-generated top-level type, IdlAccounts a very convenient wrapper type provided by the anchor npm library, and group is one of the data structs defined in libreplex_metadata program.

Make sure you use the anchor from @coral-xyz instead of any other ones - there are a few older versions / forks of anchor floating around but the one from @coral-xyz is always the latest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.