fabric2.2.0内部链码安装及调用(生产环境)_fabric 系统链码调用-程序员宅基地

技术标签: 区块链  

生成创世块 (在orderer节点上生成)在configtx.yaml文件目录

configtxgen -profile OrgsOrdererGenesis -outputBlock /tmp/hyperledger/org0/orderer/genesis.block -channelID syschannel  (系统名)

创建通道交易 (在orderer节点上生成) 将mycc.tx文件复制到创建通道的peer节点–在configtx.yaml文件目录

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx  /etc/hyperledger/organizations/mycc.tx -channelID mycc  //指定链码名称

导入证书

root@peer0:/etc/hyperledger/fabric
# exportCORE_PEER_MSPCONFIGPATH=/etc/hyperledger/organizations/peerOrganizations/org1.hnpmct.com/users/[email protected]/msp

打包链码

peer lifecycle chaincode package test.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label test_1

创建通道,并且需要将生成的mycc.block复制到其他的组织节点上,然后执行加入通道

peer channel create -o orderer.hnpmct.com:7050 -c mycc --ordererTLSHostnameOverride orderer.hnpmct.com -f /etc/hyperledger/fabric/mycc.tx --outputBlock /etc/hyperledger/fabric/mycc.block --tls --cafile /etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem
root@peer0:/etc/hyperledger/fabric# ls
admin  channel.tx  core.yaml  fabcar.tar.gz  msp  mychannel.block  tls

加入通道

root@peer0:/etc/hyperledger/fabric# peer channel join -b /etc/hyperledger/fabric/mycc.block
2020-08-19 16:32:52.129 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-08-19 16:32:52.159 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
root@peer0:/etc/hyperledger/fabric# peer channel list
2020-08-19 16:33:01.036 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Channels peers has joined: 
mychannel

安装链码 (所有节点都需要,orderer节点不需要)

root@peer0:/etc/hyperledger/fabric# peer lifecycle chaincode install fabcar.tar.gz

查询包ID

root@peer0:/etc/hyperledger/fabric# peer lifecycle chaincode queryinstalled
Installed chaincodes on peer:
Package ID: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506, Label: fabcar_1

配置

root@peer0:/etc/hyperledger/fabric# export CC_PACKAGE_ID=fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506

授权

root@peer0:/etc/hyperledger/fabric#  peer lifecycle chaincode approveformyorg -o 192.168.1.86:7050 --ordererTLSHostnameOverride orderer.hnpmct.com --channelID mychannel --name fabcar --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile /etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem
2020-08-19 16:42:35.236 CST [chaincodeCmd] ClientWait -> INFO 001 txid [e4c0b2f6852a95d76c9ab2c080bf059246e26fb18ea6c1f82e69ff8d79af5aae] committed with status (VALID) at 

检查

root@peer0:/etc/hyperledger/fabric#  peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls --cafile /etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem --output json
{
    
	"approvals": {
    
		"Org1MSP": true,
		"Org2MSP": true,
		"Org3MSP": true,
		"Org4MSP": true
	}
}

提交链码到通道上 (某个peer节点上运行就可以,其他节点同步)

peer lifecycle chaincode commit -o orderer.hnpmct.com:7050 --ordererTLSHostnameOverride orderer.hnpmct.com --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls --cafile /etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem --peerAddresses peer0.org1.hnpmct.com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org1.hnpmct.com/peers/peer0.org1.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org2.hnpmct.com:7151 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org2.hnpmct.com/peers/peer0.org2.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org3.hnpmct.com:7251 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org3.hnpmct.com/peers/peer0.org3.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org4.hnpmct.com:7351 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org4.hnpmct.com/peers/peer0.org4.hnpmct.com/tls/ca.crt
peer lifecycle chaincode commit -o orderer.hnpmct.com:7050 --ordererTLSHostnameOverride orderer.hnpmct.com --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls --cafile 
/etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem 
--peerAddresses peer0.org1.hnpmct.com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org1.hnpmct.com/peers/peer0.org1.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org2.hnpmct.com:7151 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org2.hnpmct.com/peers/peer0.org2.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org3.hnpmct.com:7251 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org3.hnpmct.com/peers/peer0.org3.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org4.hnpmct.com:7351 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org4.hnpmct.com/peers/peer0.org4.hnpmct.com/tls/ca.crt

调用链码初始化

peer chaincode invoke -o orderer.hnpmct.com:7050 --ordererTLSHostnameOverride orderer.hnpmct.com --tls --cafile  /etc/hyperledger/organizations/ordererOrganizations/hnpmct.com/orderers/orderer.hnpmct.com/msp/tlscacerts/tlsca.hnpmct.com-cert.pem -C mychannel -n fabcar --peerAddresses peer0.org1.hnpmct.com:7051 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org1.hnpmct.com/peers/peer0.org1.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org2.hnpmct.com:7151 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org2.hnpmct.com/peers/peer0.org2.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org3.hnpmct.com:7251 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org3.hnpmct.com/peers/peer0.org3.hnpmct.com/tls/ca.crt  --peerAddresses peer0.org4.hnpmct.com:7351 --tlsRootCertFiles /etc/hyperledger/organizations/peerOrganizations/org4.hnpmct.com/peers/peer0.org4.hnpmct.com/tls/ca.crt -c '{"function":"initLedger","Args":[]}'

查询

 peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_40098405/article/details/108200932

智能推荐

ocs2007标准版部署-程序员宅基地

文章浏览阅读64次。microsoft office communication server (ocs)2007标准版部署 实验步骤: 1 创建域并提生域级别 2创建CA证书 3创建SRV记录 4架构扩展 5ocs的安装激活 6ocs配置 7申请证书 8用户配置 9ocs客户端安装及配置 具体步骤: 1创建域病提升域级别 在beijing上 开始-----运行输入dc..._ocs 2007域支持

Android Studio 导入安卓源码步骤_怎么导入别人的android源码-程序员宅基地

文章浏览阅读1.4w次,点赞14次,收藏68次。前言我们做Android系统源码开发,在定位问题的过程中经常要从App层跟踪代码到Framework层中,为了更加方便的查找代码,这时候就需要把整个工程源码导入到Android Studio中,导入后我们也可以通过断点调试,更加快速和准确地定位分析解决问题。操作步骤开发环境: Ubantu 20.4 Android Studio4.2 Android 11(R) 源码步骤一 1. 进入源码根目录,初始化系统环..............._怎么导入别人的android源码

bmp转十六进制hex样例_bmp图片转成hex-程序员宅基地

文章浏览阅读2.8k次。// $ xxd -i logo.bmp logo.h#include //TO_DO ++++++++unsigned char logo_bmp[] = { 0x42, 0x4d, 0xde, 0xc9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x0_bmp图片转成hex

欲望你真的清楚么?-程序员宅基地

文章浏览阅读837次。一、问题何为欲望?二、何为欲望 欲望(Desire)是由生物的本性产生的想达到某种目的的要求,欲望无善恶之分,关键在于如何控制。 欲望是世界上所有动物最原始的、最基本的一种本能。从人的角度讲是心理到身体的一种渴望、满足,它是一切动物存在必不可少的需求。一切动物最基本的欲望就是生存与存在。简单的来说就是 爱与不满足。 ...

基于微信小程序和SSM的校园二手交易小程序源码+论文+答辩PPT+开题报告+任务书_基于springboot的校园二手商城交易微信小程序开题答辩问题-程序员宅基地

文章浏览阅读269次。二手平台后台功能主要包括:管理员登陆、管理员管理、APP用户管理、留言评论管理、商品管理、商品发布等功能。1.在数据库设计方面,数据表是系统实现的一个难点,用户登录如何区分管理员还是普通用户,多个物品的种类价格处理,这些在数据库的设计上都是需要仔细考虑的;后端:Java+SSM。_基于springboot的校园二手商城交易微信小程序开题答辩问题

Avue-crud常用配置项_avue dicurl 带参数-程序员宅基地

文章浏览阅读2k次,点赞4次,收藏6次。avue的一些配置1.表格option配置项<avue-crud :option="option" ref="crud" //表格常用事件 @on-load="getList"//这个事件会在表格所在的组件加载时就会执行后面的getList方法,初始化表格数据。并且当表格翻页或者pageSize变化时候也会自动执行该方法,这时候表格绑定的 :page.sync="page"中的page的值也会随时更新,当页面大小变化时,还会自己将页面变为1 如果使用了这个方法 其实表格的_avue dicurl 带参数

随便推点

【推荐】骡友们推荐的各个学习英文网站的汇总【选择自CSDN i_like_cpp 的 Blog】...-程序员宅基地

文章浏览阅读2.9k次。骡友们推荐的各个学习英文网站的汇总。--------------------------------------------------------------------------------http://www.edunet.com/elt 主题:是一个全方位的学英语作为第二语言的网站 功能:聊天室,语法讲解,练习,小测试,成语讲解 特色:特别深入地介绍了语法,听力,沟通技巧等 对象:ESL..._qc 学习网站

DCN神州数码WAF-P-2021命令行恢复出厂_dcn-waf怎么用console重置-程序员宅基地

文章浏览阅读213次。注意:执行该命令将会清除设备的所有配置信息,包括网络配置、安全策略等,并将设备恢复到出厂设置时的默认配置。在执行该操作之前,请务必备份重要的设备配置信息。启动后,网线接G5口web登陆https://192.168.254.1输入帐号密码admin/yunke1234!Console接入波特率9600,输入帐号密码admin/yunke1234!进入后输入facroryreset -R回车,设备自动重启。_dcn-waf怎么用console重置

Sophus安装_error: static assertion failed: cannot format an a-程序员宅基地

文章浏览阅读747次。Sophus安装 SLAM 说明fmt安装未成功,安装8.1.1版本的fmt参考:解决办法 Ceres 2.0.0没有manifold.h 修改Sophus/test/ceres/CMakeLists.txt和 Sophus/test/core/CMakeLists.txt 中的下面这句话,使用2.1.0的版本_error: static assertion failed: cannot format an argument. to make type t fo

数据链路层简介_数据链路层的介绍-程序员宅基地

文章浏览阅读3.6k次。学习笔记_数据链路层的介绍

回调函数使用详解_回调函数的用法-程序员宅基地

文章浏览阅读1.7k次,点赞2次,收藏5次。转载自:https://blog.csdn.net/miao19920101/article/details/75648491回调函数的使用回调函数在C语言中是通过函数指针来实现的,通过将回调函数的地址传给被调函数从而实现回调。因此,要实现回调,必须首先定义函数指针。1. 回调指针概念:指针是一个变量,是用来指向内存地址的。一个程序运行时,所有和运行相关的物件都是需要加载到内存中,这..._回调函数的用法

[STM32F0xx]的AD转换驱动程序_stm32f0xx adc_in-程序员宅基地

文章浏览阅读792次。STM32F0xx的AD转换程序。 该例程使用的是PB01引脚,AD功能为ADC_IN9,查数据手册,如下图所示。 首先初始化引脚: void adc_init( void ){ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC1, ENABLE ); GPIO_InitSt..._stm32f0xx adc_in

推荐文章

热门文章

相关标签