Associated Token Account

Unlike a random token account, an associated token account (ATA) is calculated by SOL's address.

You can get an ATA like this

ata, _, err := common.FindAssociatedTokenAddress(alice.PublicKey, mintPubkey)
if err != nil {
	log.Fatalf("find ata error, err: %v", err)
}
fmt.Println("ata:", ata.ToBase58())

It always return the same result if you pass the same owner and mint

Then here is the instruction:

Associated Token Program

assotokenprog.CreateAssociatedTokenAccount(assotokenprog.CreateAssociatedTokenAccountParam{
	Funder:                 feePayer.PublicKey,
	Owner:                  alice.PublicKey,
	Mint:                   mintPubkey,
	AssociatedTokenAccount: ata,
}),

Funder is the person will pay the account's init balance

Owner is the owner of token account.

Mint is the mint which the token account will hold.

AssociatedTokenAccount is the result which returned by FindAssociatedTokenAddress

Last updated

Was this helpful?