Open lucasoares opened 6 months ago
@lucasoares not sure if you need this anymore but i found a workaround to make create associated token account idempotent possible.
import (
"github.com/gagliardetto/solana-go"
associatedtokenaccount "github.com/gagliardetto/solana-go/programs/associated-token-account""
)
func BuildCreateATAIdempotentInstruction(payer, walletAddress, mint solana.PublicKey) *solana.GenericInstruction {
createATAInstruction := associatedtokenaccount.NewCreateInstruction(
payer,
walletAddress,
mint,
).Build()
return solana.NewInstruction(createATAInstruction.ProgramID(), createATAInstruction.Accounts(), []byte{1})
}
The difference is at the data field, set it to 1 to enable idempotent mode
Currently solana-go only allows creating non-idempotent instruction for the
associatedtokenaccount.NewCreateInstructionBuilder
program instruction.It would be nice to allow it to be created using the idempotent solution, which is achieved by having a
[1]
uint8 bytearray as the instruction data.I do not understand the
gagliardetto/binary
library's internals and don't know how theBaseVariant
works. The currentbinary
module doesn't have much documentation, but if you guide me it appears to be an easy PR.Loved the work you have done with this library. I will be using it a lot for personal projects, and I want to know more about it to contribute. Thanks!