ubuntu 22.04
golang 1.18
fabric 2.4.3
因为fabric-sdk-go v1.0.0只支持到fabric2.4,golang的版本也不能太高,只推荐1.18
后续可能会使用Fabric Gateway取代fabric-sdk-go以支持最新的fabric
但目前暂时继续使用fabric2.4
执行
go mod tidy
运行本地DID测试
go test -v local_did_test.go
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-sample
git checkout v2.4.3
wget https://github.com/hyperledger/fabric/releases/download/v2.4.3/hyperledger-fabric-linux-amd64-2.4.3.tar.gz
wget https://github.com/hyperledger/fabric-ca/releases/download/v1.5.3/hyperledger-fabric-ca-linux-amd64-1.5.3.tar.gz
tar xvzf hyperledger-fabric-linux-amd64-2.4.3.tar.gz
tar xvzf hyperledger-fabric-ca-linux-amd64-1.5.3.tar.gz
cd bin
export PATH=${PWD}:$PATH
cd ../
docker pull hyperledger/fabric-peer:2.4.3
docker pull hyperledger/fabric-orderer:2.4.3
docker pull hyperledger/fabric-ccenv:2.4.3
docker pull hyperledger/fabric-tools:2.4.3
docker pull hyperledger/fabric-baseos:2.4.3
docker pull hyperledger/fabric-ca:1.5.3
docker tag hyperledger/fabric-peer:2.4.3 hyperledger/fabric-peer
docker tag hyperledger/fabric-peer:2.4.3 hyperledger/fabric-peer:2.4
docker tag hyperledger/fabric-orderer:2.4.3 hyperledger/fabric-orderer
docker tag hyperledger/fabric-orderer:2.4.3 hyperledger/fabric-orderer:2.4
docker tag hyperledger/fabric-ccenv:2.4.3 hyperledger/fabric-ccenv
docker tag hyperledger/fabric-ccenv:2.4.3 hyperledger/fabric-ccenv:2.4
docker tag hyperledger/fabric-tools:2.4.3 hyperledger/fabric-tools
docker tag hyperledger/fabric-tools:2.4.3 hyperledger/fabric-tools:2.4
docker tag hyperledger/fabric-baseos:2.4.3 hyperledger/fabric-baseos
docker tag hyperledger/fabric-baseos:2.4.3 hyperledger/fabric-baseos:2.4
docker tag hyperledger/fabric-ca:1.5.3 hyperledger/fabric-ca
docker tag hyperledger/fabric-ca:1.5.3 hyperledger/fabric-ca:1.5
cd test-network
./network.sh down
./network.sh up
./network.sh createChannel
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
cp -r {repo_path}/contract .
cd contract/
go mod tidy
go mod vendor
cd ..
./network.sh deployCC -ccn did -ccp contract -ccl go
cd fabric-did/config
cp -r {fabric-sample-path}/test-network/organizations/* .
cd ../
go test -v -run=TestGetBlockData
如果遇到网络问题,可能需要设置host
{fabric_ip} peer0.org1.example.com
{fabric_ip} peer0.org2.example.com
{fabric_ip} orderer.example.com
go test -v -run=TestCreateDID
上述只是实现了did和vc的链上存储和验证,隐私保护、身份认证等功能敬请期待。