The asynchronous bwrite method writes a file hash to the blockchain. It takes the hash of the directory path of the file (pHash) and the document hash (dHash) as input and writes to the blockchain.
- Before writing to the blockchain, we need access to a registered identity that has permission to write to our blockchain. We'll use the user1 user that we registered in our wallet earlier. Using the Hyperledger Fabric SDK FileSystemWallet method, we'll create a new wallet object pointing to the wallet we created for DocsApp. We check whether the user 1 user is registered in the wallet. Execution of the method will proceed only if the user 1 user exists:
async function bWrite (pHash,dHash) ...