gagliardetto / solana-go

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

Simulate transaction doesn't work #68

Open karneges opened 2 years ago

karneges commented 2 years ago

Hello, I have just found an issue with transaction simulation, I tried it with a different RPC, but the result is the same, can you help me, please? image

ivs commented 2 years ago

For some reason, the truncated response is returned, so the unmarshaled result is empty. I tried to debug lib but didn't succeed. So I'm using this code to simulate transactions (txn is the signed solana-go transaction):

    req := `
        {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "simulateTransaction",
            "params": [
                "` + txn.MustToBase64() + `",
                {"replaceRecentBlockhash": true, "encoding": "base64"}
            ]
        }`

    resp, _ := http.Post("https://api.mainnet-beta.solana.com", "application/json", strings.NewReader(req))
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))