Appearance
Using wallets on Solana
You can use Privy server wallets to sign messages and execute transactions on Solana or any SVM-compatible networks.
Using the SDK
To execute a Solana action with a server wallet, use the methods on the PrivyClient
's walletApi.solana
class. As a parameter to this method, pass the request to execute with the wallet.
There are currently three supported Solana methods: signMessage
, signTransaction
, and signAndSendTransaction
. View the parameters required for each method and examples below.
Field | Type | Description |
---|---|---|
walletId | string | Unique ID of the wallet to take actions with. |
idempotencyKey | string | (Optional) Idempotency key to identify a unique request. |
message | string | Uint8Array | The string or bytes to sign with the wallet. |
tsx
const {data} = await privy.walletApi.solana.signMessage({
walletId: 'insert-wallet-id',
message: 'Hello world',
});
// Get the signature and encoding from the response
const {signature, encoding} = data;
Using the REST API
To request a signature or transaction from a Solana wallet, make a POST
request to:
sh
https://api.privy.io/v1/wallets/<wallet_id>/rpc
TIP
In the request headers, make sure to include Privy's required authentication headers and headers that may be required for your app's wallet API setup.
Body
In the body of the request, include the following fields. Make sure to follow the appropriate guidance for the action you'd like to take with the wallet (signing messages, signing transactions, or signing and broadcasting transactions).
Field | Type | Description |
---|---|---|
method | 'signMessage' | RPC method to execute with the wallet. |
params | Object | Parameters for the RPC method to execute with the wallet. |
params.message | string | An encoded string serializing the message to be signed with the wallet. |
params.encoding | 'base64' | The encoding format for params.message . Currently, only 'base64' is supported. |
Response
If the action is allowed, Privy will send the following fields in the response body:
Field | Type | Description |
---|---|---|
method | 'signMessage' | The RPC method executed with the wallet. |
data | Object | Outputs for the RPC method executed with the wallet. |
data.signature | string | An encoded string serializing the signature produced by the user's wallet. |
data.encoding | 'base64' | The encoding format for the returned signature . Currently, only 'base64' is supported. |
Examples
As an example, a sample request to take an action with a wallet might look like the following:
bash
$ curl --request POST https://api.privy.io/v1/wallets/<wallet_id>/rpc \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H "privy-authorization-signature: <authorization-signature-for-request>" \
-H 'Content-Type: application/json' \
-d '{
"method": "signMessage",
"params": {
"message": "insert-base-64-encoded-message",
"encoding": "base64"
}
}'
A successful response will look like the following:
json
{
"method": "signMessage",
"data": {
"signature": "base64-encoded-signature",
"encoding": "base64"
}
}