This contract allows our microservice to create transactions related to storage operations and interact with the deployed blockchain on hyperledger fabric.
- Create WRITE, READ, DELETE, SHARE transactions in the blockchain
- Fetch existing blocks for a specific wallet
This project uses node and npm as package manager, make sure it is installed
node -v
npm -v
Clone the project
git clone https://github.com/K-nto/Kinto-storage-contract.git
Go to the project directory
cd Kinto-storage-contract
Install dependencies
npm install
Compile
npm run build
Start
npm run start
To deploy this contract into hyperledger blockchain head to scripts/SETUP_LOCAL.md
for further instructions
Once the contract is deployed into the blockchain. With the proper security configurations, these are the available querys
- Initialize storage ledger
{"function": "initLedger", "Args": []}
- get all file operations
{"function": "queryAllFileOperations", "Args": []}
- create a transaction
{"function": "createFileOperation", "Args": ["FILEHASH_1", "WALLET_1", "WRITE"]}
- Modify operation
{"function": "modifyFile", "Args": ["TRANSACTION_ID", "FILE_HASH"]}
Example Using hyperledger fabric Peer Cli on a test network
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n $CONTRACT_NAME --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c '{"function":"createFileOperation","Args":["FILEHASH_2", "WALLET_2", "READ"]}'
Example Using typescript
import {contract} from '@hyperledger/fabric-gateway';
// You need to connect to the network and generate a gateway connection
//Execute transaction
const transactionResultBytes = await contract.evaluateTransaction(
'createFileOperation',
'FILEHASH_2',
'WALLET_2',
'READ'
);
const resultJson = new TextDecoder().decode(transactionResultBytes);
Distributed under the no License. See LICENSE.txt for more information.
Federico Javier Parodi - Fedejp - Linkedin - Github
Carlos Santiago Yanzon - Bizk - Linkedin - Github
Project Link: https://github.com/K-nto
We thank and aknowledge the authors of these resources for their work.