HyperLedger

하이퍼레저에 대한 정리

Featured image

HyperLedger fabric 예제

필수 사항 ubuntu or Mac Git, CURL, Docker, Docker Compose, nodejs, npm 의 설치가 필요합니다.

환경 설치

Git 설치
sudo apt install git
git version

CURl 설치
apt-get install curl

Docker 설치
sudo apt-get install docker-ce docker-ce-cli
docker -v

Docker Comper 설치
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

sudo apt install nodejs
node -v

sudo apt install npm
npm -v

HyperLedger 샘플파일 설치

curl -sSL https://bit.ly/2ysbOFE | bash -s

Fabric test network를 통해 node 생성

 ./network.sh up

mychannel 생성
 /network.sh createChannel

옵션 c를 이용하여 이름 생성
 ./network.sh createChannel -c channel1

또한 아래 명령어를 사용한다면 테스트 노드와 채널을 동시에 만들수있습니다.
 ./network.sh up createChannel

ChainCode 생성 및 실행하기

./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
//peer CLI
export PATH=${PWD}/../bin:$PATH

//core.yaml
export FABRIC_CFG_PATH=$PWD/../config/

export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
[
{"ID": "asset1", "color": "blue", "size": 5, "owner": "Tomoko", "appraisedValue": 300},
{"ID": "asset2", "color": "red", "size": 5, "owner": "Brad", "appraisedValue": 400},
{"ID": "asset3", "color": "green", "size": 10, "owner": "Jin Soo", "appraisedValue": 500},
{"ID": "asset4", "color": "yellow", "size": 10, "owner": "Max", "appraisedValue": 600},
{"ID": "asset5", "color": "black", "size": 15, "owner": "Adriana", "appraisedValue": 700},
{"ID": "asset6", "color": "white", "size": 15, "owner": "Michel", "appraisedValue": 800}
]

에러 발생