美文网首页
fabric常用的命令行操作

fabric常用的命令行操作

作者: CodingCode | 来源:发表于2020-05-12 07:49 被阅读0次

    fabric常用的命令行操作

    1. create channel
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        cli.sampleorg.example.com \
        peer channel create \
            -o ${ORDERER_ADDRESS} \
            -c ${CHANNEL} \
            -f /etc/hyperledger/fabric/${CHANNEL}.tx \
            --outputBlock /etc/hyperledger/fabric/${CHANNEL}.block \
            ${TLS_CAFILE}
    
    1. peer join channel
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer channel join -b /etc/hyperledger/fabric/${CHANNEL}.block \
    
    1. install chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode install -n ${CHAINCODE} -v ${VERSION} -p ${CHAINCODEPATH} \
    
    1. instantiate chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode instantiate \
            -o ${ORDERER_ADDRESS} \
            -C ${CHANNEL} \
            -n ${CHAINCODE} \
            -v ${VERSION} \
            -c '{"Args":["init","a","1000","b","2000"]}' \
            ${TLS_CAFILE}
    
    1. invoke chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode invoke \
            -o ${ORDERER_ADDRESS} \
            -C ${CHANNEL} \
            -n ${CHAINCODE} \
            -c '{"Args":["invoke", "a", "b", "1"]}' \
            ${TLS_CAFILE}
    
    1. query chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode query \
            -C ${CHANNEL} \
            -n ${CHAINCODE} \
            -c '{"Args":["query","a"]}' \
            ${TLS_CAFILE}
    
    1. query installed chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode invoke \
            -o ${ORDERER_ADDRESS}  \
            -C ${CHANNEL} \
            -n lscc -c '{"Args":["getinstalledchaincodes"]}' \
            --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE}
    
    1. query instantiated chaincode
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode invoke \
            -o ${ORDERER_ADDRESS}  \
            -C ${CHANNEL} \
            -n lscc -c '{"Args":["getchaincodes"]}' \
            --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE}
    
    1. query channel info
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode invoke \
            -o ${ORDERER_ADDRESS}  \
            -C ${CHANNEL} \
            -n qscc -c '{"Args":["GetChainInfo","mychannel"]}' \
            --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE}
    
    1. query transaction info
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer chaincode invoke \
            -o ${ORDERER_ADDRESS}  \
            -C ${CHANNEL} \
            -n qscc -c '{"Args":["GetTransactionByID","mychannel","1a710b2da8ce4bff039929ac7b9fcd9253137fc1535e06430023d3fb6ce8d617"]}' \
            --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE}
    
    1. query joined channel list
    docker exec \
        -e "CORE_PEER_ID=${PEER_ID}" \
        -e "CORE_PEER_ADDRESS=${PEER_ADDRESS}" \
        -e "CORE_PEER_LOCALMSPID=${PEER_LOCALMSPID}" \
        -e "CORE_PEER_MSPCONFIGPATH=${PEER_ADMIN_MSPCONFIGPATH}" \
        -e "CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED}" \
        -e "CORE_PEER_TLS_ROOTCERT_FILE=${CORE_PEER_TLS_ROOTCERT_FILE}" \
        -e "CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE}" \
        -e "CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE}" \
        cli.sampleorg.example.com \
        peer channel list \
    

    相关文章

      网友评论

          本文标题:fabric常用的命令行操作

          本文链接:https://www.haomeiwen.com/subject/vydvnhtx.html