ubuntu 22.04
golang 1.18
fabric 2.4.3
docker-compose
IPFS
(The golang version cannot be too high. It is found that versions above 1.18 will cause fabric-sdk-go compilation to fail.)
1.1 clone the repository
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-sample
git checkout v2.4.3
1.2 download binary files
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 ../
1.3 download docker images
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
1.3 start the fabric test network
cd test-network
./network.sh down
./network.sh up
1.4 create the channel
./network.sh createChannel
you should see:
2.1 copy repository contract folder to test-network
cp -r {repo_path}/CP-ABE-Blockchain/contract .
cd contract/
go mod vendor
2.2 deploy the contract
./network.sh deployCC -ccn DTModeling -ccp contract -ccl go
3.1 copy the fabric certificates to config folder
cd CP-ABE-Blockchain/config
cp -r {fabric-sample-path}/test-network/organizations/* .
3.2 test if can connect to fabric
cd ../
go test -v ./test/ -run=TestGetBlockData
(If you don't want to start IPFS, you need to change the shareFileToIpfs
method in device.go
)
4.1 download IPFS
wget https://dist.ipfs.tech/kubo/v0.29.0/kubo_v0.29.0_linux-amd64.tar.gz
tar -xvzf kubo_v0.29.0_linux-amd64.tar.gz
cd kubo
./ipfs init
./ipfs daemon
4.1 start the AS server
go run main.go
4.2 run the CP_ABE_Blockchain_test
go test -v test/CP_ABE_Blockchain_test.go