# Hyperledger Korea UserGroup Meetup

# 2019๋…„ 09์›” 21์ผ

# ์ฃผ์ œ

  • ํ•˜์ดํผ๋ ˆ์ € 2.0๊ณผ ์ด์ „ ๋ฒ„์ „๊ณผ์˜ ๋น„๊ต
  • ํ•˜์ดํผ๋ ˆ์ € ํŒจ๋ธŒ๋ฆญ์˜ MSP ๋™์ž‘๋ฐฉ์‹ ํ™•์ธ : ์•„์‰ฌ์›€.
  • Fabric high-throughput : ํฅ๋ฏธ๋กœ์šด ๋ถ€๋ถ„
  • ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๊ธฐ๋ฐ˜ Hyperledger Fabric 30๋ถ„๋งŒ์— ๋ง›๋ณด๊ธฐ : ์‹œ๊ฐ„์ด ์—†์–ด์„œ ๊ฑฐ์˜ ์ง„ํ–‰ ์•ˆํ•จ.

# ํ•˜์ดํผ๋ ˆ์ € 2.0๊ณผ ์ด์ „ ๋ฒ„์ „๊ณผ์˜ ๋น„๊ต

# Token Cli ์„ค์ •

/tmp์— jsonํŒŒ์ผ ์ƒ์„ฑ

  • configorg1.json

    {
      "ChannelID":"",
      "MSPInfo":{
        "MSPConfigPath":"",
        "MSPID":"Org1MSP",
        "MSPType":"bccsp"
      },
      "Orderer":{
        "Address":"orderer.example.com:7050",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem",
        "ServerNameOverride":""
      },
      "CommitterPeer":{
        "Address":"peer0.org1.example.com:7051",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
        "ServerNameOverride":""
      },
      "ProverPeer":{
        "Address":"peer0.org1.example.com:7051",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt",
        "ServerNameOverride":""
      }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
  • configorg2.json

    {
      "ChannelID":"",
      "MSPInfo":{
        "MSPConfigPath":"",
        "MSPID":"Org2MSP",
        "MSPType":"bccsp"
      },
      "Orderer":{
        "Address":"orderer.example.com:7050",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem",
        "ServerNameOverride":""
      },
      "CommitterPeer":{
        "Address":"peer0.org2.example.com:9051",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt",
        "ServerNameOverride":""
      },
      "ProverPeer":{
        "Address":"peer0.org2.example.com:9051",
        "ConnectionTimeout":0,
        "TLSEnabled":true,
        "TLSRootCertFile":"/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt",
        "ServerNameOverride":""
      }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
  • shares.json

    [
      {
      "recipient":"Org2MSP:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp",
      "quantity":"50"
      }
    ]
    
    1
    2
    3
    4
    5
    6

# BYFN ๊ตฌ๋™

# FabToken ์‹ค์Šต์—์„œ ์‚ฌ์šฉํ•  ์„ค์ • ํŒŒ์ผ ํ™•์ธ
$ ls /tmp/*.json
/tmp/configorg1.json  /tmp/configorg2.json  /tmp/shares.json

# BYFN ๊ตฌ๋™
$ cd $HOME/meetup/1906/fabric-samples/first-network/
$ ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=2.0.0
DOCKER_IMAGE_VERSION=2.0.0-alpha
=================== WARNING ===================
  Local fabric binaries and docker images are
  out of  sync. This may cause problems.
...
========= All GOOD, BYFN execution completed ===========
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ cp /tmp/*.json $HOME/meetup/1906/fabric-samples/first-network/crypto-config
$ cd $HOME/meetup/1906/fabric-samples/first-network/crypto-config
$ ls *.json
configorg1.json  configorg2.json  shares.json

1
2
3
4
5

# FabToken ์‹ค์Šต

# CLI ์ปจํ…Œ์ด๋„ˆ ์ ‘์†
$ docker exec -it cli bash
bash-4.4# 
bash-4.4# ls
channel-artifacts/  crypto/             log.txt            mycc.tar.gz        mychannel.block    scripts/
bash-4.4# cd crypto/
# ์„ค์ • ํŒŒ์ผ ํ™•์ธ
bash-4.4# ls
configorg1.json       configorg2.json       ordererOrganizations/  peerOrganizations/     shares.json
bash-4.4#

1
2
3
4
5
6
7
8
9
10
11

Issue

  • ํ† ํฐ๋ช…: BYFNcoins
  • ์ˆ˜๋Ÿ‰: 100
  • ์†Œ์œ ์ž: User1@org1.example.com
bash-4.4# token issue \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp \
--channel mychannel \
--type BYFNcoins \
--quantity 100 \
--recipient Org1MSP:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp

Orderer Status [SUCCESS]
Committed [true]

1
2
3
4
5
6
7
8
9
10
11

List

bash-4.4# token list \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp \
--channel mychannel

{"tx_id":"0b6f347a438399c24c5aa00a78d58a20cd6a89c6700ad3ad0fdccf8f90ee1c54"}
[BYFNcoins,100]

1
2
3
4
5
6
7
8

Transfer

  • Token ID: ๋ชฉ๋ก ์กฐํšŒ๋กœ ํ™•์ธ๋œ "tx_id"ํ‚ค๋ฅผ ํฌํ•จํ•˜๋Š” JSON
  • ์ˆ˜์‹ ์ž: User1@org2.example.com
  • ์ „์†ก ์ˆ˜๋Ÿ‰: 50
bash-4.4# token transfer \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp \
--channel mychannel \
--tokenIDs '[{"tx_id":"0b6f347a438399c24c5aa00a78d58a20cd6a89c6700ad3ad0fdccf8f90ee1c54"}]' \
--shares /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/shares.json

Orderer Status [SUCCESS]
Committed [true]

1
2
3
4
5
6
7
8
9
10

ํ† ํฐ์ˆ˜๋Ÿ‰ ํ™•์ธ

# User1@org1.example.com ํ† ํฐ ์กฐํšŒ
bash-4.4# token list \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp \
--channel mychannel

{"tx_id":"14d97dac90a9acc68432abaad7192eafb46887a2cb8b469b7db43ad07d27e5d1","index":1}
[BYFNcoins,50]

# User1@org2.example.com ํ† ํฐ ์กฐํšŒ
bash-4.4# token list \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg2.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp \
--channel mychannel

{"tx_id":"14d97dac90a9acc68432abaad7192eafb46887a2cb8b469b7db43ad07d27e5d1"}
[BYFNcoins,50]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Redeem

  • Token ID: ๋ชฉ๋ก ์กฐํšŒ๋กœ ํ™•์ธ๋œ "tx_id"ํ‚ค๋ฅผ ํฌํ•จํ•˜๋Š” JSON
  • ์†Œ์œ ์ž: User1@org1.example.com
  • ์ƒํ™˜ ์ˆ˜๋Ÿ‰: 25
bash-4.4# token redeem \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp \
--channel mychannel \
--tokenIDs '[{"tx_id":"14d97dac90a9acc68432abaad7192eafb46887a2cb8b469b7db43ad07d27e5d1","index":1}]' \
--quantity 25

Orderer Status [SUCCESS]
Committed [true]
bash-4.4# token list \
--config /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/configorg1.json \
--mspPath /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp \
--channel mychannel
{"tx_id":"921e4e8efdd8ff8246a3d6d19828b4e2665db6bfaefc1ae6bc73066d75dee1e6","index":1}
[BYFNcoins,25]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15