github.com/status-im/status-go@v1.1.0/services/subscriptions/README.md (about) 1 # Signal Subscriptions 2 3 This package implements subscriptions mechanics using [`signal`](../../signal) package. 4 5 It defines 3 new RPC methods in the `eth` namespace and 2 signals. 6 7 ## Methods 8 9 ###`eth_subscribeSignal` 10 Creates a new filter and subscribes to its changes via signals. 11 12 Parameters: receives the method name and parameters for the filter that is created. 13 14 Example 1: 15 ```json 16 { 17 "jsonrpc": "2.0", 18 "id": 1, 19 "method": "eth_subscribeSignal", 20 "params": ["eth_newPendingTransactionFilter", []] 21 } 22 ``` 23 24 Example 2: 25 ```json 26 { 27 "jsonrpc": "2.0", 28 "id": 2, 29 "method": "eth_subscribeSignal", 30 "params": [ 31 "shh_newMessageFilter", 32 [{ "symKeyID":"abcabcabcabc", "topics": ["0x12341234"] }] 33 ] 34 } 35 ``` 36 37 Supported filters: `shh_newMessageFilter`, `eth_newFilter`, `eth_newBlockFilter`, `eth_newPendingTransactionFilter` 38 (see [Ethereum documentation](https://github.com/ethereum/wiki/wiki/JSON-RPC) for respective parameters). 39 40 Returns: error or `subscriptionID`. 41 42 43 ###`eth_unsubscribeSignal` 44 Unsubscribes and removes one filter by its ID. 45 NOTE: Unsubscribing from a filter removes it. 46 47 Parameters: `subscriptionID` obtained from `eth_subscribeSignal` 48 Returns: error if something went wrong while unsubscribing. 49 50 51 ## Signals 52 53 1. Subscription data received 54 55 ```json 56 { 57 "type": "subscriptions.data", 58 "event": { 59 "subscription_id": "shh_0x01", 60 "data": { 61 <whisper envelope 01>, 62 <whisper envelope 02>, 63 ... 64 } 65 } 66 ``` 67 68 2. Subscription error received 69 70 ```json 71 { 72 "type": "subscriptions.error", 73 "event": { 74 "subscription_id": "shh_0x01", 75 "error_message": "can not find filter with id: 0x01" 76 } 77 } 78 ``` 79