Skip to content

Commit

Permalink
chore: add solana_signAllTransactions solana_signAndSendTransaction a…
Browse files Browse the repository at this point in the history
…nd update older methods (#70)
  • Loading branch information
zoruka authored Sep 26, 2024
1 parent 36d8347 commit 80b77b7
Showing 1 changed file with 122 additions and 31 deletions.
153 changes: 122 additions & 31 deletions docs/advanced/multichain/rpc-reference/solana-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ This method returns an Array of public keys available to sign from the wallet.

### Returns

1.`Array` - Array of accounts:
1.1. `Object`
1.1.1. `pubkey` : `String` - public key for keypair
`Array` - Array of accounts:
- `Object` :
- `pubkey` : `String` - public key for keypair

### Example

```javascript
```typescript
// Request
{
"id": 1,
Expand All @@ -47,13 +47,13 @@ This method returns an Array of public keys available to sign from the wallet.

### Returns

1.`Array` - Array of accounts:
1.1. `Object`
1.1.1. `pubkey` : `String` - public key for keypair
`Array` - Array of accounts:
- `Object` :
- `pubkey` : `String` - public key for keypair

### Example

```javascript
```typescript
// Request
{
"id": 1,
Expand All @@ -70,38 +70,80 @@ This method returns an Array of public keys available to sign from the wallet.
}
```

## 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

```javascript
// 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 to `transaction` param.
> The deprecated parameters are not compatible with versioned transactions.
### Parameters

`Object` - Signing parameters:<br />
- **[deprecated]** `feePayer` : `String` - public key of the transaction fee payer<br />
- **[deprecated]** `instructions` : `Array` of `Object` - instructions to be atomically executed:<br />
- `transaction` : `String` - base64-encoded serialized transaction<br />
- **[deprecated]** `feePayer` : `String | undefined` - public key of the transaction fee payer<br />
- **[deprecated]** `instructions` : `Array` of `Object` or `undefined` - instructions to be atomically executed:<br />
&nbsp;- `Object` - instruction<br />
&emsp;- `programId` : `String` - public key of the on chain program<br />
&emsp;- `data` : `String | undefined` - encoded calldata for instruction<br />
&emsp;- `keys` : `Array` of `Object`- account metadata used to define instructions<br />
&emsp;- `keys` : `Array` of `Object` - account metadata used to define instructions<br />
&emsp;&emsp;- `Object` - key<br />
&emsp;&emsp;&emsp;- `isSigner` : `Boolean` - true if an instruction requires a transaction signature matching `pubkey`<br />
&emsp;&emsp;&emsp;- `isWritable` : `Boolean` - true if the `pubkey` can be loaded as a read-write account<br />
&emsp;&emsp;&emsp;- `pubkey` : `String` - public key of authorized program<br />
- **[deprecated]** `recentBlockhash` : `String` - a recent blockhash<br />
- **[deprecated]** `signatures` : `Array` of `Object`, - (optional) previous partial signatures for this instruction set<br />
- **[deprecated]** `recentBlockhash` : `String | undefined` - a recent blockhash<br />
- **[deprecated]** `signatures` : `Array` of `Object` or `undefined` - (optional) previous partial signatures for this instruction set<br />
&nbsp;- `Object` - partial signature<br />
&emsp;- `pubkey` : `String` - pubkey of the signer<br />
&emsp;- `signature` : `String` - signature matching `pubkey`<br />
- `transaction` : `String`, - base64-encoded serialized transaction<br />

### Returns

1. `Object`
1.1. `signature` : `String` - corresponding signature for signed instructions
`Object`:
- `signature`: `String` - corresponding signature for signed instructions
- `transaction`?: `String | undefined` - optional: base64-encoded serialized transaction

### Example

```javascript
```typescript
// Request
{
"id": 1,
Expand All @@ -123,7 +165,7 @@ This method returns a signature over the provided instructions by the targeted p
"pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm",
"signature": "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4"
}],
"transaction": "r32f2..FD33r"
"transaction": "r32f2..FD33r"
}
}

Expand All @@ -135,39 +177,88 @@ This method returns a signature over the provided instructions by the targeted p
}
```

## solana_signMessage

This method returns a signature for the provided message from the requested signer address.
## 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

1. `Object` - Signing parameters:
1.1. `message` : `String` - the message to be signed (base58 encoded)
1.2. `pubkey` : `String` - public key of the signer
`Object` - Signing parameters:
- `transactions` : `String[]` - base64-encoded serialized list of transactions<br />

### Returns

1. `Object`
1.1. `signature` : `String` - corresponding signature for signed message
`Object`:
- `transactions` : `String[]` - base64-encoded serialized list of signed transactions in the same order as received<br />

### Example

```javascript
```typescript
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "solana_signMessage",
"method": "solana_signAllTransactions",
"params": {
"message": "37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7",
"pubkey": "AqP3MyNwDP4L1GJKYhzmaAUdrjzpqJUZjahM7kHpgavm"
"transactions": string[]
}
}

// Result
// Response
{
"id": 1,
"jsonrpc": "2.0",
"result": { signature: "2Lb1KQHWfbV3pWMqXZveFWqneSyhH95YsgCENRWnArSkLydjN1M42oB82zSd6BBdGkM9pE6sQLQf1gyBh8KWM2c4" }
"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:<br />
- `transaction` : `String` - the whole transaction serialized and encoded with base64<br />
- `sendOptions` : `Object` - options for sending the transaction<br />
- `skipPreflight` : `Boolean` - skip preflight checks<br />
- `preflightCommitment` : `'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max'` - preflight commitment level<br />
- `maxRetries` : `Number` - maximum number of retries<br />
- `minContextSlot` : `Number` - minimum context slot<br />

### Returns

`Object`:
- `signature` : `String`, - the signature of the transaction encoded with base58 used as transaction id<br />

### Example

```typescript
// 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
}
}
```

0 comments on commit 80b77b7

Please sign in to comment.