# FabCar as an external service
See the "Chaincode as an external service" documentation for running chaincode as an external service.
This includes details of the external builder and launcher scripts which will peers in your Fabric network will require.
The FabCar chaincode requires two environment variables to run, `CHAINCODE_SERVER_ADDRESS` and `CORE_CHAINCODE_ID_NAME`, which are described in the `chaincode.env.example` file. Copy this file to `chaincode.env` before continuing.
**Note:** each organization in a Fabric network will need to follow the instructions below to host their own instance of the FabCar external service.
## Packaging and installing
Make sure the value of `CHAINCODE_SERVER_ADDRESS` in `chaincode.env` is correct for the FabCar external service you will be running.
The peer needs a `connection.json` configuration file so that it can connect to the external FabCar service.
Use the `CHAINCODE_SERVER_ADDRESS` value in `chaincode.env` to create the `connection.json` file with the following command (requires [jq](https://stedolan.github.io/jq/)):
```
env $(cat chaincode.env | grep -v "#" | xargs) jq -n '{"address":env.CHAINCODE_SERVER_ADDRESS,"dial_timeout": "10s","tls_required": false}' > connection.json
```
Add this file to a `code.tar.gz` archive ready for adding to a FabCar external service package:
```
tar cfz code.tar.gz connection.json
```
Package the FabCar external service using the supplied `metadata.json` file:
```
tar cfz fabcar-pkg.tgz metadata.json code.tar.gz
```
Install the `fabcar-pkg.tgz` chaincode as usual, for example:
```
peer lifecycle chaincode install ./fabcar-pkg.tgz
```
## Running the FabCar external service
To run the service in a container, build a FabCar docker image:
```
docker build -t hyperledger/fabcar-sample .
```
Edit the `chaincode.env` file to configure the `CHAINCODE_ID` variable before starting a FabCar container using the following command:
```
docker run -it --rm --name fabcar.org1.example.com --hostname fabcar.org1.example.com --env-file chaincode.env --network=net_test hyperledger/fabcar-sample
```
## Starting the FabCar external service
Complete the remaining lifecycle steps to start the FabCar chaincode!
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
bin.zip (87个子文件)
bin
discover 16.01MB
fabric-ca-client 24.77MB
configtxlator 14.27MB
ledgerutil 16.28MB
crypto-config.yaml 2KB
cryptogen 10.76MB
configtxgen 17.26MB
configtx.yaml 22KB
orderer 28.86MB
peer 45.75MB
osnadmin 12.43MB
channel-artifacts
docker-compose-org2-2peer.yaml 7KB
docker-compose-org1-2peer.yaml 7KB
chaincode
sacc
go.mod 237B
go.sum 5KB
sacc_test.go 4KB
sacc.go 3KB
marbles02
go
go.mod 245B
go.sum 5KB
marbles_chaincode.go 31KB
META-INF
statedb
couchdb
indexes
indexOwner.json 99B
javascript
marbles_chaincode.js 20KB
package.json 318B
.gitignore 1KB
META-INF
statedb
couchdb
indexes
indexOwner.json 99B
marbles02_private
go
go.mod 1KB
go.sum 47KB
marbles_chaincode_private.go 22KB
META-INF
statedb
couchdb
collections
collectionMarbles
indexes
indexOwner.json 99B
collections_config.json 381B
fabcar
go
go.mod 1KB
fabcar.go 4KB
go.sum 47KB
Dockerfile 333B
metadata.json 47B
chaincode.env.example 413B
.gitignore 44B
.dockerignore 42B
README.md 2KB
typescript
.editorconfig 231B
src
car.ts 200B
fabcar.ts 4KB
index.ts 162B
tslint.json 558B
package.json 2KB
.gitignore 1KB
tsconfig.json 308B
java
gradle
wrapper
gradle-wrapper.jar 54KB
gradle-wrapper.properties 202B
src
test
java
org
hyperledger
fabric
samples
fabcar
FabCarTest.java 10KB
CarQueryResultTest.java 3KB
CarTest.java 2KB
main
java
org
hyperledger
fabric
samples
fabcar
FabCar.java 7KB
CarQueryResult.java 2KB
Car.java 2KB
gradlew.bat 3KB
build.gradle 2KB
settings.gradle 75B
gradlew 6KB
.gitignore 804B
README.md 740B
config
checkstyle
checkstyle.xml 7KB
suppressions.xml 275B
javascript
.editorconfig 231B
lib
fabcar.js 4KB
.eslintrc.js 1014B
package.json 1KB
index.js 221B
.gitignore 1KB
.eslintignore 52B
abstore
go
go.mod 1KB
go.sum 47KB
abstore.go 4KB
java
gradle
wrapper
gradle-wrapper.jar 54KB
gradle-wrapper.properties 202B
src
main
java
org
hyperledger
fabric-samples
ABstore.java 5KB
gradlew.bat 3KB
build.gradle 648B
settings.gradle 128B
gradlew 6KB
.gitignore 804B
javascript
abstore.js 3KB
package.json 308B
.gitignore 1KB
README.md 2KB
docker-compose-3orderer.yaml 11KB
fabric-ca-server 31.13MB
共 87 条
- 1
资源评论
m0_60999912
- 粉丝: 4
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功