blocto / solana-go-sdk

Solana Golang SDK
https://blocto.github.io/solana-go-sdk/
MIT License
373 stars 96 forks source link

Create assosiated token account error #41

Closed aaetera closed 2 years ago

aaetera commented 2 years ago

Starting solana-go-sdk-main\examples\tour\create-associated-token-account\main.go file (on Devnet rpc endpoint) and receiving that type error: send raw tx error, err: rpc response error: {"code":-32002,"message":"Transaction simulation failed: Error processing Instruction 0: custom program error: 0x2","data":{"accounts":null,"err":{"InstructionError":[0,{"Custom":2}]},"logs":["Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]","Program log: Transfer 2039280 lamports to the associated token account","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program log: Allocate space for the associated token account","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program log: Assign the associated token account to the SPL Token program","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program log: Initialize the associated token account","Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]","Program log: Instruction: InitializeAccount","Program log: Error: Invalid Mint","Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3069 of 179470 compute units","Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x2","Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 23599 of 200000 compute units","Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: custom program error: 0x2"]}}

Is there any changes in Solana Core or other causes?

yihau commented 2 years ago

the error is Error: Invalid Mint

before you creating a token account, you should create the mint first.

there is another example will guide you to create a mint.

after your created it, you replace the mint address to yours

- var mintPubkey = common.PublicKeyFromString("29oPCpWj6QiXEipwtmXPrDJAR2P29Z6wHKpHRxEsbnSr")
+ var mintPubkey = common.PublicKeyFromString("your mint address here")
aaetera commented 2 years ago

ok, thanks u a lot