1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-22 01:36:56 +01:00

Finished examples - experimenting with websocket

This commit is contained in:
Michiel Mulders 2018-01-20 22:19:23 +01:00
parent 87f36946f0
commit 0a7e207fef
5 changed files with 28 additions and 9 deletions

View File

@ -5,6 +5,22 @@
**Basic Usage**: Create asset and transfer it to new owner. **Basic Usage**: Create asset and transfer it to new owner.
-> `npm start` -> `npm start`
**Async/Await Basic Usage**: Basic usage example rewritten with async/await.
-> `npm run basic-async`
**Querying for Assets**: Query for assetdata or metadata. **Querying for Assets**: Query for assetdata or metadata.
-> `npm run query-assets` -> `npm run query-assets`
**Seed/Keypair Functionality**: Create keypair with bip39 library.
-> `npm run seed-func`
## Notes
`dotenv` is listed as a dependencies in `package.json`.
If you want to use this, add a `.env` file to the root of this project (same level as this `README.md` file)
and replace the variables to fit your system.
```
BIGCHAINDB_API_PATH=http://localhost:9984/api/v1/
BIGCHAINDB_APP_ID=<your-app-id>
BIGCHAINDB_APP_KEY=<your-app-key>
```

View File

@ -9,8 +9,7 @@
"start": "nodemon src/basic-usage.js --exec babel-node", "start": "nodemon src/basic-usage.js --exec babel-node",
"query-assets": "nodemon src/query-assets.js --exec babel-node", "query-assets": "nodemon src/query-assets.js --exec babel-node",
"seed-func": "nodemon src/seed-func.js --exec babel-node", "seed-func": "nodemon src/seed-func.js --exec babel-node",
"basic-async": "nodemon src/basic-usage-async-await.js --exec babel-node", "basic-async": "nodemon src/basic-usage-async-await.js --exec babel-node"
"websocket": "nodemon src/websocket.js --exec babel-node"
}, },
"author": "BigchainDB", "author": "BigchainDB",
"license": "MIT", "license": "MIT",
@ -31,6 +30,7 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"bigchaindb-driver": "^3.2.0", "bigchaindb-driver": "^3.2.0",
"bip39": "^2.5.0" "bip39": "^2.5.0",
"dotenv": "^4.0.0"
} }
} }

View File

@ -1,10 +1,11 @@
const driver = require('bigchaindb-driver') const driver = require('bigchaindb-driver')
require('dotenv').config()
// ======== Preparation ======== // // ======== Preparation ======== //
const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', {
app_id: 'c17a9968', app_id: process.env.BIGCHAINDB_APP_ID,
app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' app_key: process.env.BIGCHAINDB_APP_KEY
}) })
const alice = new driver.Ed25519Keypair() const alice = new driver.Ed25519Keypair()

View File

@ -1,10 +1,11 @@
const driver = require('bigchaindb-driver') const driver = require('bigchaindb-driver')
require('dotenv').config()
// ======== Preparation ======== // // ======== Preparation ======== //
const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', {
app_id: 'c17a9968', app_id: process.env.BIGCHAINDB_APP_ID,
app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' app_key: process.env.BIGCHAINDB_APP_KEY
}) })
const alice = new driver.Ed25519Keypair() const alice = new driver.Ed25519Keypair()

View File

@ -1,10 +1,11 @@
const driver = require('bigchaindb-driver') const driver = require('bigchaindb-driver')
require('dotenv').config()
// ======== Preparation ======== // // ======== Preparation ======== //
const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', {
app_id: 'c17a9968', app_id: process.env.BIGCHAINDB_APP_ID,
app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' app_key: process.env.BIGCHAINDB_APP_KEY
}) })
const alice = new driver.Ed25519Keypair() const alice = new driver.Ed25519Keypair()