Go to file
2023-06-15 11:31:11 +08:00
src build: config spotless plugin and reformat code 2023-06-15 11:31:11 +08:00
.gitignore update .gitignore 2021-11-02 00:27:09 +08:00
build.gradle build: config spotless plugin and reformat code 2023-06-15 11:31:11 +08:00
LICENSE Initial commit 2021-09-24 09:47:41 +00:00
README.md add simple readme.md 2022-03-09 18:09:22 +08:00

  1. 通过HTTP协议用 直接拼接URL参考https://public.internetapi.cn/docs/bdcontract/doc/ContractAPI.html#id69

使用SDK参考test目录下的SmartContractHttpClientTest.java

//当需要发起签名调用时使用正确的privateKey和publicKey。
SmartContractHttpClient client =
                new SmartContractHttpClient(
                        SM2KeyPair.fromJson(
                                "{\"privateKey\":\"...\",\"publicKey\":\"...\"}"),
                        IP,
                        port);
        System.out.println(client.executeContractAsString(contractID_or_contractName, operation,arg));

2.通过WebSocket调用 使用SDK参考test目录下的SmartClientTest.java

SmartContractClient client = new SmartContractClient("ws://ip:port/SCIDE/SCExecutor") ;
//如果需要指定key也可传入key参数。
//SM2KeyPair key =    SM2KeyPair.fromJson("json格式的密钥对");
//client = new SmartContractClient("...",key);
client.waitForConnect();
client.login();
ContractRequest cr = new ContractRequest();
cr.setContractID("xxx");
cr.setAction("xxx");
cr.setArg("xxx");
JsonObject result = testClient.executeContractSync(cr);