gagliardetto / solana-go

Go SDK library and RPC client for the Solana Blockchain
Apache License 2.0
929 stars 264 forks source link

GetRecentBlockhash error #257

Closed zy166317 closed 1 week ago

zy166317 commented 2 weeks ago

panic: (*jsonrpc.RPCError)(0xc00009ac90)({ Code: (int) -32601, Message: (string) (len=16) "Method not found", Data: (interface {}) })

lphhh commented 2 weeks ago

This method is expected to be removed in solana-core v2.0. Please use getLatestBlockhash instead

prdsrm commented 2 weeks ago

Change your code to this:

recent, err := rpcClient.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)
if err != nil {
    panic(err) // don't do this, handle the error yourself
}

Maybe the examples should be updated, no?

gagliardetto commented 1 week ago

Updated the examples