MDL Manager Tutorial 4/4 [Chaincode]
[MDL Network Configuration]
* MDL Manager
1. CA
2.MSP
3. Orderer
4. Peer
5. Organization
6. Channel
7. Chaincode
7-1. Chaincode Enrollment
7-2. Chaincode Instantiation
7-3. Chaincode invoke, query
7-4. Chaincode mapping API
This tutorial provides methods to query and invoke APIs so that the installed chaincode can be used externally, including chaincode registration and instantiation through the MDL Manager*.
* MDL Manager
A high-speed blockchain application platform that operates based on Hyperledger Fabric, allowing users to flexibly deploy and manage nodes, channels, and chaincodes by building a network environment through an intuitive UI.
[Chaincode]
Hyperledger Fabric users often use the terms smart contract and chaincode interchangeably. In general, a smart contract defines the transaction logic that controls the lifecycle of a business object contained in the world state.
A smart contract is defined within a chaincode. Multiple smart contracts can be define within the same chaincode. When a chaincode is deployed, all smart contracts within it are made available to applications.
7-2. Chaincode Instantiation
ㆍSelect Peer, Orderer, or Channel.
ㆍEnter Arguments to instantiate the Chaincode.
To insert data into the installed chaincode, insert the written chaincode function and arguments, or to instantiate only, send an empty value to Arguments to complete the instantiation. The picture below is an example.
7-3. Chaincode invoke, query
ㆍInstantiated → Select Chaincode → Click the Execution button to call the Chaincode query & invoke screen.
ㆍSelect the invoke function of the registered chaincode, input the argument of the function, and select and execute the peer and orderer to be executed.
Upon successful execution, the registered transaction id is displayed on the left.
ㆍIf the query is executed in the same way as above, data is displayed in the transaction registered using the chaincode.
7-4. Chaincode mapping API
By issuing a key to manage the chaincode installed in the MDL Manager so that it can be used externally, you can query and invoke it with the API.
ㆍClick the Settings → Generate API Key button to call the API Key creation screen.
ㆍFirst, select a Channel to load the Chaincode on that Channel.
ㆍCreate API Key by selecting Chaincode and Functions to generate API Key.
ㆍCheck the generated API Key.
Chaincode Mapping API Interworking Specification
Below is an example tested by referring to the API Interworking Specification.
Chaincode Invoke
### request ###
~$ curl --location --request POST 'http://192.168.72.166/api/blockchain/v1/channels/testchannel/chaincodes/simple/invoke' \
--header 'Authorization: Basic Ic8F4nNzTRK78DaWbAtIng==' \
--form 'version="v1"' \
--form 'mdl_user="admin"' \
--form 'peers="[{\"enroll_id\":\"org1peer1\", \"msp_id\":\"org1msp\", \"mdl_user\":\"admin\"},{\"enroll_id\":\"org1peer2\", \"msp_id\":\"org1msp\", \"mdl_user\":\"admin\"}]"' \
--form 'orderers="[{\"orderer_name\":\"orderer1\", \"org_name\":\"org1\", \"mdl_user\":\"admin\"}]"' \
--form 'function="open"' \
--form 'args="b1"' \
--form 'args="100"'
### response ###
{"transaction_id":"da0b4ecb8dd6407c6b221aaf86d2503baea0029c11e21ad12afddc500b768294"}
Chaincode query
### request ###
~$ curl --location -g --request GET 'http://192.168.72.166/api/blockchain/v1/channels/testchannel/chaincodes/simple/query?version=v1&mdl_user=admin&peers=[{%22enroll_id%22:%22org1peer1%22,%20%22msp_id%22:%22org1msp%22,%20%22mdl_user%22:%22admin%22},{%22enroll_id%22:%22org1peer2%22,%20%22msp_id%22:%22org1msp%22,%20%22mdl_user%22:%22admin%22}]&function=query&args=c1' \
--header 'Authorization: Basic Ic8F4nNzTRK78DaWbAtIng=='
### response ###
{"result":100}
MDL (MEDIUM Distributed Ledger), applied with MEDIUM’s unique blockchain acceleration technology, is a total blockchain solution that allows you to easily install, operate, and monitor Hyperledger Fabric.
High Performance
Providing the world's fastest speed of over 15,000 TPS
※ Performance test results by Korea Testing and Certification Agency
(KOTCA) 14,142TPS (2021. 01)
Easy to Use (MDL Manager)
- Allowing an easy installation of Hyperledger Fabric on prepared servers.
(Within 10 minutes)
- Intuitive monitoring/management capabilities are supported through the dashboard.
- Providing ChainCode Mapping API and REST API so that ChainCode calls and blockchain
can be used.