diff --git a/sample/BCOS-development-guide.md b/sample/BCOS-development-guide.md deleted file mode 100644 index 3cd1085743..0000000000 --- a/sample/BCOS-development-guide.md +++ /dev/null @@ -1,202 +0,0 @@ -[TOC] -# BCOS智能合约客户端开发指导 - -## 概要 -本文档主要提供基于BOSC区块链系统的智能合约应用开发指导,使得开发者能够使用流行的编程语言如Java、Nodejs等进行应用开发。 本文档中包含API介绍及其源码工程, 它们通过简单的范例介绍开发智能合约的方法, 帮助开发者快速入门区块链应用开发。 - -## 运行环境 -* 操作系统:Ubuntu (建议16.04) 或 CentOS (建议7.0) -* BCOS区块链客户端 - -## 智能合约 -智能合约语法及细节参考 **[solidity官方文档](https://solidity.readthedocs.io/en/develop/solidity-in-depth.html)** , **BCOS区块链客户端**建议使用solidity编译器版本指定为0.4.2及以上, 合约编写可以使用任何文本编辑器(推荐使用sublime或vs code+solidity插件)。 - -### 合约范例 -这里例举一个简单的solidity智能合约,仅仅提供数据设置set和读取get方法,其中set为交易类型(Transaction)方法,get为call类型方法。在本文档中将使用这个范例作为唯一合约,展示如何构建操作SimpleStorage智能合约的应用程序。范例如下: -``` -pragma solidity ^0.4.2; - -contract SimpleStorage { - uint storedData; - - function SimpleStorage() { - storedData = 5; - } - - function set(uint x) public { - storedData = x; - } - - function get() constant public returns (uint _ret) { - _ret = storedData; - } -} -``` - -### 合约编译 -1. 首先下载[BCOS工具包]。 -2. 解压[BCOS工具包],比如解压目录: /home/xxx/BCOS-Tools -命令:tar xvzf web3j-2.1.0.tar.gz - -其目录如下: -``` - ├── bin - - │ ├── compile.sh - - │ ├── web3j - - │ └── web3j.bat - - ├── contracts - - │ └── SimpleStorage.sol - - ├── lib - - │ ├── asm-5.0.3.jar - - │ ├── asm-analysis-5.0.3.jar - - │ ├── asm-commons-5.0.3.jar - - │ ├── asm-tree-5.0.3.jar - - │ ├── asm-util-5.0.3.jar - - │ ├── bcprov-jdk15on-1.54.jar - - │ ├── commons-codec-1.9.jar - - │ ├── commons-logging-1.2.jar - - │ ├── core-2.1.0.jar - - │ ├── httpclient-4.5.2.jar - - │ ├── httpcore-4.4.4.jar - - │ ├── jackson-annotations-2.8.0.jar - - │ ├── jackson-core-2.8.5.jar - - │ ├── jackson-databind-2.8.5.jar - - │ ├── javapoet-1.7.0.jar - - │ ├── jffi-1.2.14.jar - - │ ├── jffi-1.2.14-native.jar - - │ ├── jnr-constants-0.9.6.jar - - │ ├── jnr-enxio-0.14.jar - - │ ├── jnr-ffi-2.1.2.jar - - │ ├── jnr-posix-3.0.33.jar - - │ ├── jnr-unixsocket-0.15.jar - - │ ├── jnr-x86asm-1.0.2.jar - - │ ├── rxjava-1.2.4.jar - - │ └── scrypt-1.4.0.jar - - └── output -``` -目录说明: contracts为需要编译的合约目录,bin为编译执行目录,lib为依赖库,output为编译后输出的abi、bin及java文件目录 - - 3. 拷贝编译合约 - -切换到/home/xxx/BCOS-Tools/bin目录,拷贝需要编译的智能合约到/home/xxx/BCOS-Tools/contracts目录 - -执行命令:cd /home/xxx/BCOS-Tools/bin 以及拷贝需要编译的智能合约到/home/xxx/BCOS-Tools/contracts目录 - - 4. 智能合约编译及Java Wrap代码生成 - - 执行命令:sh compile.sh 【参数1:Java包名】 - 执行成功后将在output目录生成所有合约对应abi,bin,java文件,其文件名类似: **合约名字.[abi|bin|java]** 。至此编译完成。 - -## Java智能合约客户端开发 - -### 开发环境及工具 -* BCOS区块链客户端 (参考[BCOS使用文档]) -* JDK -* **solc** solidity编译器(直接使用远程二机制源或源码安装) - * Ubuntu安装 - ```apt install solc ``` 或 源码安装 - * CentOS安装 - ```yum install solc``` 或 源码安装 -* Java [web3j开发库]及其依赖库 - -### web3j介绍 -**[web3j]** 是一个支持以太坊通信协议的客户端网络库,它提供了轻量、反应式、类型安全的Java和Android程序访问能力,使得开发以太坊应用更加便捷,其详细的教程可以参考[官方网站](https://docs.web3j.io/) 。在本范例中sample程序将使用 **[web3j]** 及相关库来开发Java应用程序,基于web3j的应用开发的流程为: -1. 使用智能合约的abi和bin文件生成智能合约Java Wrapper类, 参考BCOS-Tools工具包的使用; -2. 初始化web3j远程调用对象; -3. 使用智能合约Java Wrapper类提供的load或deploy接口获取智能合约远程调用对象;(其依赖于:web3j远程调用对象) -4. 调用智能合约远程调用对象访问合约,发送交易或call查询。 - -### 构建客户端程序 -#### 创建Java工程 -此处以Eclipse为例 -1. 新建Java工程; -2. 添加web3j及其拓展依赖库, BCOS仓库的tool/java/output/下的web3j-2.1.0_main.jar、web3j-2.1.0-extension.jar,tool/java/third-jars/下所有jar文件; -3. 拷贝编译生成的java文件到工程, 如:SimpleStorage.java ; -#### 编写Java调用代码 -编写区块链应用程序,实际上是通过web3j生成的Java Wrapper类,通过JsonRPC调用和BCOS客户端节点通信,再由客户端返回JsonRPC请求响应。对合约的调用主要包括:web3j的初始,合约对象部署,合约对象加载,合约对象发送交易,合约对象call调用等 -1. web3j初始化 -``` -HttpService httpService = new HttpService(uri);//uri="http://10.10.8.219:8545" -Parity web3j = Parity.build(httpService); -``` -2. 部署合约 - -使用初始化的web3j对象和BcosRawTxManager交易管理器来部署智能合约,如果部署成功, Future对象即会返回合约调用对象 -``` -Future futureSimpleStorage = SimpleStorage.deploy(web3j, new BcosRawTxManager(web3j, credentials, 100, 100), gasPrice, gasLimited, new BigInteger("0")); -SimpleStorage simpleStorage = futureSimpleStorage.get(); -String deployAddr = simpleStorage.getContractAddress(); -``` -3. 载入已经部署的合约 - -合约部署成功后,可以获取到已经部署的合约地址:``` String deployAddr = simpleStorage.getContractAddress(); ``` -利用获取到部署合约地址,初始化的web3j对象和BcosRawTxManager交易管理器,可以载入智能合约调用对象 -``` -SimpleStorage simpleStorage = SimpleStorage.load(deployAddr.toString(), web3j, new BcosRawTxManager(web3j, credentials, 100, 100), gasPrice, gasLimited); -``` -注意: 部署后可以直接使用返回的智能合约对象, 而无需再load载入! - -4. 发送交易 - -发送交易通过直接调用已经部署或载入的智能合约调用对象执行合约对应接口即可, 比如智能合约SimpleStorage.sol的set方法,对应SimpleStorage.java的set方法,名字是相同的。 交易执行成功后将返回Receipt,Receipt包含交易hash和其他信息(如log) -``` -TransactionReceipt receipt = null; -receipt = simpleStorage.set(new Uint256(new BigInteger("1000"))).get(); -``` -5. call查询 - -使用已经部署或载入的智能合约调用对象,直接执行对应智能合约中带constant修饰符的函数,即执行call类型调用 -``` -Uint256 value = simpleStorage.get().get(); -``` - -#### sample工程使用说明 -BCOS参考中直接提供eclipse[sample完整工程](https://github.com/bcosorg/bcos/blob/master/sample/projects/java/sample) , 可以直接导入工程。 -sample工程包括: - 1. lib文件夹, 存放所有依赖开发库; - 2. res文件夹,存放测试钱包文件和配置文件 - * wallet.json,BCOS客户端钱文件(和以太坊钱包文件一样) - * config.json,工程运行配置文件,详细说明参考readme.txt -3. bin文件夹, 程序运行目录 -导入工程后,配置好config.json对应rpc_host和rpc_port即可进行SimpleStorage合约的调测 - -## Nodejs智能合约客户端开发 - -********************************************************* -[web3j开发库]:https://github.com/bcosorg/bcos/blob/master/tool/java/output/ -[第三方依赖库]:https://github.com/bcosorg/bcos/blob/master/tool/java/third-part/ -[BCOS使用文档]:https://github.com/bcosorg/bcos/blob/master/doc/manual/manual.md -[BCOS工具包]:https://github.com/bcosorg/bcos/blob/master/sample/dependencies/BCOS-Tools.tar.gz -[web3j]:https://docs.web3j.io/ \ No newline at end of file diff --git a/sample/config.json.template b/sample/config.json.template deleted file mode 100755 index 71f86cc670..0000000000 --- a/sample/config.json.template +++ /dev/null @@ -1,29 +0,0 @@ -{ - "sealEngine": "PBFT", - "systemproxyaddress":"0x0", - "systemproxyaddressDfsFile":"", - "systemproxyaddressDfsServer":"", - "listenip":"{ip}", - "rpcport":"{rpcport}", - "p2pport":"{p2pport}", - "wallet":"{nodedir}keys.info", - "keystoredir":"{nodedir}keystore/", - "datadir":"{nodedir}data/", - "vm":"interpreter", - "networkid":"{networkid}", - "logverbosity":"4", - "coverlog":"OFF", - "eventlog":"ON", - "logconf":"{nodedir}log.conf", - "dfsNode":"", - "dfsGroup":"group1", - "dfsStorage":"filestorage", - "params": { - "accountStartNonce": "0x0", - "maximumExtraDataSize": "0x0", - "tieBreakingGas": false, - "blockReward": "0x0", - "networkID" : "0x0" - }, - "NodeextraInfo":{nodeextrainfo} -} diff --git a/sample/contracts/SimpleStorage.sol b/sample/contracts/SimpleStorage.sol deleted file mode 100644 index 326047dcaf..0000000000 --- a/sample/contracts/SimpleStorage.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity ^0.4.2; - -contract SimpleStorage { - uint storedData; - - function SimpleStorage() { - storedData = 5; - } - - function set(uint x) public { - storedData = x; - } - - function get() constant public returns (uint _ret) { - _ret = storedData; - } -} diff --git a/sample/contracts/output/SimpleStorage.abi b/sample/contracts/output/SimpleStorage.abi deleted file mode 100644 index f0a87c8017..0000000000 --- a/sample/contracts/output/SimpleStorage.abi +++ /dev/null @@ -1 +0,0 @@ -[{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"_ret","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}] \ No newline at end of file diff --git a/sample/contracts/output/SimpleStorage.bin b/sample/contracts/output/SimpleStorage.bin deleted file mode 100644 index 22cce47640..0000000000 --- a/sample/contracts/output/SimpleStorage.bin +++ /dev/null @@ -1 +0,0 @@ -6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029 \ No newline at end of file diff --git a/sample/contracts/output/SimpleStorage.java b/sample/contracts/output/SimpleStorage.java deleted file mode 100644 index 7b5e1c6f6d..0000000000 --- a/sample/contracts/output/SimpleStorage.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.bcos.sample; - -import java.lang.String; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collections; -import java.util.concurrent.Future; -import org.web3j.abi.TypeReference; -import org.web3j.abi.datatypes.Function; -import org.web3j.abi.datatypes.Type; -import org.web3j.abi.datatypes.generated.Uint256; -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.tx.Contract; -import org.web3j.tx.TransactionManager; - -/** - *

Auto generated code.
- * Do not modify!
- * Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update. - * - *

Generated with web3j version none. - */ -public final class SimpleStorage extends Contract { - private static final String BINARY = "6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029"; - - private SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - super(contractAddress, web3j, credentials, gasPrice, gasLimit); - } - - private SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - super(contractAddress, web3j, transactionManager, gasPrice, gasLimit); - } - - public Future set(Uint256 x) { - Function function = new Function("set", Arrays.asList(x), Collections.>emptyList()); - return executeTransactionAsync(function); - } - - public Future get() { - Function function = new Function("get", - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeCallSingleValueReturnAsync(function); - } - - public static Future deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) { - return deployAsync(SimpleStorage.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialValue); - } - - public static Future deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) { - return deployAsync(SimpleStorage.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialValue); - } - - public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - return new SimpleStorage(contractAddress, web3j, credentials, gasPrice, gasLimit); - } - - public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - return new SimpleStorage(contractAddress, web3j, transactionManager, gasPrice, gasLimit); - } -} diff --git a/sample/dependencies/BCOS_Tools.tar.gz b/sample/dependencies/BCOS_Tools.tar.gz deleted file mode 100644 index cb3685a66a..0000000000 Binary files a/sample/dependencies/BCOS_Tools.tar.gz and /dev/null differ diff --git a/sample/genesis.json.template b/sample/genesis.json.template deleted file mode 100755 index df6527d313..0000000000 --- a/sample/genesis.json.template +++ /dev/null @@ -1,13 +0,0 @@ -{ - "nonce": "0x0", - "difficulty": "0x0", - "mixhash": "0x0", - "coinbase": "0x0", - "timestamp": "0x0", - "parentHash": "0x0", - "extraData": "0x0", - "gasLimit": "0x13880000000000", - "god":"{admin}", - "alloc": {}, - "initMinerNodes":{initMinerNodes} -} \ No newline at end of file diff --git a/sample/init.js b/sample/init.js deleted file mode 100755 index 62c0b8fb98..0000000000 --- a/sample/init.js +++ /dev/null @@ -1,137 +0,0 @@ -var fs=require('fs'); -var execSync =require('child_process').execSync; - -var options = process.argv; -if( options.length < 3 ) -{ - console.log('Usage: node init.js node0.sample node1.sample node2.sample... '); - process.exit(0); -} - -var nodeconfiglength=0; -var nodeconfig=[]; -while(nodeconfig.length - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sample/projects/java/sample/.gitignore b/sample/projects/java/sample/.gitignore deleted file mode 100644 index ae3c172604..0000000000 --- a/sample/projects/java/sample/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/sample/projects/java/sample/.project b/sample/projects/java/sample/.project deleted file mode 100644 index 776cf27c5b..0000000000 --- a/sample/projects/java/sample/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - sample - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/sample/projects/java/sample/lib/asm-5.0.3.jar b/sample/projects/java/sample/lib/asm-5.0.3.jar deleted file mode 100644 index 573535b1d5..0000000000 Binary files a/sample/projects/java/sample/lib/asm-5.0.3.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/asm-analysis-5.0.3.jar b/sample/projects/java/sample/lib/asm-analysis-5.0.3.jar deleted file mode 100644 index 8b73cf09d7..0000000000 Binary files a/sample/projects/java/sample/lib/asm-analysis-5.0.3.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/asm-commons-5.0.3.jar b/sample/projects/java/sample/lib/asm-commons-5.0.3.jar deleted file mode 100644 index 514a6dc2e1..0000000000 Binary files a/sample/projects/java/sample/lib/asm-commons-5.0.3.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/asm-tree-5.0.3.jar b/sample/projects/java/sample/lib/asm-tree-5.0.3.jar deleted file mode 100644 index e7eae53576..0000000000 Binary files a/sample/projects/java/sample/lib/asm-tree-5.0.3.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/asm-util-5.0.3.jar b/sample/projects/java/sample/lib/asm-util-5.0.3.jar deleted file mode 100644 index e89f1b7b67..0000000000 Binary files a/sample/projects/java/sample/lib/asm-util-5.0.3.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/bcprov-jdk15on-1.54.jar b/sample/projects/java/sample/lib/bcprov-jdk15on-1.54.jar deleted file mode 100644 index bd95185ae8..0000000000 Binary files a/sample/projects/java/sample/lib/bcprov-jdk15on-1.54.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/commons-codec-1.9.jar b/sample/projects/java/sample/lib/commons-codec-1.9.jar deleted file mode 100644 index ef35f1c50d..0000000000 Binary files a/sample/projects/java/sample/lib/commons-codec-1.9.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/commons-io-2.5.jar b/sample/projects/java/sample/lib/commons-io-2.5.jar deleted file mode 100644 index 1234918271..0000000000 Binary files a/sample/projects/java/sample/lib/commons-io-2.5.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/commons-logging-1.2.jar b/sample/projects/java/sample/lib/commons-logging-1.2.jar deleted file mode 100644 index 93a3b9f6db..0000000000 Binary files a/sample/projects/java/sample/lib/commons-logging-1.2.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/fastjson-1.2.24.jar b/sample/projects/java/sample/lib/fastjson-1.2.24.jar deleted file mode 100644 index 4a6652fb5a..0000000000 Binary files a/sample/projects/java/sample/lib/fastjson-1.2.24.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/httpclient-4.5.2.jar b/sample/projects/java/sample/lib/httpclient-4.5.2.jar deleted file mode 100644 index 701609fcc8..0000000000 Binary files a/sample/projects/java/sample/lib/httpclient-4.5.2.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/httpcore-4.4.4.jar b/sample/projects/java/sample/lib/httpcore-4.4.4.jar deleted file mode 100644 index ac4a877302..0000000000 Binary files a/sample/projects/java/sample/lib/httpcore-4.4.4.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/httpmime-4.3.1.jar b/sample/projects/java/sample/lib/httpmime-4.3.1.jar deleted file mode 100644 index 2b26d7a79c..0000000000 Binary files a/sample/projects/java/sample/lib/httpmime-4.3.1.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jackson-annotations-2.8.0.jar b/sample/projects/java/sample/lib/jackson-annotations-2.8.0.jar deleted file mode 100644 index d19b67b0f1..0000000000 Binary files a/sample/projects/java/sample/lib/jackson-annotations-2.8.0.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jackson-core-2.8.5.jar b/sample/projects/java/sample/lib/jackson-core-2.8.5.jar deleted file mode 100644 index 05e1be2922..0000000000 Binary files a/sample/projects/java/sample/lib/jackson-core-2.8.5.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jackson-databind-2.8.5.jar b/sample/projects/java/sample/lib/jackson-databind-2.8.5.jar deleted file mode 100644 index 2794824673..0000000000 Binary files a/sample/projects/java/sample/lib/jackson-databind-2.8.5.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/javapoet-1.7.0.jar b/sample/projects/java/sample/lib/javapoet-1.7.0.jar deleted file mode 100644 index 207af05755..0000000000 Binary files a/sample/projects/java/sample/lib/javapoet-1.7.0.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jffi-1.2.14-native.jar b/sample/projects/java/sample/lib/jffi-1.2.14-native.jar deleted file mode 100644 index 3ba318dc20..0000000000 Binary files a/sample/projects/java/sample/lib/jffi-1.2.14-native.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jffi-1.2.14.jar b/sample/projects/java/sample/lib/jffi-1.2.14.jar deleted file mode 100644 index b912ebc22b..0000000000 Binary files a/sample/projects/java/sample/lib/jffi-1.2.14.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-constants-0.9.6.jar b/sample/projects/java/sample/lib/jnr-constants-0.9.6.jar deleted file mode 100644 index 751de97ae7..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-constants-0.9.6.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-enxio-0.14.jar b/sample/projects/java/sample/lib/jnr-enxio-0.14.jar deleted file mode 100644 index 95bc904056..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-enxio-0.14.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-ffi-2.1.2.jar b/sample/projects/java/sample/lib/jnr-ffi-2.1.2.jar deleted file mode 100644 index 576db97f6c..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-ffi-2.1.2.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-posix-3.0.33.jar b/sample/projects/java/sample/lib/jnr-posix-3.0.33.jar deleted file mode 100644 index 50ca448984..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-posix-3.0.33.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-unixsocket-0.15.jar b/sample/projects/java/sample/lib/jnr-unixsocket-0.15.jar deleted file mode 100644 index 91eca2c10f..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-unixsocket-0.15.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/jnr-x86asm-1.0.2.jar b/sample/projects/java/sample/lib/jnr-x86asm-1.0.2.jar deleted file mode 100644 index dd4e695f3b..0000000000 Binary files a/sample/projects/java/sample/lib/jnr-x86asm-1.0.2.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/rxjava-1.2.4.jar b/sample/projects/java/sample/lib/rxjava-1.2.4.jar deleted file mode 100644 index c8961dbf60..0000000000 Binary files a/sample/projects/java/sample/lib/rxjava-1.2.4.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/scrypt-1.4.0.jar b/sample/projects/java/sample/lib/scrypt-1.4.0.jar deleted file mode 100644 index 7ebd8dee0d..0000000000 Binary files a/sample/projects/java/sample/lib/scrypt-1.4.0.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/web3j-2.1.0-extension.jar b/sample/projects/java/sample/lib/web3j-2.1.0-extension.jar deleted file mode 100644 index c5d76d251f..0000000000 Binary files a/sample/projects/java/sample/lib/web3j-2.1.0-extension.jar and /dev/null differ diff --git a/sample/projects/java/sample/lib/web3j-2.1.0_main.jar b/sample/projects/java/sample/lib/web3j-2.1.0_main.jar deleted file mode 100644 index 3ac1b696d4..0000000000 Binary files a/sample/projects/java/sample/lib/web3j-2.1.0_main.jar and /dev/null differ diff --git a/sample/projects/java/sample/res/config.json b/sample/projects/java/sample/res/config.json deleted file mode 100644 index 293b91231c..0000000000 --- a/sample/projects/java/sample/res/config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ -"rpc_host" : "10.10.8.219", -"rpc_port" : 8545, -"contract_binary": "6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029", -"contract_abi" : [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"_ret","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}], -"wallet" : "wallet.json", -"password" : "1111" -} \ No newline at end of file diff --git a/sample/projects/java/sample/res/readme.txt b/sample/projects/java/sample/res/readme.txt deleted file mode 100644 index 07acfc2180..0000000000 --- a/sample/projects/java/sample/res/readme.txt +++ /dev/null @@ -1,10 +0,0 @@ -***** res/* file information ******* -1. config.json -config file for the sample project - rpc_host, the remote BCOS client jsonrpc host address - rpc_port, the remote BCOS client jsonrpc port - contract_abi, the SimpleStorage contract abi structure - contract_binary, binaray data of the SimpleStorage - -2. wallet.json -the wallet file of account 03aa3e823cb7899b7b589ea242cdc2f26717d5fc, with password "1111" \ No newline at end of file diff --git a/sample/projects/java/sample/res/wallet.json b/sample/projects/java/sample/res/wallet.json deleted file mode 100644 index 24843520d8..0000000000 --- a/sample/projects/java/sample/res/wallet.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "address" : "03aa3e823cb7899b7b589ea242cdc2f26717d5fc", - "crypto" : { - "cipher" : "aes-128-ctr", - "cipherparams" : { - "iv" : "22efe1f878d20365ea798283fac6379d" - }, - "ciphertext" : "1d2a90f5bdc6cbf4856e6901fa6c75e81ed191bbc825be0078338581e91fdef7", - "kdf" : "scrypt", - "kdfparams" : { - "dklen" : 32, - "n" : 262144, - "p" : 1, - "r" : 8, - "salt" : "566e56528fec3668e69a1216bb1ad7652303d921355b1e55994c84de62955c80" - }, - "mac" : "0bc5b41f21c5271187bc9459e45c4158e39f22e2fdf75cc7aa1925934ef68bdb" - }, - "id" : "2429feaf-0e46-ddd5-5b72-0594e0a4ab00", - "version" : 3 -} \ No newline at end of file diff --git a/sample/projects/java/sample/src/org/bcos/sample/app/BcosApp.java b/sample/projects/java/sample/src/org/bcos/sample/app/BcosApp.java deleted file mode 100644 index d8874d1c1d..0000000000 --- a/sample/projects/java/sample/src/org/bcos/sample/app/BcosApp.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.bcos.sample.app; - -import java.awt.print.Printable; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.math.BigInteger; -import java.net.URL; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -import org.bcos.sample.web3j.SimpleStorage; -import org.bcos.web3j.tx.BcosRawTxManager; -import org.w3c.dom.html.HTMLAnchorElement; -import org.web3j.abi.datatypes.Address; -import org.web3j.abi.datatypes.generated.Uint256; -import org.web3j.crypto.Credentials; -import org.web3j.crypto.WalletUtils; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.protocol.http.HttpService; -import org.web3j.protocol.parity.Parity; - -import com.alibaba.fastjson.JSON; - -public class BcosApp { - private BcosConfig configure; - private Address deployAddress; - private SimpleStorage simpleStorage; - private Parity web3j; - private Credentials credentials; - - public static BigInteger gasPrice = new BigInteger("99999999999"); - public static BigInteger gasLimited = new BigInteger("9999999999999"); - public static BigInteger initialValue = new BigInteger("0"); - - public BcosApp() { - configure = null; - deployAddress = null; - simpleStorage = null; - credentials = null; - web3j = null; - } - - public BcosConfig loadConfig(){ - URL path = Thread.currentThread().getContextClassLoader().getResource(""); - String strFile = (path.getPath() + "../res/config.json"); - System.out.println("the path: " + strFile); - - File file = new File(strFile); - if (!file.exists()) { - System.err.println("*** config file not exists ***"); - return null; - } - - FileReader fReader = null; - - char cbuf[] = new char[4096]; - StringBuffer configString = new StringBuffer(); - try { - fReader = new FileReader(file); - int fileLen = (int)file.length(); - int bytes = 0; - bytes = fReader.read(cbuf, 0, 4096); - if (bytes == fileLen) { - configString.append(cbuf, 0, bytes); - } - else { - while(bytes < fileLen) { - int nRead = fReader.read(cbuf, 0, 4096); - if (nRead > 0) { - configString.append(cbuf, 0, nRead); - bytes += nRead; - } - else if (nRead == -1) { - break; - } - else { - System.out.println("*** error in reading config file ***"); - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - fReader.close(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - System.out.println("the config file: \n" + configString.toString()); - - BcosConfig config = JSON.parseObject(configString.toString(), BcosConfig.class); - System.out.println("the config: " + config.toString()); - config.setWallet(path.getPath() + "../res/" + config.getWallet()); - configure = config; - - System.out.println("the wallet: " + config.getWallet()); - try { - // 加载证书 - credentials = WalletUtils.loadCredentials(configure.getPassword(), new File(configure.getWallet())); - System.out.println("address: " + credentials.getAddress()); - - } catch (Exception e) { - e.printStackTrace(); - System.err.println("*** load wallet failed ****"); - return null; - } - - // service url - String uri = "http://"; - uri += configure.getRpc_host(); - uri += ":"; - uri += configure.getRpc_port(); - - HttpService httpService = new HttpService(uri); - web3j = Parity.build(httpService); - return config; - } - - public Address deployContract() { - if (configure == null || web3j == null || credentials == null) - return null; - - Future futureSimpleStorage = SimpleStorage.deploy(web3j, new BcosRawTxManager(web3j, credentials, 100, 100), gasPrice, gasLimited, new BigInteger("0")); - - try { - simpleStorage = futureSimpleStorage.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - System.err.println("*** deploy contract failed *** "); - return null; - } - - System.out.println("deploy success, address: " + simpleStorage.getContractAddress()); - return new Address(simpleStorage.getContractAddress()); - } - - public TransactionReceipt executeTransaction(Address address) { - if (configure == null || web3j == null || credentials == null) - return null; - - if (address != null) { - simpleStorage = SimpleStorage.load(address.toString(), web3j, new BcosRawTxManager(web3j, credentials, 100, 100), gasPrice, gasLimited); - } - - TransactionReceipt receipt = null; - try { - receipt = simpleStorage.set(new Uint256(new BigInteger("1000"))).get(); - } catch (InterruptedException | ExecutionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - System.out.println("execute transaction successully, txHash: " + receipt.getTransactionHash()); - return receipt; - } - - public BigInteger executeCall(Address address) { - if (configure == null || web3j == null || credentials == null) - return null; - - if (address != null) { - simpleStorage = SimpleStorage.load(address.toString(), web3j, new BcosRawTxManager(web3j, credentials, 100, 100), gasPrice, gasLimited); - } - - BigInteger storedData = null; - try { - Uint256 value = simpleStorage.get().get(); - storedData = value.getValue(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - - System.out.println("the call value: " + storedData.intValue()); - return storedData; - } - - /** - * @return the configure - */ - public BcosConfig getConfigure() { - return configure; - } - - /** - * @param configure the configure to set - */ - public void setConfigure(BcosConfig configure) { - this.configure = configure; - } - - /** - * @return the deployAddress - */ - public Address getDeployAddress() { - return deployAddress; - } - - /** - * @param deployAddress the deployAddress to set - */ - public void setDeployAddress(Address deployAddress) { - this.deployAddress = deployAddress; - } -} diff --git a/sample/projects/java/sample/src/org/bcos/sample/app/BcosConfig.java b/sample/projects/java/sample/src/org/bcos/sample/app/BcosConfig.java deleted file mode 100644 index d3fe3f970f..0000000000 --- a/sample/projects/java/sample/src/org/bcos/sample/app/BcosConfig.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.bcos.sample.app; - -public class BcosConfig { - private String rpc_host; - private int rpc_port; - private String contract_binary; - private String contract_abi; - private String wallet; - private String password; - - public BcosConfig() { - } - - /** - * @return the rpc_host - */ - public String getRpc_host() { - return rpc_host; - } - /** - * @param rpc_host the rpc_host to set - */ - public void setRpc_host(String rpc_host) { - this.rpc_host = rpc_host; - } - /** - * @return the rpc_port - */ - public int getRpc_port() { - return rpc_port; - } - /** - * @param rpc_port the rpc_port to set - */ - public void setRpc_port(int rpc_port) { - this.rpc_port = rpc_port; - } - /** - * @return the contract_binary - */ - public String getContract_binary() { - return contract_binary; - } - /** - * @param contract_binary the contract_binary to set - */ - public void setContract_binary(String contract_binary) { - this.contract_binary = contract_binary; - } - /** - * @return the contract_abi - */ - public String getContract_abi() { - return contract_abi; - } - /** - * @param contract_abi the contract_abi to set - */ - public void setContract_abi(String contract_abi) { - this.contract_abi = contract_abi; - } - /** - * @return the wallet - */ - public String getWallet() { - return wallet; - } - /** - * @param wallet the wallet to set - */ - public void setWallet(String wallet) { - this.wallet = wallet; - } - /** - * @return the password - */ - public String getPassword() { - return password; - } - /** - * @param password the password to set - */ - public void setPassword(String password) { - this.password = password; - } -} diff --git a/sample/projects/java/sample/src/org/bcos/sample/app/Main.java b/sample/projects/java/sample/src/org/bcos/sample/app/Main.java deleted file mode 100644 index b5294f9596..0000000000 --- a/sample/projects/java/sample/src/org/bcos/sample/app/Main.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.bcos.sample.app; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.math.BigInteger; -import java.net.URL; - -import org.bcos.sample.web3j.SimpleStorage; -import org.juzix.web3j.protocol.CostomerWeb3j; -import org.juzix.web3j.protocol.CustomerWeb3jFactory; -import org.web3j.abi.datatypes.Address; -import org.web3j.crypto.Credentials; -import org.web3j.crypto.WalletUtils; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.protocol.http.HttpService; -import org.web3j.protocol.parity.Parity; - -import com.alibaba.fastjson.JSON; - -import sun.awt.image.IntegerInterleavedRaster; - -public class Main { - - public static void main(String[] args) { - BcosApp app = new BcosApp(); - - //1. load config of the sample application - BcosConfig configure = app.loadConfig(); - if (configure == null) { - System.err.println("error in load configure, init failed !!!"); - return; - } - System.out.println("load configure successully !"); - - //2. deploy the contract to BCOS blockchain - Address address = app.deployContract(); - if (address == null) { - System.err.println("error in deploy contract !!!"); - return; - } - System.out.println("deploy SimpleStorage success, address: " + address.toString()); - - //3. send Raw Transaction to blockchain - TransactionReceipt receipt = app.executeTransaction(address); - if (receipt == null) { - System.err.println("error in executeTransaction !!!"); - return; - } - System.out.println("execute SimpleStorage transaction success, TxHash: " + receipt.getTransactionHash()); - - //4. send call jsonrpc to blockchain - BigInteger value = app.executeCall(address); - System.out.println("the call value: " + value.intValue()); - } - -} diff --git a/sample/projects/java/sample/src/org/bcos/sample/web3j/SimpleStorage.java b/sample/projects/java/sample/src/org/bcos/sample/web3j/SimpleStorage.java deleted file mode 100644 index c7568e9d7d..0000000000 --- a/sample/projects/java/sample/src/org/bcos/sample/web3j/SimpleStorage.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.bcos.sample.web3j; - -import java.lang.String; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collections; -import java.util.concurrent.Future; -import org.web3j.abi.TypeReference; -import org.web3j.abi.datatypes.Function; -import org.web3j.abi.datatypes.Type; -import org.web3j.abi.datatypes.generated.Uint256; -import org.web3j.crypto.Credentials; -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.tx.Contract; -import org.web3j.tx.TransactionManager; - -/** - *

Auto generated code.
- * Do not modify!
- * Please use {@link org.web3j.codegen.SolidityFunctionWrapperGenerator} to update. - * - *

Generated with web3j version none. - */ -public final class SimpleStorage extends Contract { - private static final String BINARY = "6060604052341561000c57fe5b5b60056000819055505b5b60c6806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820df8a57eee7fa3751dd1a8cc753a935ac3cdd07b391e14b64c76b42b3389715950029"; - - private SimpleStorage(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - super(contractAddress, web3j, credentials, gasPrice, gasLimit); - } - - private SimpleStorage(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - super(contractAddress, web3j, transactionManager, gasPrice, gasLimit); - } - - public Future set(Uint256 x) { - Function function = new Function("set", Arrays.asList(x), Collections.>emptyList()); - return executeTransactionAsync(function); - } - - public Future get() { - Function function = new Function("get", - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeCallSingleValueReturnAsync(function); - } - - public static Future deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) { - return deployAsync(SimpleStorage.class, web3j, credentials, gasPrice, gasLimit, BINARY, "", initialValue); - } - - public static Future deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue) { - return deployAsync(SimpleStorage.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialValue); - } - - public static SimpleStorage load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - return new SimpleStorage(contractAddress, web3j, credentials, gasPrice, gasLimit); - } - - public static SimpleStorage load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - return new SimpleStorage(contractAddress, web3j, transactionManager, gasPrice, gasLimit); - } -} diff --git a/sample/run.sh b/sample/run.sh deleted file mode 100755 index 4fb8b4ff56..0000000000 --- a/sample/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -node init.js node0.sample node1.sample -chmod +x /bcos-data/node0/start0.sh -chmod +x /bcos-data/node1/start1.sh -sh /bcos-data/node0/start0.sh & -sh /bcos-data/node1/start1.sh & \ No newline at end of file diff --git a/sample/start.sh.template b/sample/start.sh.template deleted file mode 100755 index d2502ae306..0000000000 --- a/sample/start.sh.template +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -bcoseth --genesis {genesis} --config {config} -