Skip to content

Commit 635ec6b

Browse files
Update Stacks RPC documentation with 6 new methods
- Add getAddresses method for retrieving active account addresses - Update stx_transferStx method with network parameter and new format - Add stx_signTransaction method for signing transactions with optional broadcast - Update stx_signMessage method with messageType, domain, and network parameters - Add stx_signStructuredMessage method for SIP-018 structured signing - Add stx_callContract method for contract interactions All methods follow the existing documentation format with proper parameter tables, request/response examples, and consistent formatting. Co-Authored-By: [email protected] <[email protected]>
1 parent 6672c80 commit 635ec6b

File tree

1 file changed

+195
-25
lines changed

1 file changed

+195
-25
lines changed

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

Lines changed: 195 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,257 @@ description: Stacks JSON-RPC Methods
55

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

8+
## Core Methods (common)
89

9-
## stx_transferStx
10+
### getAddresses
1011

11-
Simple STX transfer, request a transfer of STX tokens. Wallet signs and executes the transaction.
12+
Retrieve active account addresses; primarily Stacks-focused.
1213

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

1554
```json
1655
{
1756
"id": 1,
1857
"jsonrpc": "2.0",
1958
"method": "stx_transferStx",
2059
"params": {
21-
"sender": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
2260
"recipient": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
2361
"amount": "100000000000",
24-
"memo": ""
62+
"memo": "",
63+
"network": "mainnet"
2564
}
2665
}
2766
```
2867

29-
### Parameters
68+
#### Parameters
3069

3170
| Parameter | Required? | Data Type | Description |
3271
|-----------|------|-----------|-------------|
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) |
72+
| `recipient` | Required | `string` | Stacks address |
73+
| `amount` | Required | `string` | micro-STX (uSTX) |
3674
| `memo` | Optional | `string` | Memo string to be included with the transfer transaction |
75+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
76+
77+
#### Response
78+
79+
```json
80+
{
81+
"jsonrpc": "2.0",
82+
"id": 1,
83+
"result": {
84+
"txid": "0x…",
85+
"transaction": "0x…"
86+
}
87+
}
88+
```
3789

38-
### Response
90+
### stx_signTransaction
91+
92+
Sign a Stacks transaction. Optional broadcast.
93+
94+
#### Request
95+
96+
```json
97+
{
98+
"id": 1,
99+
"jsonrpc": "2.0",
100+
"method": "stx_signTransaction",
101+
"params": {
102+
"transaction": "0x…",
103+
"broadcast": false,
104+
"network": "mainnet"
105+
}
106+
}
107+
```
108+
109+
#### Parameters
110+
111+
| Parameter | Required? | Data Type | Description |
112+
|-----------|------|-----------|-------------|
113+
| `transaction` | Required | `string` | hex transaction |
114+
| `broadcast` | Optional | `boolean` | default false |
115+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
116+
117+
#### Response
39118

40119
```json
41120
{
42121
"jsonrpc": "2.0",
43122
"id": 1,
44123
"result": {
45-
"txid": "stack_tx_id",
46-
"transaction": "raw_tx_hex"
124+
"signature": "0x…",
125+
"transaction": "0x…",
126+
"txid": "0x…"
47127
}
48128
}
49129
```
50130

51-
- `txid` - is used to identify the transaction on the explorer
52-
- `transaction` - hex-encoded raw transaction
131+
**Note:** `txid` is present if broadcast=true
53132

54-
## stx_signMessage
133+
### stx_signMessage
55134

56-
For signing a message with wallet users private key.
135+
Sign arbitrary message; supports structured (SIP-018).
57136

58-
### Request
137+
#### Request
59138

60139
```json
61140
{
62141
"id": 1,
63142
"jsonrpc": "2.0",
64143
"method": "stx_signMessage",
65144
"params": {
66-
"address": "SP3F7GQ48JY59521DZEE6KABHBF4Q33PEYJ823ZXQ",
67-
"message": "message"
145+
"message": "message",
146+
"messageType": "utf8",
147+
"network": "mainnet"
148+
}
149+
}
150+
```
151+
152+
#### Parameters
153+
154+
| Parameter | Required? | Data Type | Description |
155+
|-----------|------|-----------|-------------|
156+
| `message` | Required | `string` | message to be signed |
157+
| `messageType` | Optional | `string` | "utf8" \| "structured" (default utf8) |
158+
| `domain` | Optional | `any` | required if structured |
159+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
160+
161+
#### Response
162+
163+
```json
164+
{
165+
"jsonrpc": "2.0",
166+
"id": 1,
167+
"result": {
168+
"signature": "0x…"
169+
}
170+
}
171+
```
172+
173+
### stx_signStructuredMessage
174+
175+
Domain-bound structured signing (SIP-018).
176+
177+
#### Request
178+
179+
```json
180+
{
181+
"id": 1,
182+
"jsonrpc": "2.0",
183+
"method": "stx_signStructuredMessage",
184+
"params": {
185+
"message": "message",
186+
"domain": "domain"
68187
}
69188
}
70189
```
71190

72-
### Parameters
191+
#### Parameters
73192

74193
| Parameter | Required? | Data Type | Description |
75194
|-----------|------|-----------|-------------|
76-
| `address` | Required | `string` | The stacks address of sender |
77-
| `message` | Required | `string` | Utf-8 string representing the message to be signed by the wallet |
195+
| `message` | Required | `string \| object` | message to be signed |
196+
| `domain` | Required | `string \| object` | domain for structured signing |
78197

79-
### Response
198+
#### Response
80199

81200
```json
82201
{
83202
"jsonrpc": "2.0",
84203
"id": 1,
85204
"result": {
86-
"signature": "0x1234..."
205+
"signature": "0x…",
206+
"publicKey": "0x04…"
207+
}
208+
}
209+
```
210+
211+
**Note:** `publicKey` is optional
212+
213+
### stx_callContract
214+
215+
Build, sign, and optionally broadcast a contract call.
216+
217+
#### Request
218+
219+
```json
220+
{
221+
"id": 1,
222+
"jsonrpc": "2.0",
223+
"method": "stx_callContract",
224+
"params": {
225+
"contract": "SP000000000000000000002Q6VF78.pox",
226+
"functionName": "stack-stx",
227+
"functionArgs": ["u1000000", "0x…"],
228+
"network": "mainnet",
229+
"fee": "1000",
230+
"nonce": "1",
231+
"anchorMode": "any",
232+
"broadcast": true
87233
}
88234
}
89235
```
90236

91-
- `signature` - The signature of the message
237+
#### Parameters
238+
239+
| Parameter | Required? | Data Type | Description |
240+
|-----------|------|-----------|-------------|
241+
| `contract` | Required | `string` | contract identifier |
242+
| `functionName` | Required | `string` | function name to call |
243+
| `functionArgs` | Required | `string[]` | function arguments |
244+
| `network` | Optional | `string` | "mainnet" \| "testnet" \| "devnet" |
245+
| `fee` | Optional | `string` | transaction fee |
246+
| `nonce` | Optional | `string` | transaction nonce |
247+
| `anchorMode` | Optional | `string` | "any" \| "onChainOnly" \| "offChainOnly" |
248+
| `broadcast` | Optional | `boolean` | whether to broadcast the transaction |
249+
250+
#### Response
251+
252+
```json
253+
{
254+
"jsonrpc": "2.0",
255+
"id": 1,
256+
"result": {
257+
"txid": "0x…",
258+
"transaction": "0x…"
259+
}
260+
}
261+
```

0 commit comments

Comments
 (0)