router.post('/transfer', function(req, res) {
conn.searchAssets(req.body.assetName)
.then(assets => {
const did = new DID(req.body.assetPublicKey);
did.define(req.body.modelName);
did.models[req.body.modelName]
.retrieve(assets[0].id)
.then(asset => {
console.log(asset)
// [ OrmObject {
// _name: 'test',
// _schema: undefined,
// _connection:
// Connection {
// path: 'http://localhost:9984/api/v1/',
// headers: {},
// conn: [Connection] },
// _appId: 'global',
// transactionHistory: [ [Object] ],
// id: 'id:global:test:99040993-0fa3-4c32-9d54-f6d83a65fb1f',
// data: { myData: '', ownerName: 'Juan Diego' } } ]
return asset.append({
toPublicKey: req.body.destPublicKey,
keypair: req.body.ownerKeyPair,
data: {
myData: req.body.data,
ownerName: req.body.ownerName
}
})
})
.then(updatedAsset => {
console.log("This message does not appear")
console.log(updatedAsset);
res.send(updatedAsset);
})
})
});
/Users/apple/Documents/big_chaindb/node_modules/base-x/index.js:29
if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
^
TypeError: Expected Buffer
How to get all available Assets?
How to get all assets for particular public Key/private key?
Using below URL to retrieve the specific assets/metadata using search criteria
http://localhost:9984/api/v1/assets?search={search_param_string}
// Metadata contains information about the transaction itself
// (can be `null` if not needed)
{metadata},
// A transaction needs an output
[ BigchainDB.Transaction.makeOutput(
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))
],
alice.publicKey
)
// Sign the transaction with private keys
const txSigned = BigchainDB.Transaction.signTransaction(tx, alice.privateKey)
// Send the transaction off to BigchainDB
let conn = new BigchainDB.Connection(API_PATH)
conn.postTransactionCommit(txSigned)
@abhi-nilekar
npm install bigchaindb-driver@4.1.0
npm install base-x@3.0.4
npm install bip39@2.5.0
may be it will help you