Comments (7)
I've check your fee payer's balance, it shows 0.
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/client/rpc"
"github.com/portto/solana-go-sdk/common"
"github.com/portto/solana-go-sdk/types"
)
var feePayer = types.AccountFromPrivateKeyBytes([]byte{171, 198, 211, 210, 224, 159, 123, 194, 109, 67, 84, 90, 248, 134, 20, 25, 32, 185, 1, 216, 114, 253, 61, 71, 211, 88, 58, 242, 27, 146, 27, 137, 19, 110, 184, 252, 165, 125, 39, 128, 238, 132, 66, 123, 192, 136, 48, 33, 92, 107, 3, 44, 179, 4, 191, 172, 226, 212, 98, 118, 113, 163, 233, 105})
var alice = types.AccountFromPrivateKeyBytes([]byte{171, 198, 211, 210, 224, 159, 123, 194, 109, 67, 84, 90, 248, 134, 20, 25, 32, 185, 1, 216, 114, 253, 61, 71, 211, 88, 58, 242, 27, 146, 27, 137, 19, 110, 184, 252, 165, 125, 39, 128, 238, 132, 66, 123, 192, 136, 48, 33, 92, 107, 3, 44, 179, 4, 191, 172, 226, 212, 98, 118, 113, 163, 233, 105})
var mintPubkey = common.PublicKeyFromString("2JrfrWiKQTQKiRh6pUv8YogGwxpZcHNJTVW6E9JdFx5v")
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
feePayerBalance, err := c.GetBalance(context.Background(), feePayer.PublicKey.ToBase58())
if err != nil {
log.Fatalf("failed to get balance, err: %v", err)
}
fmt.Printf("%v, balance: %v\n", feePayer.PublicKey.ToBase58(), feePayerBalance)
}
also I've check your mint. your mint hasn't initialized either.
https://explorer.solana.com/address/2JrfrWiKQTQKiRh6pUv8YogGwxpZcHNJTVW6E9JdFx5v?cluster=devnet
I guess in previous example I used http://localhost:8899 as endpoint
in this example I forgot to change it. It used devnet endpoint.
so I think you can do
- c := client.NewClient(rpc.DevnetRPCEndpoint)
+ c := client.NewClient("http://localhost:8899")
and it will work
from solana-go-sdk.
Thanks. Understood the issue.
from solana-go-sdk.
It is my fault, I forgot to change all example to use the same endpoint.
I've modified it. Thank for your issue!
from solana-go-sdk.
I guess your fee payer(funder) don't have enough balance to create token account.
It will cost you 0.00203928 SOL for a token account.
also remember check your connection is the same
from solana-go-sdk.
Just cross-checked. My fee payer has 7.998528400 SOL balance.
And the connection is the same too.
from solana-go-sdk.
would you share your code to me?
not sure how you pass these accounts into instruction.
from solana-go-sdk.
This is my code. It is taken from the documents you've created.
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/client/rpc"
"github.com/portto/solana-go-sdk/common"
"github.com/portto/solana-go-sdk/program/assotokenprog"
"github.com/portto/solana-go-sdk/types"
)
var feePayer = types.AccountFromPrivateKeyBytes([]byte{171, 198, 211, 210, 224, 159, 123, 194, 109, 67, 84, 90, 248, 134, 20, 25, 32, 185, 1, 216, 114, 253, 61, 71, 211, 88, 58, 242, 27, 146, 27, 137, 19, 110, 184, 252, 165, 125, 39, 128, 238, 132, 66, 123, 192, 136, 48, 33, 92, 107, 3, 44, 179, 4, 191, 172, 226, 212, 98, 118, 113, 163, 233, 105})
var alice = types.AccountFromPrivateKeyBytes([]byte{171, 198, 211, 210, 224, 159, 123, 194, 109, 67, 84, 90, 248, 134, 20, 25, 32, 185, 1, 216, 114, 253, 61, 71, 211, 88, 58, 242, 27, 146, 27, 137, 19, 110, 184, 252, 165, 125, 39, 128, 238, 132, 66, 123, 192, 136, 48, 33, 92, 107, 3, 44, 179, 4, 191, 172, 226, 212, 98, 118, 113, 163, 233, 105})
var mintPubkey = common.PublicKeyFromString("2JrfrWiKQTQKiRh6pUv8YogGwxpZcHNJTVW6E9JdFx5v")
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
ata, _, err := common.FindAssociatedTokenAddress(alice.PublicKey, mintPubkey)
if err != nil {
log.Fatalf("find ata error, err: %v", err)
}
fmt.Println("ata:", ata.ToBase58())
res, err := c.GetRecentBlockhash(context.Background())
if err != nil {
log.Fatalf("get recent block hash error, err: %v\n", err)
}
rawTx, err := types.CreateRawTransaction(types.CreateRawTransactionParam{
Instructions: []types.Instruction{
assotokenprog.CreateAssociatedTokenAccount(
feePayer.PublicKey,
alice.PublicKey,
mintPubkey,
),
},
Signers: []types.Account{feePayer},
FeePayer: feePayer.PublicKey,
RecentBlockHash: res.Blockhash,
})
if err != nil {
log.Fatalf("generate tx error, err: %v\n", err)
}
txhash, err := c.SendRawTransaction(context.Background(), rawTx)
if err != nil {
log.Fatalf("send raw tx error, err: %v\n", err)
}
log.Println("txhash:", txhash)
}
I am able to generate the ATA following which I get the error.
ata: HXjpqhEnEMUC2AWTEs4uampaMPVPgKoFqDNR78GLcBQa
2021/10/04 15:36:03 send raw tx error, err: rpc response error: {"code":-32002,"message":"Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.","data":{"accounts":null,"err":"AccountNotFound","logs":[]}}
exit status 1
This was my exact error.
from solana-go-sdk.
Related Issues (20)
- how to decode the instruction.data? HOT 1
- how to getTokenAccountOwner HOT 3
- how to get the mint name of 7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx HOT 3
- How to get SOL transfers from a response getTransaction() HOT 2
- creating a new wallet and other things HOT 1
- Cant understand how to give instructions for Launchmynft.io
- Cant understand how to give instructions for raydium swap HOT 2
- How to create stake account? HOT 2
- [HELP] Deserializing AccountData data field into address lookup tables
- UpdateMetadataAccount returning deprecated error HOT 2
- Any plan to support anchor? HOT 3
- Websocket API support
- How do I initiate a USDT SPL transfer transaction? HOT 4
- Add Priority Fee to Transaction HOT 1
- How do I initiate a USDT SPL transfer transaction? HOT 3
- An optimization suggestion about transaction serialization
- Add unitsConsumed field to RPC simulateTransaction response HOT 1
- GetSlotLeader HOT 2
- Add GetSlotLeaders HOT 1
- Add GetProgramAccounts method to the client folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana-go-sdk.