Comments (5)
what's the endpoint you're using? the error seems like a url error. the code below works fine for me
Code
package main
import (
"context"
"fmt"
"log"
"github.com/portto/solana-go-sdk/client"
"github.com/portto/solana-go-sdk/rpc"
)
func main() {
c := client.NewClient(rpc.DevnetRPCEndpoint)
nonceAccountAddr := "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx"
nonceAccount, err := c.GetNonceAccount(context.Background(), nonceAccountAddr)
if err != nil {
log.Fatalf("failed to get nonce account, err: %v", err)
}
fmt.Printf("%+v\n", nonceAccount)
}
from solana-go-sdk.
devnet SendTransaction error
I use nonce account and transfer
2022/07/24 11:47:45 failed to send tx, err: rpc response error: {"code":-32002,"message":"Transaction simulation failed: Blockhash not found","data":{"accounts":null,"err":"BlockhashNotFound","logs":[],"unitsConsumed":0}}
fromPriKey := "2iyr7kVaGscVxWZrUcjR67km71QZySyvjc6VxFM95GzMo2VaMSyc49Wd62mtoEdDoHCrhAfWcZG1bp9aGfn8Jqzb"
to := "46gDsWeTK3qf8H1Q8rJYccRnyQjAc8SHviUNh9C6bPZD"
NonceAccountAddr: "DJyNpXgggw1WGgjTVzFsNjb3fuQZVMqhoakvSBfX9LYx",
FeeAccountPriKey: "56KvDmcqnwiXJXbFnwWduuieFckQbw1sQFPyPVohGkzDwgm88fdFPR6aA3wp6jMh1gYMHjgYYPx5FvjMHAQuDkxb",
func (sol *solanaClient) SendTx(fromPriKey string, to string) (string, error) {
var amount uint64 = 1
nonceAccountPubkey := common.PublicKeyFromString(sol.solanaConfig.NonceAccountAddr)
toPublicKey := common.PublicKeyFromString(to)
nonceAccount, err := sol.Client.GetNonceAccount(context.Background(), nonceAccountPubkey.ToBase58())
if err != nil {
log.Fatalf("failed to get nonce account, err: %v", err)
return "", err
}
var feePayer, _ = types.AccountFromBase58(sol.solanaConfig.FeeAccountPriKey)
var fromUserAccount, _ = types.AccountFromBase58(fromPriKey)
tx, err := types.NewTransaction(types.NewTransactionParam{
Signers: []types.Account{feePayer, fromUserAccount},
Message: types.NewMessage(types.NewMessageParam{
FeePayer: feePayer.PublicKey,
RecentBlockhash: nonceAccount.Nonce.ToBase58(),
Instructions: []types.Instruction{
sysprog.AdvanceNonceAccount(sysprog.AdvanceNonceAccountParam{
Nonce: nonceAccountPubkey,
Auth: fromUserAccount.PublicKey,
}),
sysprog.Transfer(sysprog.TransferParam{
From: fromUserAccount.PublicKey,
To: toPublicKey,
Amount: amount,
}),
memoprog.BuildMemo(memoprog.BuildMemoParam{
Memo: []byte("use nonce"),
}),
},
}),
})
if err != nil {
log.Fatalf("failed to new a transaction, err: %v", err)
return "", err
}
sig, err := sol.Client.SendTransaction(context.Background(), tx)
if err != nil {
log.Fatalf("failed to send tx, err: %v", err)
return "", err
}
return sig, nil
}
from solana-go-sdk.
what's the endpoint you're using? the error seems like a url error. the code below works fine for me
Code
sorry, I filled in the wrong network, now it's ok.
from solana-go-sdk.
did you use the nonce account with multiple tx and send them at the same time? the error look like that.
from solana-go-sdk.
feel free to reopen this issue if you still have the problem
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.