dcorejs
javascript lib for DECENT blockchain
Setup
This library can be obtained through npm:
# npm install dcorelib
Usage
dcorelib package contain class DCore
:
const DCore =
DCore
contains static methods for work with public API, and dynamic methods for work with private API.
Initialization
You can connect:
DCore
DCore.connect()
return Promise, resolve it when connection consists.
You may to subscribe to connection event:
DCore
Public API
After connection, you may call public api methods. For example DCore.db
return wrapper for database API:
DCoredbDCoredb
DCore.history
is wrapper for history API:
DCorehistory
Private API
If you want access to private API, you need create object from DCore
class:
let account = "accountName""privateActiveKey"
or
let account = DCore
account
have transfer
method:
await account
Some examples:
const DCore = KEY = 'privateActiveKey' DCorenode = "ws://testnet.dcore.io:8090"DCore { let bot = 'test-acc'KEY let iam = await DCoreaccounts'test-acc'; let info = await DCoredb; console}
DCore in REPL
If you install dcorelib
-package in global storage, you may start dcore
exec script:
$ dcore>|
This command try autoconnect to mainnet DCore. If you want to connect on testnet, try this:
$ dcore --testnet>|
It is nodejs REPL with several variables:
DCore
, main classDCore
packagelogin
, function to create object of classDCore
generateKeys
, to generateKeys from login and passwordaccounts
, is analogDCore.accounts
assets
, is analogDCore.assets
db
, is analogDCore.db
history
, is analogDCore.hostory
network
, is analogDCore.network
fees
, is analogDCore.fees
For example
$ dcore> assets"dct"
Shot request
If need call only one request, you may use --account
, --asset
, --block
, --object
, --history
, --balance
or --transfer
keys in command-line:
$ dcore --account <'name' or 'id' or 'last number in id'> "id": "1.2.5992" "membership_expiration_date": "1970-01-01T00:00:00" "registrar": "1.2.37" "referrer": "1.2.21" ... $ dcore --asset <'symbol' or 'id' or 'last number in id'> "id": "1.3.0" "symbol": "KRM" "precision": 5 ... $ dcore --block <number>block_num: 4636380 "previous": "0046bedba1317d146dd6afbccff94412d76bf094" "timestamp": "2018-10-01T13:09:40" "witness": "1.6.41" ... $ dcore --object 123 "id": "1.2.3" "membership_expiration_date": "1969-12-31T23:59:59" "registrar": "1.2.3" "referrer": "1.2.3" ... $ dcore --history <account> <limit> <start> <stop> "id": "1.11.98179" "op": 0 ... $ dcore --balance <account or accounts> <asset or assets>accountKRM: 1234567 $ dcore --transfer <from> <to> <amount> <asset> --keyTransfered <amount> <asset> from '<from>' to '<to>' with memo '<memo>'
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The package is available as open source under the terms of the MIT License.