1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2025-02-14 21:10:32 +01:00

Merge pull request #27 from bigchaindb/feature/readmeupdates

Code example updates
This commit is contained in:
Matthias Kretschmann 2017-06-14 18:48:28 +02:00 committed by GitHub
commit 6ccc9848c5

View File

@ -45,7 +45,7 @@ You'll probably need a babel here and a bundler there. Alternatively, use one of
```js ```js
import * as driver from 'bigchaindb-driver' import * as driver from 'bigchaindb-driver'
// http(s)://<bigchaindb-API-url>/ (e.g. http://localhost:9984/api/v1/) // BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
const API_PATH = 'http://localhost:9984/api/v1/' const API_PATH = 'http://localhost:9984/api/v1/'
// Create a new user with a public-private key pair // Create a new user with a public-private key pair
@ -65,7 +65,7 @@ const tx = driver.Transaction.makeCreateTransaction(
driver.Transaction.makeEd25519Condition(alice.publicKey)) driver.Transaction.makeEd25519Condition(alice.publicKey))
], ],
alice.publicKey alice.publicKey
); )
// Optional: You've got everything you need, except for an asset // Optional: You've got everything you need, except for an asset
// and metadata. Maybe define them here, any JSON-serializable object // and metadata. Maybe define them here, any JSON-serializable object
@ -78,7 +78,7 @@ const tx = driver.Transaction.makeCreateTransaction(
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey) const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
// Send the transaction off to BigchainDB // Send the transaction off to BigchainDB
let conn = new driver.Connection(PATH, { 'Content-Type': 'application/json' }) let conn = new driver.Connection(API_PATH, { 'Content-Type': 'application/json' })
conn.postTransaction(txSigned) conn.postTransaction(txSigned)
.then(() => conn.getStatus(txSigned.id)) .then(() => conn.getStatus(txSigned.id))