FISCO BCOS 开发第一个区块链应用
这里只是记录流程、遇到的问题、解决方法以及注意的点
详细见开发文档:[https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/sdk_application.html]
问题:
1、Resolving dependency configuration ‘runtime’ is not allowed
------>见下文:业务逻辑开发
2、could not find method compile() for arguments
------>估计你也跟我一样直接用了它提供的包,直接运行就会报很多错,因为里面的代码很多都过时了,尤其是gradle更新到7.x以后。这里复制文档提供的代码就行。
就是把compile 改成implemention,runtime改成runtimeonly
3、Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository ‘maven(XXX)’ to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
------>https://www.jianshu.com/p/8a0e5191590a
设计智能合约
见文档:https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/sdk_application.html
开发源码
见文档:https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/sdk_application.html
编译智能合约
创建区块链应用项目
安装idea
创建一个Java工程
见文档:https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/sdk_application.html
引入FISCO BCOS Java SDK
更新新代码:
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.9.1')//这里不更新也行,软件会在代码下面用波浪线提示,可以升级也可以不升级。不过里面很多包都提示升级了,建议升级。
配置SDK证书
见文档:
业务逻辑开发
注意此处代码有更新,需要修改不然会报错:
错误信息是:Resolving dependency configuration ‘runtime’ is not allowed
jar {
destinationDir file('dist/apps')
archiveName project.name + '.jar'
exclude '**/*.xml'
exclude '**/*.properties'
exclude '**/*.crt'
exclude '**/*.key'
doLast {
copy {
from configurations.runtimeClasspath//*****此处更新***** #
into 'dist/lib'
}
copy {
from file('src/test/resources/')
into 'dist/conf'
}
copy {
from file('tool/')
into 'dist/'
}
copy {
from file('src/test/resources/contract')
into 'dist/contract'
}
}
}
运行应用
注意先启动FISCO BCOS链:
先进入fisco:
cd /home/xiao/fisco //这是我存放fisco的地址,改成你自己的
启动链:
bash nodes/127.0.0.1/start_all.sh
到这里跟着文档走就可以了。