@@ -19,7 +19,7 @@ General purpose library for the EOS blockchain.
19
19
``` javascript
20
20
Eos = require (' eosjs' ) // Eos = require('./src')
21
21
22
- eos = Eos . Localnet () // 127.0.0.1:8888
22
+ eos = Eos () // 127.0.0.1:8888
23
23
24
24
// All API methods print help when called with no-arguments.
25
25
eos .getBlock ()
@@ -39,7 +39,6 @@ eos.getBlock({block_num_or_id: 1}, callback)
39
39
40
40
// Provide an empty object or a callback if an API call has no arguments
41
41
eos .getInfo ({}).then (result => {console .log (result)})
42
-
43
42
```
44
43
45
44
API methods and documentation are generated from:
@@ -62,11 +61,11 @@ config = {
62
61
},
63
62
expireInSeconds: 60 ,
64
63
broadcast: true ,
65
- debug: false ,
64
+ debug: false , // API and transactions
66
65
sign: true
67
66
}
68
67
69
- eos = Eos . Localnet (config)
68
+ eos = Eos (config)
70
69
```
71
70
72
71
* ` mockTransactions ` (optional)
@@ -107,12 +106,12 @@ options = {
107
106
108
107
### Usage (read/write)
109
108
110
- If you use the Testnet, you 'll need to replace the private key in keyProvider.
109
+ You 'll need to provide the private key in keyProvider.
111
110
112
111
``` javascript
113
112
Eos = require (' eosjs' ) // Eos = require('./src')
114
113
115
- eos = Eos . Localnet ({keyProvider: ' 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' })
114
+ eos = Eos ({keyProvider: ' 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' })
116
115
117
116
// Run with no arguments to print usage.
118
117
eos .transfer ()
@@ -153,7 +152,7 @@ Eos = require('eosjs') // Eos = require('./src')
153
152
wif = ' 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
154
153
pubkey = ' EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'
155
154
156
- eos = Eos . Localnet ({keyProvider: wif})
155
+ eos = Eos ({keyProvider: wif})
157
156
158
157
eos .transaction (tr => {
159
158
tr .newaccount ({
@@ -200,7 +199,7 @@ Import and include the library when you configure Eos:
200
199
201
200
``` javascript
202
201
binaryen = require (' binaryen' )
203
- eos = Eos . Localnet ({... , binaryen})
202
+ eos = Eos ({... , binaryen})
204
203
```
205
204
206
205
Complete example:
@@ -215,9 +214,9 @@ keyProvider = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
215
214
//
216
215
// $ npm install [email protected]
217
216
// binaryen = require('binaryen')
218
- // eos = Eos.Localnet ({keyProvider, binaryen})
217
+ // eos = Eos({keyProvider, binaryen})
219
218
220
- eos = Eos . Localnet ({keyProvider})
219
+ eos = Eos ({keyProvider})
221
220
222
221
wasm = fs .readFileSync (` docker/contracts/eosio.token/eosio.token.wasm` )
223
222
abi = fs .readFileSync (` docker/contracts/eosio.token/eosio.token.abi` )
@@ -243,7 +242,7 @@ keyProvider = [
243
242
Eos .modules .ecc .seedPrivate (' currency' )
244
243
]
245
244
246
- eos = Eos . Localnet ({keyProvider})
245
+ eos = Eos ({keyProvider})
247
246
248
247
// if either transfer fails, both will fail (1 transaction, 2 messages)
249
248
eos .transaction (eos =>
@@ -288,7 +287,7 @@ A manual transaction provides for more flexibility.
288
287
``` javascript
289
288
Eos = require (' eosjs' ) // Eos = require('./src')
290
289
291
- eos = Eos . Localnet ({keyProvider: ' 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' })
290
+ eos = Eos ({keyProvider: ' 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' })
292
291
293
292
// returns Promise
294
293
eos .transaction ({
@@ -324,28 +323,24 @@ import from `./src` instead.
324
323
325
324
``` javascript
326
325
Eos = require (' ./src' )
327
-
328
- // Creating the instance `eos` means that common blockchain data-structures are
329
- // available for a given network (Testnet, Mainnet, etc).
330
- eos = Eos .Localnet ()
326
+ eos = Eos ()
331
327
```
332
328
333
329
* Fcbuffer
334
330
335
- The ` eos ` instance can provide more convenient serialization:
331
+ The ` eos ` instance can provide serialization:
336
332
337
333
``` javascript
338
334
// 'asset' is a type but could be any struct or type like: transaction or uint8
339
335
type = {type: 1 , data: ' 00ff' }
340
336
buffer = eos .fc .toBuffer (' extensions_type' , type)
341
337
assert .deepEqual (type, eos .fc .fromBuffer (' extensions_type' , buffer))
342
338
343
- // Serialization for a smart-contract's Abi:
344
- eos .contract (' currency' , (error , c ) => currency = c)
345
- create = {issuer: ' inita' , maximum_supply: ' 1.0000 4,CUR' }
346
- buffer = currency .fc .toBuffer (' create' , create)
347
- create .maximum_supply = ' 1.0000 CUR'
348
- assert .deepEqual (create, currency .fc .fromBuffer (' create' , buffer))
339
+ // ABI Serialization
340
+ eos .contract (' eosio.token' , (error , c ) => eosio_token = c)
341
+ create = {issuer: ' inita' , maximum_supply: ' 1.0000 SYS' }
342
+ buffer = eosio_token .fc .toBuffer (' create' , create)
343
+ assert .deepEqual (create, eosio_token .fc .fromBuffer (' create' , buffer))
349
344
```
350
345
351
346
Use Node v8+ to ` package-lock.json ` .
@@ -357,7 +352,7 @@ need to use them directly. They are exported here giving more API access or
357
352
in some cases may be used standalone.
358
353
359
354
``` javascript
360
- var {api, ecc, json, Fcbuffer, format } = Eos .modules
355
+ var {format, api, ecc, json, Fcbuffer} = Eos .modules
361
356
```
362
357
* format [ ./format.md] ( ./docs/format.md )
363
358
* Blockchain name validation
@@ -393,13 +388,16 @@ git clone https://github.com/EOSIO/eosjs.git
393
388
cd eosjs
394
389
npm install
395
390
npm run build_browser
396
- # builds: ./dist/eos.js
391
+ # builds: ./dist/eos.js load with ./dist/index.html
392
+
393
+ npm run build_browser_test
394
+ # builds: ./dist/test.js run with ./dist/test.html
397
395
```
398
396
399
397
``` html
400
398
<script src =" eos.js" ></script >
401
399
<script >
402
- var eos = Eos . Testnet ()
400
+ var eos = Eos ()
403
401
// ...
404
402
</script >
405
403
```
0 commit comments