fisco-bcos-service

Rust SDK For FISCO BCOS 2.7.0+

安装

toml [dependencies] fisco-bcos-service = "0.2"

此 crate 使用了 TASSL 来处理 TLS 连接,在 LinuxMacos 下无需做任何额外操作,其他环境下则需要指定以下环境变量:

LinuxMacos 下,如果你已经编译好了 TASSL,也可以通过指定以上环境变量来缩短编译时间。

使用

Web3Service

通过方法 create_web3_service 获得 Web3Service 实例

```rust use fiscobcosservice::createweb3service;

let configfilepath = "./configs/config.json"; let web3service = createweb3service(configfile_path).unwrap(); ```

其中 config_file_path 为包含以下信息的 json 文件路径:

json { "service_type": "rpc", "node": { "host": "127.0.0.1", "port": 8545 }, "account": "./accounts/alice.pem", "contract": { "solc": "./bin/solc-0.4.25", "source": "./contracts", "output": "./contracts/.output" }, "authentication": { "ca_cert": "./authentication/gm/gmca.crt", "sign_cert": "./authentication/gm/gmsdk.crt", "sign_key": "./authentication/gm/gmsdk.key", "enc_key": "./authentication/gm/gmensdk.key", "enc_cert": "./authentication/gm/gmensdk.crt" }, "sm_crypto": false, "group_id": 1, "chain_id": 1, "timeout_seconds": 10 }

每一项的解释如下:

注:配置项中 accountcontractauthentication 中的路径如果使用相对路径,它的参考路径为该配置文件所在路径。

自行实例化 Web3Service

如果你不想通过 create_web3_service 创建 Web3Service 实例,亦可参照 createweb3service 的实现自行实例化。

API 列表

注:所有接口均为异步调用(使用了 Rust 的 async 特性)。

License

Apache-2.0