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

How can we obtain the real token receiving address? #215

Open
ygcool opened this issue May 29, 2024 · 0 comments
Open

How can we obtain the real token receiving address? #215

ygcool opened this issue May 29, 2024 · 0 comments

Comments

@ygcool
Copy link

ygcool commented May 29, 2024

tx: https://solscan.io/tx/5EuLFb4uZ21bNsEQrGw52sSTHK1RVaz4NBoLqW1sqcC6YhPnQp3SpMYmdwJNNAd3gd8iPPGNj1jA1Q9MucLMnr6Z

func decodeSPLTokenTransfer(tx *solana.Transaction) {
	// 依次解析命令,解析出的TransferChecked指令为止
	for _, inst := range tx.Message.Instructions {
		progKey, err := tx.ResolveProgramIDIndex(inst.ProgramIDIndex)
		if err != nil {
			break
		}
		fmt.Printf("progKey is %v \n", progKey)

		accounts, err := inst.ResolveInstructionAccounts(&tx.Message)
		if err != nil {
			break
		}
		decodedInst, err := token.DecodeInstruction(accounts, inst.Data)
		if err != nil {
			continue
		}
		if transferInfo, ok := decodedInst.Impl.(*token.TransferChecked); ok {
			fmt.Printf("Source %v\n", transferInfo.Accounts.Get(0).PublicKey.String())
			fmt.Printf("Destination %v\n", transferInfo.Accounts.Get(2).PublicKey.String()) // 3hL6oKH13MgJCABFKRAa2Rnd856wp78KXm11nw56vzF5
			fmt.Printf("token %v\n", transferInfo.Accounts.Get(1).PublicKey.String())
			fmt.Printf("amount %d\n", *transferInfo.Amount)
			fmt.Printf("decimals %d\n", *transferInfo.Decimals)
		}
	}
}

Destination address : 3hL6oKH13MgJCABFKRAa2Rnd856wp78KXm11nw56vzF5

But the actual receiving address is:2sAUucZzUsBZYn3ag6KHAiV3d51WSDs1k94dCLgE1Bq6

How can we obtain the real token receiving address?

thanks.

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