Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting token mint address from token_transfer instrcution #82

Open
majidmohsenifar opened this issue Jun 30, 2022 · 0 comments
Open

Getting token mint address from token_transfer instrcution #82

majidmohsenifar opened this issue Jun 30, 2022 · 0 comments

Comments

@majidmohsenifar
Copy link

majidmohsenifar commented Jun 30, 2022

Hi, thank you for such a great package
I have a question about how to get the token name or mint address from
token_transfer instruction, I could get the amount, source address, destination address and owner address,
but I need the token name or mint address, I would appreciate it if you could help me with that.

tokenInst, _ := token.DecodeInstruction(instruction.ResolveInstructionAccounts(&solTx.Message), instruction.Data)
	if tokenInst.TypeID.Uint8() == token.Instruction_Transfer {
		tokenTransfer, _ := tokenInst.Impl.(*token.Transfer)
		fmt.Println("amount",  *tokenTransfer.Amount)
		fmt.Println("owner", tokenTransfer.GetOwnerAccount().PublicKey.String())
		fmt.Println("sourceAccount", tokenTransfer.GetSourceAccount().PublicKey.String())
		fmt.Println("DestinationAccount", tokenTransfer.GetDestinationAccount().PublicKey.String())
                //TODO get the coin name or mint address
                fmt.Println("mint address", "how to get this?")
                fmt.Println("coin name", "how to get this?")
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant