const { Ed25519Sha256 } = require('crypto-conditions');
// BigchainDB server instance (e.g. https://example.com/api/v1/)
const API_PATH = 'http://localhost:9984/api/v1/'
// Create a new keypair.
const alice = new driver.Ed25519Keypair()
// Construct a transaction payload
const tx = driver.Transaction.makeCreateTransaction(
// Define the asset to store, in this example it is the current temperature
// (in Celsius) for the city of Berlin.
{ city: 'Berlin, DE', temperature: 22, datetime: new Date().toString() },
// Metadata contains information about the transaction itself
// (can be null if not needed)
{ what: 'My first BigchainDB transaction' },
// A transaction needs an output
[ driver.Transaction.makeOutput(
driver.Transaction.makeEd25519Condition(alice.publicKey))
],
alice.publicKey
)
// Sign the transaction with private keys
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
console.log(txSigned)
// Send the transaction off to BigchainDB
const conn = new driver.Connection(API_PATH)
console.log(conn)
conn.postTransactionCommit(txSigned)
.then(retrievedTx => console.log('Transaction', retrievedTx.id, 'successfully posted.')).catch(err=>{
console.log(err)
});
Hello,Could you help me to fix this issue? I try to connect BigChainDb through nodejs sdk but while try to make a transaction getting this error
{ message: 'HTTP Error: Requested page not reachable', status: '500 INTERNAL SERVER ERROR', requestURI: 'http://localhost:9984/api/v1/transactions?mode=commit' }
this is my code
const http = require("http");
const driver = require('bigchaindb-driver');
const base58 = require('bs58');
const { Ed25519Sha256 } = require('crypto-conditions'); // BigchainDB server instance (e.g. https://example.com/api/v1/) const API_PATH = 'http://localhost:9984/api/v1/' // Create a new keypair. const alice = new driver.Ed25519Keypair()
// Construct a transaction payload const tx = driver.Transaction.makeCreateTransaction( // Define the asset to store, in this example it is the current temperature // (in Celsius) for the city of Berlin. { city: 'Berlin, DE', temperature: 22, datetime: new Date().toString() },
// Metadata contains information about the transaction itself // (can be
null
if not needed) { what: 'My first BigchainDB transaction' },// A transaction needs an output [ driver.Transaction.makeOutput( driver.Transaction.makeEd25519Condition(alice.publicKey)) ], alice.publicKey )
// Sign the transaction with private keys const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
console.log(txSigned) // Send the transaction off to BigchainDB const conn = new driver.Connection(API_PATH) console.log(conn) conn.postTransactionCommit(txSigned) .then(retrievedTx => console.log('Transaction', retrievedTx.id, 'successfully posted.')).catch(err=>{ console.log(err) });
http .createServer(function (req, res) { console.log("8081"); }) .listen(8081);