We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
rpcClient := rpc.New(rpc.DevNet_RPC) alicePrivateKey := solana.MustPrivateKeyFromBase58("") alicePubKey := solana.MustPublicKeyFromBase58("7stNT1jcpPHJhLPqVoZ9nFFZLEUwYNpy8gL4H3SYVvrj") bobPubKey := solana.MustPublicKeyFromBase58("5ps1QQxYRxfwzqH4cyBc7nMem9opxM2qsnBifb3mRtrh") // get token account tokenMintAccount := solana.MustPublicKeyFromBase58("CXk2AMBfi3TwaEL2468s6zP8xq9NxTXjp9gjMgzeUynM") aliceTokenAccount := solana.MustPublicKeyFromBase58("8xvmSNBPBBLya5nYZPkSKaGJs4rxWaerVZD1Dqjgooy6") transferInst := token.NewTransferCheckedInstructionBuilder(). SetAmount(amount). SetDecimals(6). SetSourceAccount(aliceTokenAccount). SetMintAccount(tokenMintAccount). SetDestinationAccount(bobTokenAccount). SetOwnerAccount(alicePubKey). Build() // get recent block hash recent, err := rpcClient.GetLatestBlockhash(context.Background(), rpc.CommitmentFinalized) if err != nil { panic(err) } fmt.Printf("recent block hash is %v\n", recent.Value.Blockhash) // construct a transaction to estimate gas fee tx0, err := solana.NewTransaction( []solana.Instruction{ computeBudgetPriceInst, computeBudgetLimitInst, transferInst, }, recent.Value.Blockhash, solana.TransactionPayer(alicePubKey), ) if err != nil { panic(err) } messageContent0, err := tx0.Message.MarshalBinary() if err != nil { panic(err) } base64EncodeMsg := base64.StdEncoding.EncodeToString(messageContent0) feeResult, err := rpcClient.GetFeeForMessage(context.Background(), base64EncodeMsg, rpc.CommitmentConfirmed) if err != nil { panic(err) } fmt.Printf("get message fee %v\n", *feeResult.Value) // construct the final transaction to send to blockchain tx, err := solana.NewTransaction( []solana.Instruction{ computeBudgetPriceInst, computeBudgetLimitInst, transferInst, }, recent.Value.Blockhash, solana.TransactionPayer(alicePubKey), ) if err != nil { panic(err) } // sign transaction _, err = tx.Sign( func(key solana.PublicKey) *solana.PrivateKey { if key.Equals(alicePubKey) { return &alicePrivateKey } return nil }) if err != nil { panic(err) } // get transaction sig and print it txSig, err := rpcClient.SendTransaction(context.Background(), tx) if err != nil { panic(err) }
Meet errors
panic: (*jsonrpc.RPCError)(0x14000c94f60)({ Code: (int) -32002, Message: (string) (len=99) "Transaction simulation failed: Error processing Instruction 2: invalid account data for instruction", Data: (map[string]interface {}) (len=7) { (string) (len=8) "accounts": (interface {}) <nil>, (string) (len=3) "err": (map[string]interface {}) (len=1) { (string) (len=16) "InstructionError": ([]interface {}) (len=2 cap=2) { (json.Number) (len=1) "2", (string) (len=18) "InvalidAccountData" } }, (string) (len=17) "innerInstructions": (interface {}) <nil>, (string) (len=4) "logs": ([]interface {}) (len=9 cap=16) { (string) (len=62) "Program ComputeBudget111111111111111111111111111111 invoke [1]", (string) (len=59) "Program ComputeBudget111111111111111111111111111111 success", (string) (len=62) "Program ComputeBudget111111111111111111111111111111 invoke [1]", (string) (len=59) "Program ComputeBudget111111111111111111111111111111 success", (string) (len=62) "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]", (string) (len=41) "Program log: Instruction: TransferChecked", (string) (len=38) "Program log: Error: InvalidAccountData", (string) (len=89) "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1455 of 599700 compute units", (string) (len=96) "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: invalid account data for instruction" }, (string) (len=20) "replacementBlockhash": (interface {}) <nil>, (string) (len=10) "returnData": (interface {}) <nil>, (string) (len=13) "unitsConsumed": (json.Number) (len=4) "1755" } })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Meet errors
The text was updated successfully, but these errors were encountered: