MDL Manager Tutorial 4/4 [Chaincode]

tutorial network hyperledger fabric hlf blockchain chaincode invoke api query

[MDL Network Configuration]
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


MDL_X_무료배포_1_part4

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. Chaincode

tutorial_4
Chaincodes → Installed → Click the + button to call up the chaincode registration screen.


7-1. Chaincode Registration

tutorial_4

tutorial_4
Upload the chaincode to be installed.

tutorial_4
ㆍEnter Version and Description.


tutorial_4
Select CA Server Name, Organization Admin, and MSP.


tutorial_4
Select and register a peer to install chaincode.

7-2. Chaincode Instantiation


tutorial_4
Select Chaincode → Click the Instantiate button to call up the Chaincode instantiate screen.

tutorial_4
ㆍSelect Peer, Orderer, or Channel.


tutorial_4
ㆍ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

tutorial_4
InstantiatedSelect Chaincode → Click the Execution button to call the Chaincode query & invoke screen.

tutorial_4
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.


tutorial_4
ㆍ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.

tutorial_4
ㆍClick the SettingsGenerate API Key button to call the API Key creation screen.


tutorial_4
ㆍFirst, select a Channel to load the Chaincode on that Channel.

tutorial_4
ㆍCreate API Key by selecting Chaincode and Functions to generate API Key.


tutorial_4
ㆍCheck the generated API Key.


MDL_X_무료배포_2_part4

Chaincode Mapping API Interworking Specification



Below is an example tested by referring to the API Interworking Specification.

Chaincode Invoke

tutorial_4

### 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

tutorial_4

### 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.


MDL_X_무료배포_3_part4
MDL Manager Tutorial [Channel]

Related Posts