Skip to content

Commit c707824

Browse files
authored
Merge pull request #607 from reown-com/devin/1756395382-update-stacks-rpc-docs
Update Stacks RPC documentation with 6 new methods
2 parents 32f30c0 + 226c6c2 commit c707824

File tree

1 file changed

+169
-35
lines changed

1 file changed

+169
-35
lines changed

advanced/multichain/rpc-reference/stacks-rpc.mdx

Lines changed: 169 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,51 @@ description: Stacks JSON-RPC Methods
66

77
These are the methods that wallets should implement to handle Stacks transfers and messages via WalletConnect.
88

9-
## stx_transferStx
9+
## Core Methods (common)
1010

11-
Simple STX transfer, request a transfer of STX tokens. Wallet signs and executes the transaction.
11+
### stx_getAddresses
1212

13-
### Request
13+
Retrieve active account addresses; primarily Stacks-focused.
14+
15+
#### Request
16+
17+
```json
18+
{
19+
"id": 1,
20+
"jsonrpc": "2.0",
21+
"method": "stx_getAddresses",
22+
"params": {}
23+
}
24+
```
25+
26+
#### Response
27+
28+
```json
29+
{
30+
"jsonrpc": "2.0",
31+
"id": 1,
32+
"result": {
33+
"addresses": [
34+
{
35+
"symbol": "STX",
36+
"address": "SP…"
37+
}
38+
]
39+
}
40+
}
41+
```
42+
43+
**Notes:**
44+
- Use this first to select the wallet's active address.
45+
- Filter on `symbol: "STX"` or by address prefix (SP for mainnet, ST for testnet).
46+
47+
## Stacks Methods
48+
49+
### stx_transferStx
50+
51+
Transfer STX.
52+
53+
#### Request
1454

1555
```json
1656
{
@@ -21,41 +61,83 @@ Simple STX transfer, request a transfer of STX tokens. Wallet signs and executes
2161
"sender": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
2262
"recipient": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
2363
"amount": "100000000000",
24-
"memo": ""
64+
"memo": "",
65+
"network": "mainnet"
2566
}
2667
}
2768
```
2869

29-
### Parameters
70+
#### Parameters
3071

3172
| Parameter | Required? | Data Type | Description |
3273
|-----------|------|-----------|-------------|
33-
| `sender` | Required | `string` | The stacks address of sender |
34-
| `recipient` | Required | `string` | The STX address of the recipient |
35-
| `amount` | Required | `number \| string` | Amount of STX tokens to transfer in microstacks (BigInt constructor compatible) |
74+
| `sender` | Required | `string` | The stacks address of sender (required for multi-account scenarios) |
75+
| `recipient` | Required | `string` | Stacks address |
76+
| `amount` | Required | `string` | micro-STX (uSTX) |
3677
| `memo` | Optional | `string` | Memo string to be included with the transfer transaction |
78+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
3779

38-
### Response
80+
#### Response
3981

4082
```json
4183
{
4284
"jsonrpc": "2.0",
4385
"id": 1,
4486
"result": {
45-
"txid": "stack_tx_id",
46-
"transaction": "raw_tx_hex"
87+
"txid": "1234567890abcdef1234567890abcdef12345678",
88+
"transaction": "0x…"
4789
}
4890
}
4991
```
5092

51-
- `txid` - is used to identify the transaction on the explorer
52-
- `transaction` - hex-encoded raw transaction
93+
### stx_signTransaction
5394

54-
## stx_signMessage
95+
Sign a Stacks transaction. Optional broadcast.
5596

56-
For signing a message with wallet users private key.
97+
#### Request
5798

58-
### Request
99+
```json
100+
{
101+
"id": 1,
102+
"jsonrpc": "2.0",
103+
"method": "stx_signTransaction",
104+
"params": {
105+
"transaction": "0x…",
106+
"broadcast": false,
107+
"network": "mainnet"
108+
}
109+
}
110+
```
111+
112+
#### Parameters
113+
114+
| Parameter | Required? | Data Type | Description |
115+
|-----------|------|-----------|-------------|
116+
| `transaction` | Required | `string` | hex transaction |
117+
| `broadcast` | Optional | `boolean` | default false |
118+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
119+
120+
#### Response
121+
122+
```json
123+
{
124+
"jsonrpc": "2.0",
125+
"id": 1,
126+
"result": {
127+
"signature": "0x…",
128+
"transaction": "0x…",
129+
"txid": "1234567890abcdef1234567890abcdef12345678"
130+
}
131+
}
132+
```
133+
134+
**Note:** `txid` is present if broadcast=true
135+
136+
### stx_signMessage
137+
138+
Sign arbitrary message; supports structured (SIP-018).
139+
140+
#### Request
59141

60142
```json
61143
{
@@ -64,67 +146,119 @@ For signing a message with wallet users private key.
64146
"method": "stx_signMessage",
65147
"params": {
66148
"address": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
67-
"message": "message"
149+
"message": "message",
150+
"messageType": "utf8",
151+
"network": "mainnet",
152+
"domain": "example.com"
68153
}
69154
}
70155
```
71156

72-
### Parameters
157+
#### Parameters
73158

74159
| Parameter | Required? | Data Type | Description |
75160
|-----------|------|-----------|-------------|
76161
| `address` | Required | `string` | The stacks address of sender |
77162
| `message` | Required | `string` | Utf-8 string representing the message to be signed by the wallet |
163+
| `messageType` | Optional | `string` | Type of message for signing: `utf8` for basic string or `structured` for structured data |
164+
| `network` | Optional | `string` | Network for signing: `mainnet`, `testnet`, `signet`, `devnet` (note: redundant since chainId is provided) |
165+
| `domain` | Optional | `string` | Domain tuple per SIP-018 (for structured messages only) |
78166

79-
### Response
167+
#### Response
80168

81169
```json
82170
{
83171
"jsonrpc": "2.0",
84172
"id": 1,
85173
"result": {
86-
"signature": "0x1234..."
174+
"signature": "0x…"
87175
}
88176
}
89177
```
90178

91-
- `signature` - The signature of the message
179+
### stx_signStructuredMessage
180+
181+
Domain-bound structured signing (SIP-018).
182+
183+
#### Request
184+
185+
```json
186+
{
187+
"id": 1,
188+
"jsonrpc": "2.0",
189+
"method": "stx_signStructuredMessage",
190+
"params": {
191+
"message": "message",
192+
"domain": "domain"
193+
}
194+
}
195+
```
196+
197+
#### Parameters
198+
199+
| Parameter | Required? | Data Type | Description |
200+
|-----------|------|-----------|-------------|
201+
| `message` | Required | `string \| object` | message to be signed |
202+
| `domain` | Required | `string \| object` | domain for structured signing |
92203

204+
#### Response
93205

206+
```json
207+
{
208+
"jsonrpc": "2.0",
209+
"id": 1,
210+
"result": {
211+
"signature": "0x…",
212+
"publicKey": "0x04…"
213+
}
214+
}
215+
```
94216

217+
**Note:** `publicKey` is optional
95218

96-
## stx_getAddresses
219+
### stx_callContract
97220

98-
For requesting the wallet addresses
221+
Wrapper method for `stx_signTransaction` that calls a Stacks contract.
99222

100-
### Request
223+
#### Request
101224

102225
```json
103226
{
104227
"id": 1,
105228
"jsonrpc": "2.0",
106-
"method": "stx_getAddresses",
229+
"method": "stx_callContract",
230+
"params": {
231+
"contract": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ.my-contract",
232+
"functionName": "get-balance",
233+
"functionArgs": []
234+
}
107235
}
108236
```
109237

110-
### Response
238+
#### Parameters
239+
240+
| Parameter | Required? | Data Type | Description |
241+
|-----------|------|-----------|-------------|
242+
| `contract` | Required | `string` | Fully qualified contract identifier, including Stacks address and contract name |
243+
| `functionName` | Required | `string` | Name of the function to call |
244+
| `functionArgs` | Required | `string[]` | Arguments to pass to the contract function, encoded as strings |
245+
246+
#### Response
247+
111248
```json
112249
{
113250
"jsonrpc": "2.0",
114251
"id": 1,
115252
"result": {
116-
"accounts": [
117-
{
118-
"address": "SP23....",
119-
"publicKey": "ab12031..."
120-
}
121-
]
253+
"txid": "stack_tx_id",
254+
"transaction": "raw_tx_hex"
122255
}
123256
}
124257
```
125258

126-
- `accounts`: The connected accounts with their address and publicKey
259+
- `txid` - is used to identify the transaction on the explorer
260+
- `transaction` - hex-encoded raw transaction
127261

262+
## Session Properties
128263

129-
### Session Properties
130-
In a connection request, it is recommended to serialize the response to `getAddresses` in `session.sessionProperties.stacks_getAddresses`. This allows dapps to consume an active session without requiring a context switch to re-request all addresses and associated public keys from the wallet.
264+
In a connection request, it is recommended to serialize the response to `stx_getAddresses` in `session.sessionProperties.stacks_getAddresses`. This allows dapps to consume an active session without requiring a context switch to re-request all addresses and associated public keys from the wallet.

0 commit comments

Comments
 (0)