blocto / solana-go-sdk

Solana Golang SDK
https://blocto.github.io/solana-go-sdk/
MIT License
392 stars 103 forks source link

Sign raw tx and send it #126

Open femtoeu opened 1 year ago

femtoeu commented 1 year ago

Hello! I'm trying to swap some spl token to sol and i'm using jup.ag api for that. I'm stucked at signing and sending transaction. Their api returns me swap transaction in base64, i'm storing it in swapTx variable. After that i'm signing this raw tx bytes with my account.

When i'm trying to send my signed transaction it throws this err: {2.0 1 {"code":-32602,"message":"invalid value: integer `478196`, expected a value in the range [0, 65535]","data":null}}

func (c *Client) Swap(account types.Account, quote Quote) error {
    swapTx, err := c.jupiter.Swap(jupiter.SwapRequest{
        Route:         quote,
        UserPublicKey: account.PublicKey.String(),
    })
    if err != nil {
        return err
    }

    signedTx := base58.Encode(account.Sign(swapTx))

    resp, err := c.rpcClient.RpcClient.SendTransaction(ctx, signedTx)
    if err != nil {
        return err
    }

    log.Println(resp)
}
Chief-Alchemist commented 8 months ago

Also interested in this case, have received the same error. Maybe @yihau can help?