mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-22 09:46:57 +01:00
Update Python and Node.js samples
This commit is contained in:
parent
7eb63c079a
commit
1f7592d3bd
@ -69,8 +69,9 @@ window.addEventListener('DOMContentLoaded', function domload(event) {
|
|||||||
const codeMessages = document.querySelectorAll('.code-example__message')
|
const codeMessages = document.querySelectorAll('.code-example__message')
|
||||||
|
|
||||||
function updateMessage(content) {
|
function updateMessage(content) {
|
||||||
|
const escapedContent = content.replace(/'/g, "\\'")
|
||||||
for (var codeMessage of codeMessages) {
|
for (var codeMessage of codeMessages) {
|
||||||
codeMessage.textContent = content
|
codeMessage.textContent = escapedContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// empty default message
|
// empty default message
|
||||||
|
@ -86,20 +86,20 @@ redirect_from:
|
|||||||
from bigchaindb_driver import BigchainDB
|
from bigchaindb_driver import BigchainDB
|
||||||
from bigchaindb_driver.crypto import generate_keypair
|
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()
|
alice = generate_keypair()
|
||||||
|
|
||||||
tx = bdb.transactions.prepare(
|
tx = bdb.transactions.prepare(
|
||||||
metadata={ "message": "Blockchain all the things!" }
|
operation='CREATE',
|
||||||
)
|
signers=alice.public_key,
|
||||||
|
asset={'data': {'message': 'Blockchain all the things!'}})
|
||||||
txSigned = bdb.transactions.fulfill(
|
signed_tx = bdb.transactions.fulfill(
|
||||||
tx,
|
tx,
|
||||||
private_keys=alice.private_key
|
private_keys=alice.private_key)
|
||||||
)
|
bdb.transactions.send(signed_tx)
|
||||||
|
|
||||||
bdb.transactions.send(txSigned)
|
|
||||||
```
|
```
|
||||||
{% endcapture %}{{ python | markdownify }}
|
{% endcapture %}{{ python | markdownify }}
|
||||||
</div>
|
</div>
|
||||||
@ -108,15 +108,20 @@ bdb.transactions.send(txSigned)
|
|||||||
{% capture nodejs %}
|
{% capture nodejs %}
|
||||||
```js
|
```js
|
||||||
const driver = require('bigchaindb-driver')
|
const driver = require('bigchaindb-driver')
|
||||||
const conn = new driver.Connection('https://test.ipdb.io/api/v1/')
|
|
||||||
|
|
||||||
const alice = new driver.Ed25519Keypair()
|
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(
|
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)
|
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
|
||||||
|
|
||||||
conn.postTransaction(txSigned)
|
conn.postTransaction(txSigned)
|
||||||
```
|
```
|
||||||
{% endcapture %}{{ nodejs | markdownify }}
|
{% endcapture %}{{ nodejs | markdownify }}
|
||||||
|
Loading…
Reference in New Issue
Block a user