Skip to content

Instantly share code, notes, and snippets.

@Jojoooo1
Last active February 4, 2019 11:58
Show Gist options
  • Save Jojoooo1/ce9d8d034bbad4ab8f69d92b5338ae9d to your computer and use it in GitHub Desktop.
Save Jojoooo1/ce9d8d034bbad4ab8f69d92b5338ae9d to your computer and use it in GitHub Desktop.
chaincode-3.js
// [..]
// Function for retrieving state value
async getDataById(stub, args) {
// Assigns id to data
const data = args[0];
// Verifies id is not empty
if (!data) {
throw new Error('Por favor especifique um id');
}
console.info('--- start getDataById ---');
const dataAsBytes = await stub.getState(data);
console.info('==================');
console.log(dataAsBytes.toString());
console.info('==================');
console.info('--- end getDataById ---');
return dataAsBytes;
}
// [..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment