@@ -46,10 +46,10 @@ the {{< external-link title="dfuse JS client library" href="https://github.com/d
46
46
47
47
Here are a few of its key features:
48
48
49
- * Handles API token issuance
50
- * Refreshes your API token upon expiration
51
- * Automatically reconnects if the connection closes
52
- * Supports ` Browsers ` and ` Node.js ` environments
49
+ - Handles API token issuance
50
+ - Refreshes your API token upon expiration
51
+ - Automatically reconnects if the connection closes
52
+ - Supports ` Browsers ` and ` Node.js ` environments
53
53
54
54
You can add it to your project using Yarn or NPM.
55
55
@@ -104,11 +104,16 @@ the dfuse client using the API key you created in the first step and the network
104
104
connect to.
105
105
106
106
Valid networks can be found at [ EOSIO API Endpoints] ({{< ref "reference/eosio/endpoints" >}})
107
-
108
107
{{< tabs "create-client" >}}
109
- {{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="4:9" >}}
110
- {{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="1:6" >}}
111
- {{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="1:11" >}}
108
+ {{< tab lang="javascript" title="Node.js" >}}
109
+ {{< code-section "quickstarts_javascript_node_eos_section1" >}}
110
+ {{< /tab >}}
111
+ {{< tab lang="javascript" title="Bundler" >}}
112
+ {{< code-section "quickstarts_javascript_bundler_eos_section1" >}}
113
+ {{< /tab >}}
114
+ {{< tab lang="javascript" title="Browser" >}}
115
+ {{< code-section "quickstarts_javascript_browser_eos_section1" >}}
116
+ {{< /tab >}}
112
117
{{< /tabs >}}
113
118
114
119
## 4. Stream your first results
@@ -120,14 +125,20 @@ to you, you get to choose and pick only what you are interested in.
120
125
{{< alert type="note" >}}
121
126
Want to inspect the full set of available fields you can retrieve?
122
127
123
- * [ GraphQL API Reference] ({{< ref "/reference/eosio/graphql" >}})
124
- * {{< external-link href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0= " title="GraphiQL, online query editor with completion and docs">}}
125
- {{< /alert >}}
128
+ - [ GraphQL API Reference] ({{< ref "/reference/eosio/graphql" >}})
129
+ - {{< external-link href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0= " title="GraphiQL, online query editor with completion and docs">}}
130
+ {{< /alert >}}
126
131
127
132
{{< tabs "define-query">}}
128
- {{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="11:17" >}}
129
- {{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="8:14" >}}
130
- {{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="13:21" >}}
133
+ {{< tab lang="javascript" title="Node.js" >}}
134
+ {{< code-section "quickstarts_javascript_node_eos_section2" >}}
135
+ {{< /tab >}}
136
+ {{< tab lang="javascript" title="Bundler" >}}
137
+ {{< code-section "quickstarts_javascript_bundler_eos_section2" >}}
138
+ {{< /tab >}}
139
+ {{< tab lang="javascript" title="Browser" >}}
140
+ {{< code-section "quickstarts_javascript_browser_eos_section2" >}}
141
+ {{< /tab >}}
131
142
{{< /tabs >}}
132
143
133
144
Next, you create the GraphQL subscription to stream transfers as they come. You will use the ` searchTransactionsForward ` operation, with the ` "receiver:eosio.token action:transfer -data.quantity:'0.0001 EOS'" ` query (See the [ Search Query Language reference here] ({{< ref "/reference/eosio/search-terms" >}})). This basically means, give me all transactions containing one or more
@@ -137,16 +148,23 @@ You can combine the dfuse client instance we created in step 3 with the GraphQL
137
148
a ` main ` function:
138
149
139
150
{{< tabs "execute-query">}}
140
- {{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="19:43" >}}
141
- {{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="16:52" >}}
142
- {{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="23:60" >}}
151
+ {{< tab lang="javascript" title="Node.js" >}}
152
+ {{< code-section "quickstarts_javascript_node_eos_section3" >}}
153
+ {{< /tab >}}
154
+ {{< tab lang="javascript" title="Bundler" >}}
155
+ {{< code-section "quickstarts_javascript_bundler_eos_section3" >}}
156
+ {{< /tab >}}
157
+ {{< tab lang="javascript" title="Browser" >}}
158
+ {{< code-section "quickstarts_javascript_browser_eos_section3" >}}
159
+ {{< /tab >}}
143
160
{{< /tabs >}}
144
161
145
162
The function passed as the 2nd parameter to ` client.graphql() ` will be called every time a new result is returned
146
163
by the API. And here is a sample of the prints you will receive as a result of executing the streaming operation
147
164
above:
148
165
149
166
<!-- **Note** We use python for all languages for a nicer output rendering -->
167
+
150
168
{{< highlight "python" >}}
151
169
Transfer eosbetdice11 -> eosbetbank11 [ 0.0500 EOS]
152
170
Transfer newdexpublic -> gq4tcnrwhege [ 2.8604 EOS]
@@ -161,19 +179,26 @@ Transfer bluebetproxy -> bluebetbulls [0.6000 EOS]
161
179
Here the small glue code containing the ` main ` function, imports and other helper functions to run the example:
162
180
163
181
{{< tabs "support-code">}}
164
- {{< tab-code title="Node.js" filename="./quickstarts/javascript/node.js/index.eosio.js" range="45:45" >}}
165
- {{< tab-code title="Bundler" filename="./quickstarts/javascript/bundler/index.eosio.js" range="54:54" >}}
166
- {{< tab-code title="Browser" filename="./quickstarts/javascript/browser/index.eosio.html" range="61:63" >}}
182
+ {{< tab lang="javascript" title="Node.js" >}}
183
+ {{< code-section "quickstarts_javascript_node_eos_section4" >}}
184
+ {{< /tab >}}
185
+ {{< tab lang="javascript" title="Bundler" >}}
186
+ {{< code-section "quickstarts_javascript_bundler_eos_section4" >}}
187
+ {{< /tab >}}
188
+ {{< tab lang="javascript" title="Browser" >}}
189
+ {{< code-section "quickstarts_javascript_browser_eos_section4" >}}
190
+ {{< /tab >}}
167
191
{{< /tabs >}}
168
192
169
193
{{< tabs "full-working">}}
170
194
171
195
{{< tab lang="shell" title="Node.js">}}
172
196
git clone https://github.com/dfuse-io/docs
173
- cd docs/quickstarts/javascript/node.js
197
+ cd docs/quickstarts/javascript/node
174
198
npm install
175
199
176
200
# Replace 'server_abcdef12345678900000000000' with your own API key!
201
+
177
202
DFUSE_API_KEY=server_abcdef12345678900000000000 node index.eosio.js
178
203
{{< /tab >}}
179
204
@@ -183,34 +208,38 @@ cd docs/quickstarts/javascript/bundler
183
208
npm install
184
209
185
210
# Replace 'web_abcdef12345678900000000000' with your own API key!
211
+
186
212
DFUSE_API_KEY=web_abcdef12345678900000000000 npm run build: eosio
187
213
188
214
# Open ` index.eosio.html ` directly in your favorite Browser
189
- open index.eosio.html # Mac
190
- xdg-open index.eosio.html # Ubuntu
191
- start index.eosio.thml # Windows
215
+
216
+ open index.eosio.html # Mac
217
+ xdg-open index.eosio.html # Ubuntu
218
+ start index.eosio.thml # Windows
192
219
{{< /tab >}}
193
220
194
221
{{< tab lang="shell" title="Browser">}}
195
222
git clone https://github.com/dfuse-io/docs
196
223
cd docs/quickstarts/javascript/browser
224
+
197
225
# Manually edit index.eosio.html changing ` web_abcdef12345678900000000000 ` with your own API key
198
226
199
227
# Open ` index.eosio.html ` directly in your favorite Browser
200
- open index.eosio.html # Mac
201
- xdg-open index.eosio.html # Ubuntu
202
- start index.eosio.thml # Windows
228
+
229
+ open index.eosio.html # Mac
230
+ xdg-open index.eosio.html # Ubuntu
231
+ start index.eosio.thml # Windows
203
232
{{< /tab >}}
204
233
205
234
{{< /tabs >}}
206
235
207
236
## 6. What's next?
208
237
209
- * [ GraphQL API Reference] ({{< ref "/reference/eosio/graphql" >}})
210
- * [ REST API Reference] ({{< ref "/reference/eosio/rest" >}})
211
- * [ WebSocket API Reference] ({{< ref "/reference/eosio/websocket" >}})
212
- * [ Check dfuse Core Concepts] ({{< ref "/guides/core-concepts" >}})
213
- * [ Look at one of our tutorials] ({{< ref "/guides/eosio/tutorials" >}})
214
- * {{< external-link title="The ` @dfuse/client-js ` overview document" href="https://github.com/dfuse-io/client-js/blob/master/README.md#dfuse-javascripttypescript-client-library " >}}
215
- * {{< external-link title="The ` @dfuse/client-js ` quick API reference" href="https://github.com/dfuse-io/client-js/blob/master/README.md#api " >}} ({{< external-link title="Full API reference" href="https://dfuse-io.github.io/client-js/ " >}})
216
- * {{< external-link title="GraphiQL, online query editor with completion and docs" href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0= " >}}
238
+ - [ GraphQL API Reference] ({{< ref "/reference/eosio/graphql" >}})
239
+ - [ REST API Reference] ({{< ref "/reference/eosio/rest" >}})
240
+ - [ WebSocket API Reference] ({{< ref "/reference/eosio/websocket" >}})
241
+ - [ Check dfuse Core Concepts] ({{< ref "/guides/core-concepts" >}})
242
+ - [ Look at one of our tutorials] ({{< ref "/guides/eosio/tutorials" >}})
243
+ - {{< external-link title="The ` @dfuse/client-js ` overview document" href="https://github.com/dfuse-io/client-js/blob/master/README.md#dfuse-javascripttypescript-client-library " >}}
244
+ - {{< external-link title="The ` @dfuse/client-js ` quick API reference" href="https://github.com/dfuse-io/client-js/blob/master/README.md#api " >}} ({{< external-link title="Full API reference" href="https://dfuse-io.github.io/client-js/ " >}})
245
+ - {{< external-link title="GraphiQL, online query editor with completion and docs" href="https://mainnet.eos.dfuse.io/graphiql/?query=c3Vic2NyaXB0aW9uIHsKICBzZWFyY2hUcmFuc2FjdGlvbnNGb3J3YXJkKHF1ZXJ5OiJyZWNlaXZlcjplb3Npby50b2tlbiBhY3Rpb246dHJhbnNmZXIgLWRhdGEucXVhbnRpdHk6JzAuMDAwMSBFT1MnIikgewogICAgdW5kbyBjdXJzb3IKICAgIHRyYWNlIHsgaWQgbWF0Y2hpbmdBY3Rpb25zIHsganNvbiB9IH0KICB9Cn0= " >}}
0 commit comments