1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-25 11:08:29 +01:00

Update Python and Node.js samples

This commit is contained in:
vrde 2017-07-06 17:37:58 +02:00
parent 7eb63c079a
commit 1f7592d3bd
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 23 additions and 17 deletions

View File

@ -69,8 +69,9 @@ window.addEventListener('DOMContentLoaded', function domload(event) {
const codeMessages = document.querySelectorAll('.code-example__message')
function updateMessage(content) {
const escapedContent = content.replace(/'/g, "\\'")
for (var codeMessage of codeMessages) {
codeMessage.textContent = content
codeMessage.textContent = escapedContent
}
}
// empty default message

View File

@ -86,20 +86,20 @@ redirect_from:
from bigchaindb_driver import BigchainDB
from bigchaindb_driver.crypto import generate_keypair
bdb = BigchainDB('https://test.ipdb.io/api/v1/')
bdb = BigchainDB(
'https://test.ipdb.io/api/v1/',
headers={'app_id': 'Get one from developers.ipdb.io',
'app_key': 'Same as app_id'})
alice = generate_keypair()
tx = bdb.transactions.prepare(
metadata={ "message": "Blockchain all the things!" }
)
txSigned = bdb.transactions.fulfill(
operation='CREATE',
signers=alice.public_key,
asset={'data': {'message': 'Blockchain all the things!'}})
signed_tx = bdb.transactions.fulfill(
tx,
private_keys=alice.private_key
)
bdb.transactions.send(txSigned)
private_keys=alice.private_key)
bdb.transactions.send(signed_tx)
```
{% endcapture %}{{ python | markdownify }}
</div>
@ -108,15 +108,20 @@ bdb.transactions.send(txSigned)
{% capture nodejs %}
```js
const driver = require('bigchaindb-driver')
const conn = new driver.Connection('https://test.ipdb.io/api/v1/')
const alice = new driver.Ed25519Keypair()
const conn = new driver.Connection(
'https://test.ipdb.io/api/v1/',
{ app_id: 'Get one from developers.ipdb.io',
app_key: 'Same as app_id' })
const tx = driver.Transaction.makeCreateTransaction(
{ message: "Blockchain all the things!" }
)
{ message: 'Blockchain all the things!' },
null,
[ driver.Transaction.makeOutput(
driver.Transaction.makeEd25519Condition(alice.publicKey))],
alice.publicKey)
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
conn.postTransaction(txSigned)
```
{% endcapture %}{{ nodejs | markdownify }}