跳到主要内容

RPC Methods

This doc should be used as a source-of-truth and reflect the latest decisions and changes applied to the WalletConnect collection of client-to-client JSON-RPC methods for all platforms SDKs.

Definitions

  • Nullables: Fields flagged as Optional can be ommited from the payload.
  • Unless explicitly mentioned that a response requires associated data, all methods response's follow a default JSON-RPC pattern for the success and failure cases:
// Success
result: true

// Failure
error: {
"code": number,
"message": string
}

Session:

wc_sessionPropose

Used to propose a session through topic A. Requires a success response with associated data.

  • Success response is equivalent to session approval.
  • Error response is equivalent to session rejection.
  • This method might require a special timeout, because it needs end-user interaction to respond.
  • Proposer must use the relay parameter selected and sent by the responder, if different than the proposed one.

Request

// wc_sessionPropose params
{
"relays": [
{
"protocol": string,
"data": string // Optional
},
],
"proposer": {
"publicKey": string,
"metadata": Metadata
},
"requiredNamespaces": {
"<namespace_name>" : {
"chains": [string],
"methods": [string],
"events": [string],
"extension": [ // optional
{
"chains": [string],
"methods": [string],
"events": [string],
}
]
}
},
}

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | true |
| Tag | 1100 |

Response

// Success result
{
"relay": {
"protocol": string,
"data": string // Optional
},
"responderPublicKey": string,
}

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | false |
| Tag | 1101 |

wc_sessionSettle

Used to settle a session over topic B.

Request

// wc_sessionSettle params
{
"relay": {
"protocol": string,
"data": string // Optional
},
"controller": {
"publicKey": string,
"metadata": Metadata
},
"namespaces": {
"<namespace_name>" : {
"accounts": [string],
"methods": [string],
"events": [string],
"extension": [ // optional
{
"accounts": [string],
"methods": [string],
"events": [string],
}
]
}
},
"expiry": Int64, // seconds
}

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | false |
| Tag | 1102 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | false |
| Tag | 1103 |

wc_sessionUpdate

Used to update the namespaces of a session.

Request

// wc_sessionUpdate params
{
"namespaces": {
"<namespace_name>" : {
"accounts": [string],
"methods": [string],
"events": [string],
"extension": [ // optional
{
"accounts": [string],
"methods": [string],
"events": [string],
}
]
}
}
}

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1104 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1105 |

wc_sessionExtend

Used to extend the lifetime of a session.

  • The expiry is the absolute timestamp of the expiration date, in seconds.

Request

// wc_sessionExtend params
{
"expiry": number
}

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1106 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1107 |

wc_sessionRequest

Sends a CAIP-27 request to the peer client. The client should immediately reject the request and respond an error if the target session permissions doesn't include the requested method or chain ID.

Request

// wc_sessionRequest params
{
"request": {
"method": string,
"params": any
},
"chainId": string
}

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | true |
| Tag | 1108 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | false |
| Tag | 1109 |

wc_sessionEvent

Request

// wc_sessionEvent params
{
"event": {
"name": string,
"data": any
},
"chainId": string
}

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | true |
| Tag | 1110 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 300 |
| Prompt | false |
| Tag | 1111 |

wc_sessionDelete

Used to inform the peer to close and delete a session. The reason field should be a human-readable message defined by the SDK consumer to be shown on the peer's side.

Request

// wc_sessionDelete params
{
"code": Int64,
"message": string
}

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1112 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 86400 |
| Prompt | false |
| Tag | 1113 |

wc_sessionPing

Used to evaluate if peer is currently online. Timeout at 30 seconds

Request

// wc_sessionPing params
{
// empty
}

| IRN | |
| ------- | -------- |
| TTL | 30 |
| Prompt | false |
| Tag | 1114 |

Response

// Success result
true

| IRN | |
| ------- | -------- |
| TTL | 30 |
| Prompt | false |
| Tag | 1115 |