Solana
solana_getAccounts
This method returns an Array of public keys available to sign from the wallet.
Parameters
none
Returns
Array
- Array of accounts:
Object
:pubkey
:String
- public key for keypair
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_getAccounts",
"params": {}
}
// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": [{ "pubkey": "722RdWmHC5TGXBjTejzNjbc8xEiduVDLqZvoUGz6Xzbp" }]
}
solana_requestAccounts
This method returns an Array of public keys available to sign from the wallet.
Parameters
none
Returns
Array
- Array of accounts:
Object
:pubkey
:String
- public key for keypair
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_getAccounts",
"params": {}
}
// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": [{ "pubkey": "722RdWmHC5TGXBjTejzNjbc8xEiduVDLqZvoUGz6Xzbp" }]
}
solana_signMessage
This method returns a signature for the provided message from the requested signer address.
Parameters
Object
- Signing parameters:
message
:String
- the message to be signed (base58 encoded)pubkey
:String
- public key of the signer
Returns
Object
:
signature
:String
- corresponding signature for signed message
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_signMessage",
"params": {
"message": "37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7",
"pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm"
}
}
// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": { signature: "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4" }
}
solana_signTransaction
This method returns a signature over the provided instructions by the targeted public key.
[!WARNING]
Refer always totransaction
param. The deprecated parameters are not compatible with versioned transactions.
Parameters
Object
- Signing parameters:
transaction
:String
- base64-encoded serialized transaction- [deprecated]
feePayer
:String | undefined
- public key of the transaction fee payer - [deprecated]
instructions
:Array
ofObject
orundefined
- instructions to be atomically executed:
-Object
- instruction
-programId
:String
- public key of the on chain program
-data
:String | undefined
- encoded calldata for instruction
-keys
:Array
ofObject
- account metadata used to define instructions
-Object
- key
-isSigner
:Boolean
- true if an instruction requires a transaction signature matchingpubkey
-isWritable
:Boolean
- true if thepubkey
can be loaded as a read-write account
-pubkey
:String
- public key of authorized program - [deprecated]
recentBlockhash
:String | undefined
- a recent blockhash - [deprecated]
signatures
:Array
ofObject
orundefined
- (optional) previous partial signatures for this instruction set
-Object
- partial signature
-pubkey
:String
- pubkey of the signer
-signature
:String
- signature matchingpubkey
Returns
Object
:
signature
:String
- corresponding signature for signed instructionstransaction
?:String | undefined
- optional: base64-encoded serialized transaction
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_signTransaction",
"params": {
"feePayer": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm",
"instructions": [{
"programId": "Vote111111111111111111111111111111111111111",
"data": "37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7",
"keys": [{
"isSigner": true,
"isWritable": true,
"pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm"
}]
}],
"recentBlockhash": "2bUz6wu3axM8cDDncLB5chWuZaoscSjnoMD2nVvC1swe",
"signatures": [{
"pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm",
"signature": "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4"
}],
"transaction": "r32f2..FD33r"
}
}
// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": { signature: "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4" }
}
solana_signAllTransactions
This method is responsible for signing a list of transactions. The wallet must sign all transactions and return the signed transactions in the same order as received. Wallets must sign all transactions or return an error if it is not possible to sign any of them.
Parameters
Object
- Signing parameters:
transactions
:String[]
- base64-encoded serialized list of transactions
Returns
Object
:
transactions
:String[]
- base64-encoded serialized list of signed transactions in the same order as received
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_signAllTransactions",
"params": {
"transactions": string[]
}
}
// Response
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"transactions": string[]
}
}
solana_signAndSendTransaction
This method is responsible for signing and sending a transaction to the Solana network. The wallet must sent the transaction and return the signature that can be used as a transaction id.
Parameters
Object
- transaction and options:
transaction
:String
- the whole transaction serialized and encoded with base64sendOptions
:Object
- options for sending the transaction
skipPreflight
:Boolean
- skip preflight checkspreflightCommitment
:'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max'
- preflight commitment levelmaxRetries
:Number
- maximum number of retriesminContextSlot
:Number
- minimum context slot
Returns
Object
:
signature
:String
, - the signature of the transaction encoded with base58 used as transaction id
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_signAndSendTransaction",
"params": {
"transaction": string,
"sendOptions": {
"skipPreflight"?: boolean,
"preflightCommitment"?: 'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max',
"maxRetries"?: number,
"minContextSlot"?: number,
}
}
}
// Response
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"signature": string
}
}