github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/README.md (about) 1 # W3bstream 2 3 ## Overview 4 5 W3bStream is a general framework for connecting data generated by devices and machines in the physical world to the blockchain world. In a nutshell, W3bStream uses the IoTeX blockchain to orchestrate a decentralized network of gateways (i.e., W3bStream nodes) that streams encrypted data from IoT devices and machines and generates proofs of real-world facts to different blockchains. An overview graphic of W3bstream is 6 7 8 ![image](https://user-images.githubusercontent.com/448293/196618039-365ab2b7-f50a-49c8-a02d-c28e48acafcb.png) 9 10 ## Arch 11 12 ![w3bstream](__doc__/modules_and_dataflow.png) 13 14 ## 🚀 Why W3bstream? 15 16 💨 Accelerated Go-to-Market (GTM) Time: W3bstream streamlines the development process for building decentralized privacy-preserving IoT and machine applications (DePINs), resulting in faster GTM and lower development costs. 17 18 💪 Trustworthy Decentralized Architecture: W3bstream's decentralized architecture offers transparent application logic, instilling trust in users and eliminating the need for centralized computational oracles like Google Cloud and AWS. 19 20 🤝 Enhanced Composability: W3bstream's permissionless infrastructure can be freely composed with various devices and dApps, fostering collaboration, innovation, and enhanced interoperability. 21 22 🔒 Privacy Protection (Ownership): W3bstream supports Zero-Knowledge technologies, providing end-to-end protection for user data and ensuring that privacy is maintained throughout the entire process, unlike centralized computational oracles that may compromise users' data privacy. 23 24 ## Run W3bstream with prebuilt docker images 25 26 ### Run W3bstream node with W3bstream Studio 27 Check it out here [w3bstream-studio](https://github.com/machinefi/w3bstream-studio#run-w3bstream-node-with-prebuilt-docker-images). 28 29 ### Run W3bstream node without W3bstream Studio 30 31 Make a path for w3bstream node. In the path, run the following command 32 33 ```bash 34 curl https://raw.githubusercontent.com/machinefi/w3bstream/main/docker-compose.yaml > docker-compose.yaml 35 ``` 36 37 Edit the config in the `yaml` file if needed. Then run 38 39 ```bash 40 docker-compose -p w3bstream -f ./docker-compose.yaml up -d 41 ``` 42 43 Your node should be up and running. 44 45 Please note: the docker images are hosted at [GitHub Docker Registry](https://github.com/machinefi/w3bstream/pkgs/container/w3bstream) 46 47 ## Getting started 48 49 ### Start with W3bstream Studio 50 If you run W3bstream node with **W3bstream Studio**, You can use Metamask to log in to [localhost:3000](localhost:3000) and create a "Hello World" project. 51 You can follow the [doc](https://docs.w3bstream.com/get-started/deploying-an-applet) 52 53 ### Start with admin user 54 1. Login with admin 55 56 ```sh 57 # the default password is "iotex.W3B.admin" 58 echo '{"username":"admin","password":"iotex.W3B.admin"}' | http put :8888/srv-applet-mgr/v0/login 59 ``` 60 61 output like 62 63 ```json 64 { 65 "accountID": "${account_id}", 66 "expireAt": "2022-09-23T07:20:08.099601+08:00", 67 "issuer": "srv-applet-mgr", 68 "token": "${token}" 69 } 70 ``` 71 72 export token for reuse. 73 74 ```sh 75 export TOK=${token} 76 ``` 77 78 2. Create hello world project with default config 79 80 ```sh 81 export PROJECTNAME=${project_name} 82 echo '{"name":"'$PROJECTNAME'"}' | http post :8888/srv-applet-mgr/v0/project -A bearer -a $TOK 83 ``` 84 85 output like 86 87 ```json 88 { 89 "accountID": "11276794515805192", 90 "channelState": true, 91 "createdAt": "2023-05-03T05:39:17.835566714Z", 92 "database": { 93 "schemas": [ 94 { 95 "schema": "public" 96 } 97 ] 98 }, 99 "envs": { 100 "env": null 101 }, 102 "name": "demo", 103 "projectID": "11276839333473280", 104 "updatedAt": "2023-05-03T05:39:17.835567047Z" 105 } 106 ``` 107 108 3. Create and deploy applet under project created previously 109 110 ```sh 111 curl https://raw.githubusercontent.com/machinefi/w3bstream-wasm-golang-sdk/main/examples/wasms/log.wasm -o log.wasm 112 export WASMFILE=./log.wasm 113 export WASMNAME=log.wasm 114 export APPLETNAME=log 115 http --form post :8888/srv-applet-mgr/v0/applet/x/$PROJECTNAME file@$WASMFILE info='{"appletName":"'$APPLETNAME'","wasmName":"'$WASMNAME'"}' -A bearer -a $TOK 116 ``` 117 118 output like 119 120 ```json 121 { 122 "appletID": "11276843999120385", 123 "createdAt": "2023-05-03T06:55:14.131370253Z", 124 "instance": { 125 "appletID": "11276843999120385", 126 "createdAt": "2023-05-03T06:55:14.146653045Z", 127 "instanceID": "11276843999135746", 128 "state": "STARTED", 129 "updatedAt": "2023-05-03T06:55:14.146653128Z" 130 }, 131 "name": "11276843999120386", 132 "projectID": "11276843314064388", 133 "resource": { 134 "createdAt": "2023-05-03T06:55:14.112226878Z", 135 "md5": "30b11f90b1d7453474496f5cc42f0869", 136 "path": "30b11f90b1d7453474496f5cc42f0869", 137 "resourceID": "11276843999092744", 138 "updatedAt": "2023-05-03T06:55:14.112227086Z" 139 }, 140 "resourceID": "11276843999092744", 141 "updatedAt": "2023-05-03T06:55:14.131370336Z" 142 } 143 ``` 144 145 4. Register publisher 146 147 ```sh 148 export PUBNAME=mobile # device name 149 export PUBKEY=mn20130503 # device unique identity, usually it is device's machine number or serial number 150 echo '{"name":"'$PUBNAME'", "key":"'$PUBKEY'"}' | http post :8888/srv-applet-mgr/v0/publisher/x/$PROJECTNAME -A bearer -a $TOK 151 ``` 152 153 output like 154 155 ```sh 156 { 157 "createdAt": "2023-05-03T16:13:16.343103+08:00", 158 "key": "mn20130503", 159 "name": "mobile", 160 "projectID": "11276843314064388", 161 "publisherID": "155392036869560322", 162 "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJQYXlsb2FkIjoiMTU1MzkyMDM2ODY5NTYwMzIyIiwiaXNzIjoiaW90ZXgtdzNic3RyZWFtIn0.OHME3ij5MaJcvekctgYvosQ8DIo-K-guQbYPbQAdyYo", 163 "updatedAt": "2023-05-03T16:13:16.343103+08:00" 164 } 165 ``` 166 167 5. Publish event through http 168 169 ```sh 170 export TOPIC=${pub_topic} ## intact project name(required) -- you can get it from t_project.f_name 171 export PUBTOK=${publisher_token} ## created before(required) 172 export PAYLOAD=${payload} ## set your payload 173 http post :8889/srv-applet-mgr/v0/event/$TOPIC --raw=$PAYLOAD -A bearer -a $PUBTOK 174 ``` 175 176 ### Learn more 177 Please refer to [HOWTO.md](./HOWTO.md) for more details. 178 179 ## Documentation 180 181 Please visit [https://docs.w3bstream.com/](https://docs.w3bstream.com/). 182 183 Interested in contributing to the doc? Please edit on [Github](https://github.com/machinefi/w3bstream-docs-gitbook) 184 185 ## SDKs 186 187 ### Client SDKs 188 - Javascript/Typesript: https://github.com/machinefi/w3bstream-client-js 189 - Python: https://github.com/machinefi/w3bstream-client-python 190 - Golang: https://github.com/machinefi/w3bstream-client-go 191 - Android: https://github.com/machinefi/w3bstream-android-sdk 192 - iOS: https://github.com/machinefi/w3bstream-ios-sdk 193 - ESP32: https://github.com/machinefi/w3bstream-client-esp32 194 195 ### WASM 196 - Golang: https://github.com/machinefi/w3bstream-wasm-golang-sdk 197 - AssemblyScript: https://github.com/machinefi/w3bstream-wasm-ts-sdk 198 - Rust: https://github.com/machinefi/w3bstream-wasm-rust-sdk 199 200 201 ## Examples 202 203 Learning how to get started with W3bstream? Here is a quick get-start example: https://github.com/machinefi/get-started 204 205 More code examples: https://github.com/machinefi/w3bstream-examples 206 207 Step-by-step tutorials can be found on dev portal: https://developers.iotex.io/ 208 209 ## Contribution Guide 210 The community welcomes everyone to contribute, you can find the good first [issue](https://github.com/machinefi/w3bstream/issues) in here if you are new to W3bstream. 211 212 ## Community 213 214 - Developer portal: https://developers.iotex.io/ 215 - Developer Discord (join #w3bstream channel): https://w3bstream.com/discord 216 217 ## License 218 [Apache-2.0](LICENSE.md)