github.com/status-im/status-go@v1.1.0/_examples/README.md (about) 1 # List of running node examples 2 3 > All code snippets are run from the root project directory. 4 5 ## Run Waku node 6 7 Running Waku node is a matter of a correct configuration. To enable Waku and JSON-RPC HTTP interface use: 8 ```shell script 9 { 10 "APIModules": "waku", 11 "HTTPEnabled": true, 12 "HTTPHost": "localhost", 13 "HTTPPort": 8545, 14 "WakuConfig": { 15 "Enabled": true 16 } 17 } 18 ``` 19 20 This command will start a Waku node using the `eth.prod` fleet: 21 ```shell script 22 $ ./build/bin/statusd -c ./_examples/waku.json 23 ``` 24 25 From now on, you can interact with Waku using HTTP interface: 26 ```shell script 27 $ curl -XPOST http://localhost:8545 -H 'Content-type: application/json' -d '{"jsonrpc":"2.0","method":"waku_info","params":[],"id":1}' 28 ``` 29 30 ## Whisper-Waku bridge 31 32 This example demonstrates how bridging between Whisper and Waku works. 33 34 First, start a Whisper node and listen to messages: 35 ```shell script 36 # start node 37 $ ./build/bin/statusd -c ./_examples/whisper.json -fleet eth.test -dir ./test-bridge-whisper -addr=:30313 38 39 # create a symmetric key 40 $ echo '{"jsonrpc":"2.0","method":"shh_generateSymKeyFromPassword","params":["test-channel"],"id":1}' | \ 41 nc -U ./test-bridge-whisper/geth.ipc 42 { 43 "jsonrpc": "2.0", 44 "id": 1, 45 "result": "7d521b2501ec6ed99787ecdec98390f141e6d823c703ad88b73a09d81b07e35e" 46 } 47 48 # create a message filter 49 $ echo '{"jsonrpc":"2.0","method":"shh_newMessageFilter","params":[{"topics": ["0xaabbccdd"], "symKeyID":"7d521b2501ec6ed99787ecdec98390f141e6d823c703ad88b73a09d81b07e35e"}],"id":1}' | \ 50 nc -U ./test-bridge-whisper/geth.ipc 51 { 52 "jsonrpc": "2.0", 53 "id": 1, 54 "result": "8fd6c01721a90c6650223f8180afe10c66ea5ab30669797d8b42d09f65a819a6" 55 } 56 ``` 57 58 In another terminal, start a Waku node and send messages: 59 ```shell script 60 $ ./build/bin/statusd -c ./_examples/waku.json -fleet eth.test -dir ./test-bridge-waku -addr=:30303 61 62 # create a symmetric key 63 $ echo '{"jsonrpc":"2.0","method":"waku_generateSymKeyFromPassword","params":["test-channel"],"id":1}' | \ 64 nc -U ./test-waku-bridge/geth.ipc 65 { 66 "jsonrpc": "2.0", 67 "id": 1, 68 "result": "1e07adfcb80c9e9853fb2c4cce3d91c17edd17ab6e950387833d64878fe91624" 69 } 70 71 # send a message 72 $ echo '{"jsonrpc":"2.0","method":"waku_post","params":[{"symKeyID":"1e07adfcb80c9e9853fb2c4cce3d91c17edd17ab6e950387833d64878fe91624", "ttl":100, "topic": "0xaabbccdd", "payload":"0x010203", "powTarget": 5.0, "powTime": 3}],"id":1}' | \ 73 nc -U ./test-waku-bridge/geth.ipc 74 { 75 "jsonrpc": "2.0", 76 "id": 1, 77 "result": "0x1832693cdb951b2cf459c9a6e98755407851af401ee1e7859a919ae95f79ef7a" 78 } 79 ``` 80 81 Finally, check messages in Whisper node: 82 ```shell script 83 $ echo '{"jsonrpc":"2.0","method":"shh_getFilterMessages","params":["8fd6c01721a90c6650223f8180afe10c66ea5ab30669797d8b42d09f65a819a6"],"id":1}' | \ 84 nc -U ./test-whisper-bridge/geth.ipc | jq . 85 { 86 "jsonrpc": "2.0", 87 "id": 1, 88 "result": [ 89 { 90 "ttl": 100, 91 "timestamp": 1582652341, 92 "topic": "0xaabbccdd", 93 "payload": "0xd31d35d36d37", 94 "padding": "0x925591dc6f6b7d01bd687700a222004e133141b7bb8048ac45d90232d8025f02292aa83befe91fe8ec46a47e7bcfb09d8f2d3529afe4e1835315351248b6735a190c9915b021e54de1975ac9d801aff9dec7bfee4cbe9245c3caca70694fa95718e17f8a5b8385bfc3e7196328cdb4fe722e49368c308c35fe73573c639a54b944bc2e35b080b9d36e7d298340bed253be3a26ac609e19df25de90fd9ab4237423772077046805f8dc3d5ad028cc602fd687e98cbb2c4226cba54b7c3e28f6d22bee510db445fe64bfcc996ddcc40423e1fc9e7fd39e2c0b838ded69c451022fe9202b386d9bd17d47d33942c60172f22ab0d38675b0d92c", 95 "pow": 17.418205980066446, 96 "hash": "0x1832693cdb951b2cf459c9a6e98755407851af401ee1e7859a919ae95f79ef7a" 97 } 98 ] 99 } 100 ``` 101