116 KiB
BDware SDK
除使用可视化的智能合约在线IDE外,用户还可使用WebSocket接口、Http接口、Bash接口来启动和运行合约.
WebSocketSDK下载与安装
合约SDK提供javascript版本与java版本的客户端。
java客户端的下载链接为:java source和jar 可参考java_source下的README.md及测试用例。
javascript的下载链接为:js SDK 内置的SM2加密库链接:sm2 SDK
建立连接
建立与节点服务器之间的WebSocket连接.
参数
字段 | 值 |
---|---|
url | 建立WebSocket的服务器URL. 使用http 协议时, 前缀为ws:// , 如"ws://localhost:1717/SCIDE/SCExecutor" ; 使用https 协议时, 前缀为wss:// |
msgHandler | 收到服务器WebSocket回复后的回调函数, 用户可自行编写, 也可参考下面提供的示例 |
请求示例
var url = "ws://127.0.0.1:1717/SCIDE/SCExecutor";//与Slave节点建立连接
//var url = "ws://127.0.0.1:1718/NodeCenterWS";//与Manager节点建立连接
var msgHandler = function(m){
console.log("recmsg:");
console.log(m);
};
var onOpenHandler=undefined;
wssocket = createWssocket(url,onOpenHandler,msgHandler);
返回结果示例
{
receiveSeg: [Function (anonymous)],
isSending: false,
sendList: [],
monitor: [Function (anonymous)],
send: [Function (anonymous)],
sendNextSegment: [Function (anonymous)],
isOpen: [Function (anonymous)]
}
ping
ping
服务器测试
参数
字段 | 值 |
---|---|
action | ping |
请求示例
var request = {};
request.action = "ping";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"action":"pong"
}
登录
使用Websocket接口调用需要权限的接口时,不论是连接CenterPortal还是NodePortal必须先登录。 登录的流程有3步:
- 客户端向服务端建立连接,连接建立完成后发送{"action":"getSessionID"}(可在onOpenHandler中实现)
- 服务端收到请求后,会向客户端返回类似{"action":"onGetSessionID","session":"-4959947809200104526_session"}的结果
- 客户端收到onGetSessionID后,会使用本地的公私钥对sessionID进行签名,并调用login接口
- 服务端会返回onLogin的结果,data字段返回的是该公钥对应的角色。
用户角色划分
合约节点的角色划分
在合约节点(NodePortal.html)中分为NodeManager/ContractProvider/ContractInstanceManager/ContractUser四类角色。
角色 | 说明 |
---|---|
NodeManager | 该节点的管理者,拥有用户管理、节点配置等权限 |
ContractProvider | 拥有编辑合约、开发合约代码、运行调试等权限 |
ContractInstanceManager | 拥有启、停合约实例、配置合约实例IO等权限 |
ContractUser | 拥有查看合约实例列表、调用合约等权限 |
Anonymous | 匿名用户,可以调用合约,可以申请成为ContractProvider/InstanceManager等角色 |
接口 | 说明 | 角色 |
---|---|---|
changeDumpPeriod | 设置备份周期 | ContractInstanceManager; |
createLedger | 创建账本 | ContractInstanceManager; |
dumpContract | 手动备份 | ContractInstanceManager; |
deleteMemoryFile | 删除镜像 | ContractInstanceManager; |
forkContract | 迁移合约 | ContractInstanceManager; |
getDumpPeriod | 获取备份周期 | ContractInstanceManager; |
killAllContract | 停止全部实例 | ContractInstanceManager; |
killContractProcess | 停止某一实例 | ContractInstanceManager; |
listMemoryFiles | 列取某一实例的镜像 | ContractInstanceManager; |
loadMemory | 加载镜像 | ContractInstanceManager; |
queryContractInstanceDOI | 查询合约实例信息 | ContractInstanceManager; |
rebuildHashIndex | ContractInstanceManager; | |
setPermission | ContractProvider;ContractInstanceManager; | |
startContract | 启动合约 | ContractInstanceManager; |
startContractBatched | 废弃 | ContractInstanceManager; |
startContractByYPK | 启动合约 | ContractInstanceManager; |
startContractInTempZips | 废弃 | ContractInstanceManager; |
startContractP2PTrustfully | 启动合约(集群模式) | ContractInstanceManager; |
updateContract | ContractInstanceManager; | |
connectTo | 连接合约实例输出流 | ContractInstanceManager;ContractUser; |
countContractLogGroupByAction | ContractInstanceManager;ContractUser; | |
countContractLogGroupByCategory | ContractInstanceManager;ContractUser; | |
getLastLog | 查询日志 | ContractInstanceManager;ContractUser; |
getLog | 查询日志 | ContractInstanceManager;ContractUser; |
getLogSize | 查询日志 | ContractInstanceManager;ContractUser; |
listAllContractProcess | ContractInstanceManager;ContractUser; | |
listContractProcess | 查询合约实例列表 | ContractInstanceManager;ContractUser; |
listLeakContractProcess | ContractInstanceManager;ContractUser; | |
queryContractLogByDate | ContractInstanceManager;ContractUser; | |
queryContractLogByKey | ContractInstanceManager;ContractUser; | |
queryContractLogByOffset | ContractInstanceManager;ContractUser; | |
queryContractLogDetail | ContractInstanceManager;ContractUser; | |
queryContractLogSize | ContractInstanceManager;ContractUser; | |
queryNodeLogByDate | ContractInstanceManager;ContractUser; | |
queryNodeLogByOffset | ContractInstanceManager;ContractUser; | |
queryNodeLogSize | ContractInstanceManager;ContractUser; | |
rebuildContractLogIndex | ContractInstanceManager;ContractUser; | |
rebuildNodeLogIndex | ContractInstanceManager;ContractUser; | |
changePublic | ContractProvider; | |
createFile | 新建文件 | ContractProvider; |
deleteFile | 删除文件 | ContractProvider; |
distributeContract | ContractProvider; | |
downloadContract | ContractProvider; | |
downloadContractFromOtherHost | ContractProvider; | |
generateAnnotationSample | ContractProvider; | |
generateAppDataAnalysis | ContractProvider; | |
generateAppDataSource | ContractProvider; | |
generateBDCoinEventProject | ContractProvider; | |
generateBDCoinProject | ContractProvider; | |
generateBiddingExample | ContractProvider; | |
generateCSVProject | ContractProvider; | |
generateContractExecutor | ContractProvider; | |
generateDAC4BDOA | ContractProvider; | |
generateDAC4BDOA_persist | ContractProvider; | |
generateDACSample | ContractProvider; | |
generateEmptyProject | ContractProvider; | |
generateEventPublisher | ContractProvider; | |
generateEventSubscriber | ContractProvider; | |
generateGasExample | ContractProvider; | |
generateHello | ContractProvider; | |
generateHttpExample | ContractProvider; | |
generateIncentives | ContractProvider; | |
generateJSONExample | ContractProvider; | |
generateLedgerExample | ContractProvider; | |
generateLedgerProject | ContractProvider; | |
generateLicenceManager | ContractProvider; | |
generateLoggerExample | ContractProvider; | |
generateMySQLExample | ContractProvider; | |
generateMySQLProject | ContractProvider; | |
generatePostgreSQLSample | ContractProvider; | |
generateReadme | ContractProvider; | |
generateRenderSample | ContractProvider; | |
generateRocksDBSample | ContractProvider; | |
generateSM2Example | ContractProvider; | |
generateStaticResource | ContractProvider; | |
generateTFLinux | ContractProvider; | |
generategenerateTFMac | ContractProvider; | |
getProject | ContractProvider; | |
getTemplateList | ContractProvider; | |
importContractInstanceCodeByDOI | ContractProvider; | |
listFile | ContractProvider; | |
listProject | ContractProvider; | |
listProjectPermission | ContractProvider; | |
listProjects | ContractProvider; | |
renameFile | ContractProvider; | |
saveFile | ContractProvider; | |
startContractAsDebug | ContractProvider; | |
uploadFile | ContractProvider; | |
compile | ContractProvider;ContractInstanceManager; | |
evaluates | ContractProvider;ContractInstanceManager; | |
executeContractP2PTrustfully | ContractProvider;ContractInstanceManager; | |
getCodeByID | 查询代码 | ContractProvider;ContractInstanceManager; |
getControlFlowByFileName | ContractProvider;ContractInstanceManager; | |
getGasValue | ContractProvider;ContractInstanceManager; | |
listCompiledFiles | ContractProvider;ContractInstanceManager; | |
queryContractResourceInfo | ContractProvider;ContractInstanceManager; | |
queryFreeResourceInfo | ContractProvider;ContractInstanceManager; | |
staticVerifyContract | ContractProvider;ContractInstanceManager; | |
writeDyjs | ContractProvider;ContractInstanceManager; | |
authNodeRole | 授权角色 | NodeManager; |
changeBDledger | 修改账本配置 | NodeManager; |
changeIpPort | NodeManager; | |
changeNodeCenter | 修改集群地址 | NodeManager; |
changeNodeName | NodeManager; | |
changeIpPort | NodeManager; | |
changeDOIPConfig | NodeManager; | |
changeYJSPath | NodeManager; | |
countNodeLogGroupByCategory | NodeManager; | |
countRole | NodeManager; | |
deleteRole | NodeManager; | |
downloadUUID | 废弃 | NodeManager; |
getEncodedUUID | 废弃 | NodeManager; |
getPeerID | NodeManager; | |
listAllAuthRole | NodeManager; | |
listNodeInfos | NodeManager; | |
listUnAuthRole | NodeManager; | |
loadConfig | NodeManager; | |
loadNodeConfig | NodeManager; | |
lockEdit | NodeManager; | |
unlockEdit | NodeManager; | |
updateConfig | NodeManager; | |
uploadLicence | NodeManager; | |
applyNodeRole | 申请角色 | 任意角色 |
executeContract | 调用合约 | 任意角色 |
getConnCount | 任意角色 | |
getHashAbstractLocally | 任意角色 | |
getHashLocally | 任意角色 | |
getNodeRoleDeprecated | 查询当前角色 | 任意角色 |
getSessionID | 任意角色 | |
listAdapters | 任意角色 | |
listTheContractProcess | 任意角色 | |
login | 登录 | 任意角色 |
longStr | 任意角色 | |
ping | 任意角色 | |
queryDataByHash | 任意角色 | |
queryDataByHashLocally | 任意角色 | |
queryHashByOffset | 任意角色 | |
queryHashByRequestID | 任意角色 | |
queryHashSize | 任意角色 | |
queryLedgers | 任意角色 | |
queryRole | 任意角色 | |
queryTransactionByHash | 任意角色 | |
sendTransaction | 任意角色 | |
setLogStage | 任意角色 |
合约准入中心角色划分
共分为两类角色:CenterManager和NodeManager。其中,CenterManager拥有对集群设置的权限。 NodeManager可以增加、删除节点等操作。
接口 | 说明 | 角色 |
---|---|---|
authNodeManager | CenterManager; | |
countActionLogByCategory | CenterManager; | |
countCMLogByCategory | CenterManager; | |
delete | CenterManager; | |
listAllUsers | CenterManager; | |
listApplyList | CenterManager; | |
listLicence | CenterManager; | |
queryActionLog | CenterManager; | |
queryCMLog | CenterManager; | |
updateLicence | CenterManager; | |
addNode | CenterManager;NodeManager; | |
changeNCFile | CenterManager;NodeManager; | |
changeOtherNC | CenterManager;NodeManager; | |
createTrustUnit | 创建可信集群 | CenterManager;NodeManager; |
deleteTrustUnit | CenterManager;NodeManager; | |
getNCFile | CenterManager;NodeManager; | |
getNodeTrustUnits | CenterManager;NodeManager; | |
getOtherNC | CenterManager;NodeManager; | |
listContractProcess | CenterManager;NodeManager; | |
listMultiPointContractProcess | CenterManager;NodeManager; | |
listNodes | CenterManager;NodeManager; | |
listTrustUnits | CenterManager;NodeManager; | |
queryUserStat | CenterManager;NodeManager; | |
stopMultiPointContractProcess | CenterManager;NodeManager; | |
applyRole | NodeManager; | |
executeContract | 调用合约 | 任意角色 |
executeContractTrustfully | 任意角色 | |
getManagerPubkey | 任意角色 | |
getNodeRole | 任意角色 | |
getNodeSessionID | 任意角色 | |
getRole | 任意角色 | |
getSessionID | 任意角色 | |
login | 登录 | 任意角色 |
合约节点Http接口
http://xxx.xxx.xxx.xxx:1717/SCIDE/SCManager
为提供Http接口服务的服务器 URL(xxx.xxx.xxx.xxx:1717
为BDWare SCIDE运行的IP和端口号) , 用户可通过在URL后附加字段参数, 完成以下功能.
http://xxx.xxx.xxx.xxx:18000/SCIDE/SCManager
为提供Http接口服务的服务器
URL(xxx.xxx.xxx.xxx:1717
为BDWare SCIDE运行的IP和端口号),用户可通过在URL后附加字段参数,完成以下功能:
用户管理类
ping
ping
服务器测试
方法
GET
参数
字段 | 值 |
---|---|
action | ping |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=ping
返回结果示例
{"data":"pong"}
合约代码管理类
下载合约项目
方法
GET
参数
字段 | 值 |
---|---|
action | downloadContract |
projectName | 合约项目名 |
isPrivate | 是否在私有目录下 |
pubKey | 用户公钥 |
timestamp | 时间戳 |
sign | 签名 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=downloadContract&projectName=BDCoin&isPrivate=false&pubKey=0480204f4ef341359a5f64fcb11baf9ca2e6706ac20cba3
8b7ff78aa631e97346086e2d48fac2ba7f5b75ccbd19ebf495c0e6f9934d69e3b083da4d42e46c991e0c2ea8bb45d59f31f46d0ec700fb01f2fdd275
上传文件
方法
POST
参数
字段 | 值 |
---|---|
path | 文件上传路径 |
fileName | 待上传文件名 |
isPrivate | 是否在私有目录下 |
order | 第几个数据包 |
count | 数据包总数 |
timestamp | 时间戳 |
sign | 签名 |
请求示例
http://127.0.0.1:18000/SCIDE/Upload?path=/TEST/TEST.yjs&fileName=WechatIMG15.jpeg&isPrivate=true&order=0&count=3&pubKey=0480204f4ef341359a5f64fcb11baf9ca2e6706ac20cba36ca83066870cf2c1d5de6df67e24e68dde7934af9b31d94a6084281db3d32d5ce42ab8f75bf799aca05&sign=dd867469f5adf9986e4ea6215febeae50c7d4c3836d002cf8c17050dfca031fd2595ffa8646e9eeae53150d2cbaea690e27d818eaf5cea3632ee1b69c3307a4b631e97346086e2d48fac2ba7f5b75ccbd19ebf495c0e6f9934d69e3b083da4d42e46c991e0c2ea8bb45d59f31f46d0ec700fb01f2fdd275
返回结果示例
{"status":"true","data":"success"}
保存合约脚本
向服务器发送请求, 向服务器本地保存合约脚本内容.
方法
GET
参数
字段 | 值 |
---|---|
action | writeDyjs |
target | 合约脚本文件名 |
content | 合约脚本内容 |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=writeDyjs&target=testyjs.yjs&content=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D
返回结果示例
{
"status": false,
"action": "onWriteDyjs",
"data": "success"
}
后续用户可启动并调用该合约.
合约实例管理类
查询合约进程
向服务器发送请求, 查询服务器上已经启动的所有合约进程.
方法
GET
参数
字段 | 值 |
---|---|
action | listContractProcess |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=listContractProcess
返回结果示例
{
"status": false,
"action": "onListContractProcess",
"data": "[\n {\n \"id\": \"-562752842\",\n \"name\": \"shortc\",\n \"port\": \"1626\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n }\n]"
}
启动合约
向服务器发送请求, 启动某个合约.
方法
GET
参数
字段 | 值 |
---|---|
action | startContract |
script | 合约脚本内容, 需进行进行URIEncode |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=startContract&script=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D
返回结果示例
{
"data": "{\"status\":\"Success\",\"result\":\"\"}",
"action": "onStartContract",
"cid": "-562752842",
"executeTime": 1187
}
调用合约
向服务器发送请求, 调用某个合约.
方法
GET
参数
字段 | 值 |
---|---|
action | executeContract |
contractID | 合约ID |
withDynamicAnalysis | true/false 是否进行动态分析 |
operation | 调用合约的方法名 |
arg | 调用合约的参数 |
pubkey | 可选,调用者公钥 |
signature | 可选,签名 |
其中pubkey为sm2的公钥,计算方式如下:
//sm2 可从sm2.js中加载获得。
signature = sm2.doSignature(contractID+"|"+operation+"|"+arg+"|"+pubkey,privateKey);
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=executeContract&contractID=-620602333&operation=main&arg=hhh
返回结果示例
{
"data": "{\"status\":\"Success\",\"result\":\"3\"}",
"action": "onExecuteResult",
"executeTime": "13"
}
批量启动合约
向服务器发送请求, 启动服务器中保存有合约脚本的一系列合约.
方法
GET
参数
字段 | 值 |
---|---|
action | startContractBatched |
fileList | 合约脚本文件列表(Json数组,URLEncode) |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=startContractBatched&fileList=%5B%20%22EventPuber.yjs%22%2C%20%22EventSuber.yjs%22%2C%20%22LicenceManager.yjs%22%20%5D
返回结果示例
{"EventPuber.yjs":"{\"status\":\"Success\",\"result\":\"\"}","LicenceManager.yjs":"{\"status\":\"Success\",\"result\":\"\"}","EventSuber.yjs":"{\"status\":\"Success\",\"result\":\"\"}","action":"onStartContract"}
启动Zip包合约
向服务器发送请求, 启动服务器中包装为zip
格式的合约.
方法
GET
参数
字段 | 值 |
---|---|
action | startContractInTempZips |
owner | 调用者公钥 |
path | zip合约(路径及)文件名 |
signature | 调用者签名 |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=startContractInTempZips&owner=0475c7b061f32477c1e228dd04143daf58a5574dc3f6b02bd2857cc794eb92bfe98606dc314049e77fd8714f57a5a481cb470cc759e688fe60d40fc87092165e55&path=traceTest.zip&signature=650d3cad50509682937c253d84da99230e8ea1bcfb9b10f6d18f8888c7c4b6b4%2C72231a6daa078a3ce657c0a2ed38251b7db56cf725beaf86780d4c240b19ccc2
返回结果示例
{"data":"verify failed","action":"onStartContract"}
获取合约代码
向服务器发送请求, 获取某个ID合约的脚本代码.
方法
GET
参数
字段 | 值 |
---|---|
action | getCodeByID |
contractID | 合约ID |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=getCodeByID&contractID=814046805
返回结果示例
{"status":true,"action":"onCodeResult","data":"@LogType(\"Arg\")\ncontract EventSuberAtCHQ{\n\t\n \texport function init(arg){\n\t\tvar result \u003d YancloudUtil.subscribe(\"EventPuberAt3966\",\"abc\",handler);\n // print(\"Handler:\"+handler);\n \t \n \t\treturn result;\n\t}\n \texport function handler(e){\n var ret \u003d \"ReceiveEvent:\";\n\t\tret+\u003d\"\\n\";\n \tprint(ret);\n \tret+\u003dYancloudUtil.executeContract(\"EventPuberAt3966\",\"notify\",\"success\");\n \tprint(ret);\n return ret;\n\t}\n}\n"}
保存合约状态
向服务器发送请求, 获取节点服务器的状态转移日志.
方法
GET
参数
字段 | 值 |
---|---|
action | dumpContract |
contractID | 合约ID 或 合约Name= |
请求示例
http://127.0.0.1:18000/SCIDE/SCManager?action=dumpContract&contractID=counter&pubKey=040461417efe01423ba603f71c689387e8aac4aa2a6f7cddfaf22c1d22c40222f7669a054e7ec2e8533b04ccbc7a0e6655ac4ae4acef81a2b1822ec6cabcaf6c1f&sign=3045022004ffd1346b936196f5b13953d2f3e11823a0d0a2d2f6fecea258cef8e20d99c0022100bbc219ed1f56799ba28a763b9e9e47063164e7ceecfbfa752de42f44551ffb83
返回结果示例
{"data":"success","size":"3.76 KB","time":"0.03s"}
获取合约内存文件列表
向服务器发送请求, 获取某子文件夹中的所有内存文件列表.
方法
GET
参数
字段 | 值 |
---|---|
action | listMemoryFiles |
contractID | 合约Id 或 合约Name |
请求示例
http://127.0.0.1:18000/SCIDE/SCManager?action=listMemoryFiles&contractID=-247468535&pubKey=040461417efe01423ba603f71c689387e8aac4aa2a6f7cddfaf22c1d22c40222f7669a054e7ec2e8533b04ccbc7a0e6655ac4ae4acef81a2b1822ec6cabcaf6c1f&sign=3045022075c7268e888b0efdef167a3f4dfc6589d771c6be41b3c0a1dc12d057e811f395022100d44f460d0cc3643e169ef08231e75a1e895646c53295c0ef1d15c3b462a53d6b
返回结果示例
{"data":["2020-09-23.18:40:38","2020-09-24.16:03:41","2020-09-24.16:58:39","2020-09-24.18:25:47","2020-09-24.18:32:37","2020-09-24.20:54:41","2020-09-24.20:57:39","2020-09-24.21:31:07","2020-09-24.21:32:09","2020-09-24.21:36:11","2020-09-28.15:29:15","2020-09-28.20:28:29","2020-09-28.20:39:46","2020-09-28.21:45:31","2020-09-28.21:49:18","2020-09-28.22:27:34","2020-09-28.22:31:09","2020-09-28.22:32:49","2020-10-07.16:51:06","2020-10-07.16:51:23","2020-10-25.21:09:10","2020-12-14.19:06:53","2021-02-02.10:28:56","2021-02-02.10:31:13"],"action":"onListMemoryFiles"}
停止合约
向服务器发送请求, 停止某个合约.
方法
GET
参数
字段 | 值 |
---|---|
action | killContractProcess |
id | 合约ID |
*requestID | 请求ID, String类型 |
*
表示可选参数
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=killContractProcess&id=-1759263594
返回结果示例
{"status":false,"action":"onListContractProcess","data":"[\n {\n \"id\": \"-65051856\",\n \"name\": \"EventSuber\",\n \"port\": \"1631\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"814046805\",\n \"name\": \"EventSuberAtCHQ\",\n \"port\": \"1630\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"2023975189\",\n \"name\": \"LicenceService\",\n \"port\": \"1632\",\n \"times\": \"0 \",\n \"traffic\": \"32.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n },\n {\n \"id\": \"-620602333\",\n \"name\": \"shortc\",\n \"port\": \"1627\",\n \"times\": \"0 \",\n \"traffic\": \"0.00 B\",\n \"storage\": \"0.00 B\",\n \"contractStatus\": \"Ready\"\n }\n]"}
停止所有合约
向服务器发送请求, 停止服务器上启动的所有合约.
方法
GET
参数
字段 | 值 |
---|---|
action | killAllContract |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=killAllContract
返回结果示例
{"status":false,"action":"onKillAllContract","data":"Kill:7357,7541,7548,7555,7584,7585,7591,7598,7609,7612,8440,8442,8444,8521,"}
静态分析合约
向服务器发送请求, 静态分析合约脚本.
方法
GET
参数
字段 | 值 |
---|---|
action | staticVerifyContract |
contractid | 合约ID |
script | 请求ID, String类型 |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=staticVerifyContract&contractid=943728900&script=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D&path=static.yjs
返回结果示例
{"data":"{\"status\":\"Success\",\"result\":\"{\\\"main\\\":\\\"Ret:arg \\\"}\"}","action":"onExecuteResult","cid":"943728900","executeTime":54}
获取合约静态分析流
向服务器发送请求, 获取某个合约的静态分析Control Flow.
方法
GET
参数
字段 | 值 |
---|---|
action | getControlFlowByFileName |
path | 合约ID |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=getControlFlowByFileName&path=EventSuber.yjs
返回结果示例
{"init":{"blocks":[{"type":"Continuous","name":"B0","stmts":["\u003dL0\u003d","aload 0","invokevirtual wrp/jdk/nashorn/internal/runtime/ScriptFunction getScope ()Lwrp/jdk/nashorn/internal/runtime/ScriptObject;"],"original":""},{"type":"Continuous","name":"B1","stmts":["\u003dL1\u003d","astore 4"],"original":""},{"type":"Continuous","name":"B2","stmts":["\u003dL2\u003d","aload 4","invokedynamic dyn:getProp|getElem|getMethod:YancloudUtil (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B3","stmts":["dup","invokedynamic dyn:getMethod|getProp|getElem:subscribe (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B4","stmts":["swap","ldc XiaomiSmartHomeAtPKU","ldc onAirPurifierModeChange","aload 4","invokedynamic dyn:getProp|getElem|getMethod:handler (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B5","stmts":["invokedynamic dyn:call:\\\u003dYancloudUtil\\,subscribe (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B6","stmts":["\u003dL3\u003d","astore 5"],"original":"\t\tvar result \u003d YancloudUtil.subscribe(\"XiaomiSmartHomeAtPKU\",\"onAirPurifierModeChange\",handler);"},{"type":"Continuous","name":"B7","stmts":["\u003dL4\u003d","aload 5","areturn"],"original":" \t\treturn result;"},{"type":"Continuous","name":"B8","stmts":["\u003dL5\u003d"],"original":" \t\treturn result;"},{"type":"Continuous","name":"B9","stmts":["\u003dL6\u003d"],"original":" \t\treturn result;"}],"edges":[{"from":"B0","to":"B1","label":{"label":"e"}},{"from":"B1","to":"B2","label":{"label":"e"}},{"from":"B2","to":"B3","label":{"label":"e"}},{"from":"B3","to":"B4","label":{"label":"e"}},{"from":"B4","to":"B5","label":{"label":"e"}},{"from":"B5","to":"B6","label":{"label":"e"}},{"from":"B6","to":"B7","label":{"label":"e"}},{"from":"B7","to":"B9","label":{"label":"e"}}]},"handler":{"blocks":[{"type":"Continuous","name":"B0","stmts":["\u003dL0\u003d","aload 0","invokevirtual wrp/jdk/nashorn/internal/runtime/ScriptFunction getScope ()Lwrp/jdk/nashorn/internal/runtime/ScriptObject;"],"original":""},{"type":"Continuous","name":"B1","stmts":["\u003dL1\u003d","astore 4"],"original":""},{"type":"Continuous","name":"B2","stmts":["\u003dL2\u003d","ldc ReceiveEvent:","aload 2","invokedynamic dyn:getProp|getElem|getMethod:content (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B3","stmts":["invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B4","stmts":["ldc ","invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B5","stmts":["aload 2","invokedynamic dyn:getProp|getElem|getMethod:type (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 0 "],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B6","stmts":["invokestatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime ADD (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B7","stmts":["\u003dL3\u003d","astore 5"],"original":" var ret \u003d \"ReceiveEvent:\"+e.content+\" \"+e.type;"},{"type":"Continuous","name":"B8","stmts":["\u003dL4\u003d","aload 4","invokedynamic dyn:getMethod|getProp|getElem:print (Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":" \tprint(ret);"},{"type":"Continuous","name":"B9","stmts":["getstatic wrp/jdk/nashorn/internal/runtime/ScriptRuntime UNDEFINED Lwrp/jdk/nashorn/internal/runtime/Undefined;","aload 5","invokedynamic dyn:call:print (Ljava/lang/Object;Lwrp/jdk/nashorn/internal/runtime/Undefined;Ljava/lang/Object;)Ljava/lang/Object; HANDLE:wrp/jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite; (6) 5 "],"original":" \tprint(ret);"},{"type":"Continuous","name":"B10","stmts":["pop"],"original":" \tprint(ret);"},{"type":"Continuous","name":"B11","stmts":["\u003dL5\u003d","aload 5","areturn"],"original":" return ret;"},{"type":"Continuous","name":"B12","stmts":["\u003dL6\u003d"],"original":" return ret;"},{"type":"Continuous","name":"B13","stmts":["\u003dL7\u003d"],"original":" return ret;"}],"edges":[{"from":"B0","to":"B1","label":{"label":"e"}},{"from":"B1","to":"B2","label":{"label":"e"}},{"from":"B2","to":"B3","label":{"label":"e"}},{"from":"B3","to":"B4","label":{"label":"e"}},{"from":"B4","to":"B5","label":{"label":"e"}},{"from":"B5","to":"B6","label":{"label":"e"}},{"from":"B6","to":"B7","label":{"label":"e"}},{"from":"B7","to":"B8","label":{"label":"e"}},{"from":"B8","to":"B9","label":{"label":"e"}},{"from":"B9","to":"B10","label":{"label":"e"}},{"from":"B10","to":"B11","label":{"label":"e"}},{"from":"B11","to":"B13","label":{"label":"e"}}]}}
日志查看类
合约日志-查询数量
方法
GET
contractName为空或是不传入时,则为查询全部合约的条数
参数
字段 | 值 |
---|---|
action | queryContractLogSize |
contractName | 字符串,非必须,合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogSize&contractName=NanningDataSource
返回结果示例
{
"size": 12,
"action": "onQueryContractLogSize",
"status": "success"
}
合约日志-根据日期查询
方法
GET
参数
字段 | 值 |
---|---|
action | queryContractLogByDate |
start | long,必须,起始时间 |
end | long,非必须,若无end,默认为当前时间 |
contractName | 字符串,非必须,合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByDate&start=1597296300272&end=1597296305747
返回结果
{
"data": [
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "getMainFrame",
"costTime": "2493",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296300272,
"key": "-8590335427581967208"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "loadResource",
"costTime": "732",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296301030,
"key": "849660532962309239"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "loadResource",
"costTime": "4580",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305745,
"key": "-8003529429500512736"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "loadResource",
"costTime": "4551",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305746,
"key": "7604666709899222357"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "loadResource",
"costTime": "6",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305751,
"key": "-7561786202695627022"
}
],
"action": "onQueryRecentContractLog"
}
合约日志-根据偏移量查询
方法
GET
参数
字段 | 值 |
---|---|
action | queryContractLogByOffset |
count | long,必须,获取日志条数 |
offset | long,非必须,若无offset,默认返回最新count条 |
contractName | 字符串,非必须,合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByOffset&count=5&contractName=NanningDataSource
返回结果
{
"data": [
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "loadResource",
"costTime": "4",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305842,
"key": "-2390672423847654148"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "isOwner",
"costTime": "4",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305868,
"key": "6056586201629372511"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "getApplyList",
"costTime": "6",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305893,
"key": "3882409580676458151"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "getAcceptList",
"costTime": "4",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"date": 1597296305908,
"key": "-3437513873417136535"
},
{
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "analysisByIndustry",
"costTime": "6",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"signature": "4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02",
"arg": " {\"year\":2018,\"category\":\"工业\",\"indexType\":\"营业额\"}",
"date": 1597296314654,
"key": "203156239086062402"
}
],
"action": "onQueryRecentContractLog"
}
合约日志-根据key查询
方法
GET
参数
字段 | 值 |
---|---|
action | queryContractLogByKey |
key | long,必须,该日志对应的key |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryContractLogByKey&key=203156239086062402
返回结果
{
"data": {
"action": "executeContract",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"contractID": "-1382208250",
"contractName": "NanningDataSource",
"function": "analysisByIndustry",
"costTime": "6",
"totalGas": "0",
"executionGas": "0",
"extraGas": "0",
"signature": "4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02",
"arg": " {\"year\":2018,\"category\":\"工业\",\"indexType\":\"营业额\"}",
"date": 1597296314654
},
"action": "onQueryContractLogByKey"
}
合约日志-按时间段统计调用次数
方法
GET
参数
字段 | 值 |
---|---|
action | countContractLogGroupByCategory |
start | long,必须,起始时间 |
end | 非必须,终止时间,默认为当前 |
interval | long,非必须,统计间隔 |
category | 非必须,合约名称以逗号连接,不传入时统计全部合约调用情况 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=countContractLogGroupByCategory&start=1596758400000&interval=86400000
返回结果
{
"start": 1596758400000,
"interval": 86400000,
"action": "onCountContractLogGroupByCategory",
"data": [
0,
0,
0,
0,
0,
0,
43,
14
]
}
账本日志-查询数量
查询通过本节点去账本上记录的日志数量
方法
GET
参数
字段 | 值 |
---|---|
action | queryHashSize |
contractName | 非必须,合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryHashSize&contractName=NanningDataSource
返回结果
{
"count": "2",
"action": "onQueryHashSize"
}
账本日志-根据偏移量查询
查询x条通过本节点去账本上记录的日志的哈希列表
方法
GET
参数
字段 | 值 |
---|---|
action | queryHashByOffset |
count | 整数,必须,表示条数 |
offset | 整数,非必须,表示偏移量,不传入offset则默认返回最新count条 |
contractName | 字符串,非必须,表示合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryHashByOffset&count=1&contractName=NanningDataSource
返回结果
{
"data": [
{
"hash": "3a6c60621907146b77146c1f2d48700e47520173",
"date": 1597296314658
}
],
"action": "onQueryHash",
"status": "success"
}
账本日志-根据hash查询详情
根据hash来查询日志内容
方法
GET
参数
字段 | 值 |
---|---|
action | queryDataByHash |
hash | 字符串,可通过queryHashByOffset |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryDataByHash&count=1&contractName=NanningDataSource&hash=3a6c60621907146b77146c1f2d48700e47520173
返回结果
{
"from": "0x3034643139323433323966373263656431343866",
"to": "0x65786563757465436f6e74726163740000000000",
"data": "1597296314655 --> {\"extraGas\":\"0\",\"totalGas\":\"0\",\"executionGas\":\"0\",\"signature\":\"4c2cef1756b2b591ab7eead19d67331e2294c7ba765c72298733c306ada0b6e84afbb6c7b9dba48b9843236ebe67aecb4af09fe58a51eef0e2e89b9f3e5cad02\",\"costTime\":\"6\",\"arg\":\" {\\\\\\\"year\\\\\\\":2018,\\\\\\\"category\\\\\\\":\\\\\\\"工业\\\\\\\",\\\\\\\"indexType\\\\\\\":\\\\\\\"营业额\\\\\\\"}\",\"contractID\":\"-1382208250\",\"action\":\"analysisByIndustry\",\"pubKey\":\"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}",
"requestID": "1597296314629_6067",
"action": "onQueryDataByHash"
}
账本日志-根据requestID查询Hash
根据requestID来查询日志内容,需由开发者保证requestID的唯一性
方法
GET
参数
字段 | 值 |
---|---|
action | queryHashByRequestID |
requestID | 字符串,在发起调用时生成 |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=queryHashByRequestID&requestID=0987654321ab
节点日志-查询数量
方法
GET
参数
字段 | 值 |
---|---|
action | queryNodeLogSize |
category | 非必须,不传入时查询全部情况 |
其中包括:ping、startContract、saveFile等。
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogSize
http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogSize&category=login
返回结果
{
"size": 177,
"action": "onQueryNodeLogSize",
"status": "success"
}
节点日志-按日期查询
方法
GET
参数
字段 | 值 |
---|---|
action | queryNodeLogByDate |
start | long,必须,起始日期 |
end | long,非必须 |
category | 非必须,不传入时查询全部情况 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByDate&start=1597376006441
http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByDate&start=1596758400000&category=login
返回结果
{
"data": [
{
"action": "listAllAuthRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006438,
"key": "387355870552374748"
},
{
"action": "listUnAuthRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006441,
"key": "4772693258708933626"
},
{
"action": "countRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006444,
"key": "-6425375229108830572"
},
{
"action": "loadNodeConfig",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006448,
"key": "-6602401010405792959"
},
{
"action": "getPeerID",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006449,
"key": "-7006776427870311552"
}
],
"action": "onQueryNodeLogByDate"
}
节点日志-按偏移量查询
方法
GET
参数
字段 | 值 |
---|---|
action | queryNodeLogByOffset |
count | long,必须,获取日志条数 |
offset | long,非必须,若无offset,默认返回最新count条 |
contractName | 字符串,非必须,合约名称 |
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=queryNodeLogByOffset&count=5
返回结果
{
"data": [
{
"action": "listAllAuthRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006438,
"key": "387355870552374748"
},
{
"action": "listUnAuthRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006441,
"key": "4772693258708933626"
},
{
"action": "countRole",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006444,
"key": "-6425375229108830572"
},
{
"action": "loadNodeConfig",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006448,
"key": "-6602401010405792959"
},
{
"action": "getPeerID",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"status": "accept",
"date": 1597376006449,
"key": "-7006776427870311552"
}
],
"action": "onQueryNodeLogByOffset"
}
节点日志-按时间段统计调用次数
方法
GET
参数
字段 | 值 |
---|---|
action | countLogGroupByCategory |
start | long,必须,起始时间 |
end | 非必须,终止时间,默认为当前 |
interval | long,非必须,统计间隔 |
category | 非必须,action以逗号连接,不传入时统计全部调用情况 |
其中,category中的action为NodePortal的接口的action集合。 包括:ping、startContract、saveFile等。
请求示例
http://127.0.0.1:18000/SCIDE/CMManager?action=countNodeLogGroupByCategory&start=1596758400000&interval=86400000
http://127.0.0.1:18000/SCIDE/CMManager?action=countNodeLogGroupByCategory&start=1596758400000&interval=86400000&category=ping,startContract
返回结果
{
"start": 1596758400000,
"interval": 86400000,
"action": "onCountNodeLogGroupByCategory",
"data": [
0,
0,
0,
0,
0,
0,
912,
761
]
}
输出历史记录日志
向服务器发送请求, 获取节点服务器上合约的TimeTravel日志.
方法
GET
参数
字段 | 值 |
---|---|
action | printTimeTravelLog |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=printTimeTravelLog
返回结果示例
{"status":false,"data":"[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/aa\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/aa_1572335939893.dyjs\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/.\n[CMActions] memory dir \u003d /Users/oliveds/docs/SmartContract/contractExamples/memoryDumps/.\n"}
输出节点转移日志
向服务器发送请求, 获取节点服务器的状态转移日志.
方法
GET
参数
字段 | 值 |
---|---|
action | printTransferLog |
请求示例
http://127.0.0.1:1717/SCIDE/SCManager?action=printTransferLog
返回结果示例
{"status":false,"data":""}
模板生成类
账本Http接口
type: google.api.Service
config_version: 3
http:
rules:
- selector: bdware.bdledger.api.Node.ClientVersion
get: /v0/node/version
- selector: bdware.bdledger.api.Ledger.CreateLedger
post: /v0/ledgers
body: "*"
- selector: bdware.bdledger.api.Ledger.GetLedgers
get: /v0/ledgers
- selector: bdware.bdledger.api.Ledger.SendTransaction
post: /v0/ledgers/{ledger}/transactions
body: "*"
- selector: bdware.bdledger.api.Query.GetBlockByHash
get: /v0/ledgers/{ledger}/block
- selector: bdware.bdledger.api.Query.GetBlocks
post: /v0/ledgers/{ledger}/blocks/query
body: "*"
- selector: bdware.bdledger.api.Query.CountBlocks
post: /v0/ledgers/{ledger}/blocks/count
body: "*"
- selector: bdware.bdledger.api.Query.GetRecentBlocks
get: /v0/ledgers/{ledger}/blocks/recent
- selector: bdware.bdledger.api.Query.GetTransactionByHash
get: /v0/ledgers/{ledger}/transaction
- selector: bdware.bdledger.api.Query.GetTransactionByBlockHashAndIndex
get: /v0/ledgers/{ledger}/block/transaction
- selector: bdware.bdledger.api.Query.GetTransactions
post: /v0/ledgers/{ledger}/transactions/query
body: "*"
- selector: bdware.bdledger.api.Query.CountTransactions
post: /v0/ledgers/{ledger}/transactions/count
body: "*"
Note
Request/Response data of bytes type should/will be encoded with Base64.
Note
When using hash strings in URL, they need to be encoded with encodeURIComponent.
账本信息类
Node.ClientVersion
Get BDLedger node version
GET http://{{IP}}:{{PORT}}/v0/node/version
返回示例
{
"version": "dev-210119.a88bf4eb"
}
Ledger.CreateLedger
Create a new ledger
POST http://{{IP}}:{{PORT}}/v0/ledgers
请求示例
{
"name": "test"
}
返回示例
{
"ok": true
}
Ledger.GetLedgers
Get all ledgers
GET http://{{IP}}:{{PORT}}/v0/ledgers
返回示例
{
"ledgers": [
"default",
"test"
]
}
Ledger.SendTransaction
Send a new transaction
POST http://{{IP}}:{{PORT}}/v0/ledgers/test/transactions
请求示例
{
"transaction": {
"type": 0,
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": 52,
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
}
返回示例
{
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE="
}
查询类
Query.GetBlockByHash
Get a block identified by its hash
GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block?hash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D
hash has to be encoded with encodeURIComponent
返回示例
{
"block": {
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"3XkwkuMBearq8uavN76Te7Zdpl8="
],
"witnesses": [],
"timestamp": "1611038043",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"transactions": [
{
"blockHash": "",
"blockTimestamp": "0",
"index": 0,
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"type": "RECORD",
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": "0",
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
],
"transactionHashes": [
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
]
}
}
Query.GetBlocks
Get blocks in a timestamp range
POST http://{{IP}}:{{PORT}}/v0/ledgers/test/blocks/query
enum IncludeTransactions {
NONE = 0; // Don't include transaction data
HASH = 1; // Include transactions hashes
FULL = 2; // Include full transactions
}
Requirement: asciimath:["start_timestamp"⇐"end_timestamp"]
If only end_timestamp is not specified, or asciimath:["end_timestamp"-"start_timestamp">"query.maxDuration"], then end_timestamp will be set to asciimath:["start_timestamp"+"query.maxDuration"].
If only start_timestamp is not specified, then start_timestamp will be set to asciimath:["end_timestamp"-"query.maxDuration"].
In all cases, start_timestamp will never be earlier than the genesis block's timestamp, and end_timestamp will never be later than the current timestamp when the node process the query request.
请求示例
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000,
"include_transactions": 0
}
返回示例
{
"blocks": [
{
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"3XkwkuMBearq8uavN76Te7Zdpl8="
],
"witnesses": [],
"timestamp": "1611038043",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"transactions": [],
"transactionHashes": []
}
],
"startTimestamp": "1611038043",
"endTimestamp": "1611038043"
}
请求示例2
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000,
"include_transactions": 1
}
返回示例2
{
"blocks": [
{
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"3XkwkuMBearq8uavN76Te7Zdpl8="
],
"witnesses": [],
"timestamp": "1611038043",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"transactions": [],
"transactionHashes": [
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
]
}
],
"startTimestamp": "1611038043",
"endTimestamp": "1611038043"
}
Request body 3.
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000,
"include_transactions": 2
}
Response 3.
{
"blocks": [
{
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"3XkwkuMBearq8uavN76Te7Zdpl8="
],
"witnesses": [],
"timestamp": "1611038043",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"transactions": [
{
"blockHash": "",
"blockTimestamp": "0",
"index": 0,
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"type": "RECORD",
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": "0",
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
],
"transactionHashes": [
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
]
}
],
"startTimestamp": "1611038043",
"endTimestamp": "1611038043"
}
Query.CountBlocks
Count all blocks in a ledger, or blocks in a timestamp range
POST http://{{IP}}:{{PORT}}/v0/ledgers/test/blocks/count
Requirement: asciimath:["start_timestamp"⇐"end_timestamp"]
If neither start_timestamp nor end_timestamp is specified, then count all blocks in the specified ledger.
If only end_timestamp is not specified, then count all blocks with timestamps later than start_timestamp.
If only start_timestamp is not specified, then count all blocks with timestamps earlier than end_timestamp.
In all cases, start_timestamp will never be earlier than the genesis block's timestamp, and end_timestamp will never be later than the current timestamp when the node process the query request.
请求示例
{}
返回示例
{
"count": "5",
"startTimestamp": "0",
"endTimestamp": "1611039957"
}
请求示例2
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000
}
返回示例2
{
"count": "1",
"startTimestamp": "1611038000",
"endTimestamp": "1611039000"
}
Query.GetRecentBlocks
Get recent count blocks (Only support IncludeTransactions=NONE for now)
GET http://{{IP}}:{{PORT}}/v0/ledgers/test/blocks/recent?count=2
返回示例
{
"blocks": [
{
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"3XkwkuMBearq8uavN76Te7Zdpl8="
],
"witnesses": [],
"timestamp": "1611038043",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"transactions": [],
"transactionHashes": []
},
{
"hash": "rk0DWMaUpRG82yVX+cFhbfhPFdw=",
"creator": "",
"nonce": "0",
"parentHashes": [
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
"3XkwkuMBearq8uavN76Te7Zdpl8=",
"8pZPR74OALIbps5XFb4dL/s0j0M="
],
"witnesses": [],
"timestamp": "1610968019",
"size": "0",
"transactionCount": 1,
"transactionsRoot": "LuxttCm/pSHVMOKF0sJExk+DJXc=",
"transactions": [],
"transactionHashes": []
}
],
"startTimestamp": "1610968019",
"endTimestamp": "1611038043"
}
Query.GetTransactionByHash
Get a transaction identified by its hash
GET http://{{IP}}:{{PORT}}/v0/ledgers/test/transaction?hash=VQBeA5Ee0Y5hqEileoQuYMHbOSE%3D
hash has to be encoded with encodeURIComponent
返回示例
{
"transaction": {
"blockHash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"blockTimestamp": "1611038043",
"index": 0,
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"type": "RECORD",
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": "0",
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
}
Query.GetTransactionByBlockHashAndIndex
Get a transaction identified by hash of the block it belongs to and its index inside the block
GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block/transaction?blockHash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D&index=0
blockHash has to be encoded with encodeURIComponent
返回示例
{
"transaction": {
"blockHash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
"blockTimestamp": "1611038043",
"index": 0,
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"type": "RECORD",
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": "0",
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
}
Query.GetTransactions
Get transactions in a timestamp range
POST http://{{IP}}:{{PORT}}/v0/ledgers/test/transactions/query
start_timestamp and end_timestamp follow the same requirements and rules as in ???.
请求示例
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000
}
返回示例
{
"transactions": [
{
"blockHash": "",
"blockTimestamp": "0",
"index": 0,
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
"type": "RECORD",
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
"nonce": "0",
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
}
],
"startTimestamp": "1611038043",
"endTimestamp": "1611038043"
}
Query.CountTransactions
Count all transactions in a ledger, or transactions in a timestamp range
POST http://{{IP}}:{{PORT}}/v0/ledgers/test/transactions/count
start_timestamp and end_timestamp follow the same requirements and rules as in ???.
请求示例
{}
返回示例
{
"count": "4",
"startTimestamp": "0",
"endTimestamp": "1611039957"
}
请求示例2
{
"start_timestamp": 1611038000,
"end_timestamp": 1611039000
}
返回示例2
{
"count": "1",
"startTimestamp": "1611038000",
"endTimestamp": "1611039000"
}
合约节点WebSocket接口
用户管理类
获取Session
登录前获取session以便进行签名。
参数
字段 | 值 |
---|---|
action | getSessionID |
请求示例
var req = {};
req.action = "getSessionID";
wssocket.send(JSON.stringify(req));
返回结果
{
"action": "onSessionID",
"session": "9782323_session"
}
用户登录
用户进行公私钥身份验证
参数
字段 | 值 |
---|---|
action | login |
请求示例
var loginParam = {};
loginParam.pubKey = global.sm2Key.publicKey;
loginParam.signature = sm2.doSignature(global.session,
global.sm2Key.privateKey);
loginParam.action = "login";
wssocket.send(JSON.stringify(loginParam));
返回结果
{
"action": "onLogin",
"data": "NodeManager,ContractProvider"
}
申请角色
在节点管理员界面申请可以申请称为合约管理员(ContractInstanceManager)、合约使用者(ContractUser)、合约提供者(ContractProvider)
参数
字段 | 值 |
---|---|
action | applyNodeRole |
role | 申请角色名称 |
请求示例
var param = {};
param.action = "applyNodeRole";
param.role = "ContractUser";
wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onApplyRole",
"data": "success"
}
{
"action":"onApplyRole",
"data":"already has!"
}
授权角色
参数
字段 | 值 |
---|---|
action | authNodeRole |
isAccept | bool类型,表示否授权 |
pubKey | 授权用户公钥 |
请求示例
var param = {};
param.action = "authNodeRole";
param.isAccept = true;
param.pubKey = "xxxxx";
wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onAuthNodeRole",
"data": "success"
}
删除用户角色
参数
字段 | 值 |
---|---|
action | deleteRole |
role | 删除角色名称 |
请求示例
var deleteInfo = {};
deleteInfo.pubKey = global.authorizedUsers.[publicKey];
deleteInfo.action = "deleteRole";
deleteInfo.role="ContractUser";
wssocket.send(JSON.stringify(deleteInfo));
返回结果
{
"action": "onDeleteRole",
"data": "success"
}
查看授权用户列表
查看准入管理员当前组网中已经授权的节点管理员
参数
字段 | 值 |
---|---|
action | listAllAuthRole |
请求示例
var param = {};
param.action = "listAllAuthRole";
wssocket.send(JSON.stringify(param));
返回结果
{
"status":false,
"action":"onListAllAuthRole",
"data":
{
"kv":[{"key":"04eafad549d0757cf67f360815e15e157c7428c9ea9fb933f31a5d45bfb6edd9809c5bf6a5f37d7b817207f19fb2d76b7dbdefe38084cd3282e37b9ac39959dfab",
"value":"NodeManager,ContractProvider,ContractUser,ContractInstanceManager"}],
"time":[{"key":"04eafad549d0757cf67f360815e15e157c7428c9ea9fb933f31a5d45bfb6edd9809c5bf6a5f37d7b817207f19fb2d76b7dbdefe38084cd3282e37b9ac39959dfab",
"value":"1617178709933"}]
}
}
查看申请用户列表
参数
字段 | 值 |
---|---|
action | listUnAuthRole |
请求示例
var param = {};
param.action = "listUnAuthRole";
wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onListUnAuthRole",
"kv": [{
"key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7",
"value": "ContractProvider,ContractUser"
}],
"time": [{
"key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7",
"value": "1587398989914"
}]
}
参数(删除)
字段 | 值 |
---|---|
action | queryUserStat |
请求示例
var param = {};
param.action = "queryUserStat";
wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onQueryUserStat",
"userListCount": 3,
"applyListCount":0
}
合约代码管理类
获取公共合约文件列表
参数
字段 | 值 |
---|---|
action | listProjects |
请求示例
var request = {};
request.action = "listProjects";
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onListProjects",
"data":"[\"AnnotationSample\",\"AppDataAnalysis\",\"AppDataSource\",\"BiddingExample\",\"ContractExecutor\"]",
"executeTime":0,
"isPrivate":false
}
获取私有合约文件列表
参数
字段 | 值 |
---|---|
action | listProjects |
pubKey | 该用户的公钥 |
isPrivate | true |
请求示例
var request = {};
request.action = "listProjects";
request.pubKey = "global.sm2.publicKey";
request.isPrivate=true;
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onListProjects",
"data":"[\"CSVFromTemplate\",\"Empty22\",\"MySQLFromTemplate\",\"test\"]",
"executeTime":0,
"isPrivate":true
}
获取合约实例
参数
字段 | 值 |
---|---|
action | listContractProcess |
请求示例
var request = {};
request.action = "listContractProcess";
wssocket.send(JSON.stringify(request));
返回结果
{
"status":false,
"action":"onListContractProcess",
"data":"[{\"id\": \"1658407837\",\"name\": \"BDCoin\",\"port\": \"1617\"}]"
}
启动合约
参数
字段 | 值 |
---|---|
action | startContract |
owner | pubkey |
requestID | 当前时间 |
script | 脚本内容 |
signature | 签名 |
请求示例
request.action = "startContract";
request.owner = global.sm2Key.publicKey;
request.requestID = new Date().getTime() + "";
request.script = global.projectScript;
request.signature = sm2.doSignature("Algorithm|" + request.script + "|" + global.sm2Key.publicKey, global.sm2Key.privateKey);
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"{\"needSeq\":false,\"seq\":0,\"status\":\"Success\",\"result\":\"\",\"isInsnLimit\":false,\"totalGas\":0,\"executionGas\":0,\"extraGas\":0,\"size\":0,\"eventRelated\":false}",
"action":"onStartContract",
"cid":"-506393888",
"executeTime":2496,
"responseID":"1617206735696"
}
启动可信集群合约
参数
字段 | 值 |
---|---|
action | startContractP2PTrustfully |
owner | pubkey |
isPrivate | 当前时间 |
path | 脚本所在路径 |
signature | 签名 |
peersID | 可信执行集群中的节点peerID组成的数组 |
请求示例
var request = {};
request.action = "startContractP2PTrustfully";
request.peersID = ["3r729hf2ehf982","sjdfiwoehfwoi34","wnfnwoeifnwenef"];
var project = "JsonTest";
request.path = "/" + project + "/mainfest.json";
request.isPrivate = false;
request.signature = sm2.doSignature("Trusted|" + request.path + "|"
+ global.sm2Key.publicKey, global.sm2Key.privateKey); //合约的签名
request.resultcheck = $("#resultcheck")[0].value;
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"{\"status\":\"Success\",\"result\":\"\"}",
"action":"onStartContractP2PTrustfully",
"cid":"-1543583350",
"executeTime":1544
}
分发合约项目
参数
字段 | 值 |
---|---|
action | distributeContract |
peersID | 集群中节点peer |
projectName | 合约名 |
isPrivate | 是否在私有目录 |
sponsorPeerID | 发起者ID |
signature | 签名 |
请求示例
request.action = "distributeContract";
request.peersID = peersID;
request.projectName = global.projects[global.lastClickedProjectId];
request.isPrivate = $("#privateDir-tab").hasClass("active");
request.sponsorPeerID = global.peerID;
request.signature = sm2.doSignature("DistributeContract|" + request.projectName + "|" + global.sm2Key.publicKey, global.sm2Key.privateKey);
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onDistributeContract",
"progress":"100.00%"
}
终止合约
参数
字段 | 值 |
---|---|
action | killContractProcess |
id | 合约id |
requestID | 请求ID |
请求示例
request.action = "killContractProcess";
request.id = contractid;
request.requestID = new Date().getTime() + "";
wssocket.send(JSON.stringify(request));
返回结果
{
"data": "ContractHandler: exit in 3 seconds!",
"action": "onOutputStream"
}
终止所有合约
参数
字段 | 值 |
---|---|
action | killAllContract |
请求示例
request.action = "killAllContract";
wssocket.send(JSON.stringify(request));
返回结果
{
"status":false,
"action":"onKillAllContract",
"data":"Kill:7241,7245,"
}
静态分析合约
参数
字段 | 值 |
---|---|
action | staticVerifyContract |
owner | 用户私钥 |
isPartial | 是否是部分 |
contractid | contractid |
script | 脚本内容 |
path | 合约文件名 |
请求示例
request.action = "staticVerifyContract";
request.owner = global.sm2Key.privateKey
request.isPartial = false;
request.contractid = contractid;
request.script = global.projectScript;
request.path = global.projectName;
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"{\"needSeq\":false,\"seq\":0,\"status\":\"Success\",\"result\":{\"hello\":\"Ret:\"},\"isInsnLimit\":false,\"totalGas\":0,\"executionGas\":0,\"extraGas\":0,\"size\":0,\"eventRelated\":false}",
"action":"onStaticVerifyResult",
"cid":"verify",
"executeTime":83
}
删除合约
参数
字段 | 值 |
---|---|
action | deleteFile |
file | fileName |
请求示例
request.action = "deleteFile";
request.file = fileName;
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onDeleteFile",
"data":"success",
"executeTime":0
}
私有合约传至公共目录
参数
字段 | 值 |
---|---|
action | changePublic |
pubkey | 用户公钥 |
fileName | fileName |
请求示例
request.action = "changePublic";
request.pubkey = pubkey;
request.fileName = fileName;
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onChangePublic",
"data":"success",
"executeTime":0
}
上传合约
参数
字段 | 值 |
---|---|
action | UploadFile |
isAppend | false |
fileName | fileName |
path | path |
isPrivate | true/false |
content | fileContent(base64编码) |
请求示例
request.action = "uploadFile";
request.isAppend = false;
request.fileName = "test1.yjs";
request.path = "test1";
text="Y29udHJhY3QgdGVzdDF7CglleHBvcnQgZnVuY3Rpb24gaGVsbG8oYXJnKXsgCiAgICAgICAgcmV0dXJuICJ3b3JsZCI7ICAKICAgIH0gICAKfQ=="
request.content = text;
wssocket.send(JSON.stringify(request));
返回结果
{
"action":"onUploadFile",
"data":"success",
"executeTime":0
}
编译合约
参数
字段 | 值 |
---|---|
action | compile |
path | string, 待编译的项目名称 |
privateTab | bool, 是否为私有目录的项目 |
请求示例
var req = {"action":"compile","path":"Hello","privateTab":true}
返回结果
{"result":"Hello_2020-08-17-09:09:40.ypk","action":"onCompile"}
锁定私有目录
锁定某个用户的的私有目录编辑功能
参数
字段 | 值 |
---|---|
action | lockEdit |
pubKey | string, 要被锁定的公钥 |
请求示例
var req = {};
req.action = "lockEdit";
req.pubKey = "xxxxxx";
wssocket.send(JSON.stringify(req));
{
"action":"onLockEdit",
"status":"success",
"data":"04c4c855862b53f323e077ccfcc744ecc2c0a04645ed16d99ede8fd5866b38c0670a97ad22c6260d1a4672aba2a5fe229a2d4eba34627c054aab102620afa288c1"
}
解锁私有目录
解锁某个用户的的私有目录编辑功能
参数
字段 | 值 |
---|---|
action | unLockEdit |
pubKey | string, 要被锁定的公钥 |
请求示例
var req = {};
req.action = unlockEdit;
req.pubKey = "xxxxxx";
wssocket.send(JSON.stringify(req));
{
"action":"onUnlockEdit",
"status":"success",
"data":"04c4c855862b53f323e077ccfcc744ecc2c0a04645ed16d99ede8fd5866b38c0670a97ad22c6260d1a4672aba2a5fe229a2d4eba34627c054aab102620afa288c1"
}
合约实例管理类
查询合约进程
向服务器发送请求, 查询服务器上已经启动的所有合约进程.
参数
字段 | 值 |
---|---|
action | listContractProcess |
请求示例
var request = {};
request.action = "listContractProcess";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"status": false,
"action": "onListContractProcess",
"data": "[...]"
}
调用合约
向服务器发送请求, 调用某个合约.
参数
字段 | 值 |
---|---|
action | executeContract |
contractID | 合约ID |
withDynamicAnalysis | true/false 是否进行动态分析,可选 |
operation | 调用合约的方法名 |
arg | 调用合约的参数 |
pubkey | 调用者公钥,可选 |
signature | 调用者签名 ,可选 |
*
表示可选参数
//sm2 可从sm2.js中加载获得。
signature = sm2.doSignature(contractID+"|"+operation+"|"+arg+"|"+pubkey,privateKey);
请求示例
var request = {};
request.action = "executeContract";
request.contractID = "2073401446";
request.operation = "main";
request.arg = "hhhhh";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"needSeq":false,
"seq":0,
"status":"Success",
"result":"world",
"isInsnLimit":false,
"totalGas":0,
"executionGas":0,
"extraGas":0,
"size":0,
"eventRelated":false,
"responseID":"1617211077264_223",
"action":"onExecuteResult",
"executeTime":"5"
}
输出历史记录日志(删除)
向服务器发送请求, 获取节点服务器上合约的TimeTravel日志.
参数
字段 | 值 |
---|---|
action | printTimeTravelLog |
请求示例
var request = {};
request.action = "printTimeTravelLog";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"status": false,
"data": "[CMActions] dumpContract :…t/contractExamples/memoryDumps/LicenceManager\n"
}
输出节点转移日志(删除)
向服务器发送请求, 获取节点服务器的状态转移日志.
参数
字段 | 值 |
---|---|
action | printTransferLog |
请求示例
var request = {};
request.action = "printTransferLog";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"status": false,
"data": ""
}
合约状态迁移
向服务器发送请求, 获取节点服务器的状态转移日志.
参数
字段 | 值 |
---|---|
action | loadMemory |
contractName | 合约名称 |
memoryFile | 合约文件名称 |
请求示例
var request = {};
request.action = "loadMemory";
request.contractName = "JsonContract";
request.memoryFile = "2020-03-17.20/42/55";
wssocket.send(JSON.stringify(request));
返回结果示例
{
"data":"success",
"size":"0.00 B",
"action":"onTransferTo",
"time":"0.01s"
}
日志查看类
查看本地近n日节点日志(删除)
参数
字段 | 值 |
---|---|
action | listLocalNodeLog |
date | 当前时间 |
请求示例
request.action = "listLocalNodeLog";
request.date = new Date().getTime() - 24 * 3600 * 1000 * n;
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"[{\"action\":\"login\",\"pubKey\":\"null\",\"status\":\"accept\",\"date\":1583139323822}\",]"
}
查看本地近n日合约日志(删除)
参数
字段 | 值 |
---|---|
action | listLocalContractLog |
date | 当前时间 |
请求示例
request.action = "listLocalContractLog";
request.date = new Date().getTime() - 24 * 3600 * 1000 * n;
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"[\"{\"action\":\"startContract\",\"pubKey\":\"04405d7ba358d9234939623ab51ea94ca685e6a1f36ed81fd9630ccba6473e632f163bb30faffd4c91f21e5bace20101d6d6e36c04ac67eea14cc24b4962b84f57\",\"contractID\":\"845581788\",\"contractName\":\"null\",\"date\":1583141525539}\"]"
}
节点配置类
获取节点配置信息
参数
字段 | 值 |
---|---|
action | loadNodeConfig |
请求示例
var param = {};
param.action = "loadNodeConfig";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onLoadNodeConfig",
"data": {
"nodeName": "04BF52213343C147E631B877BCEB17B794230EE551E85F58FA429C4BA03D690778CC384C6916C63DF36CB9E35C7E274FDB4E18491DFE3D611D347856D441CACC5AF9090B515F02AFC2DFBF56461EC83B5A4CD342466360D6CF82E6E40B637430AC4A329CCBC798DAF7D526AF9E3B3600E0BEA1BFAB8C160EF90128FAF67B19E45F37664F1E4B",
"licence": "04AADCC7103CD02626D228AFFBEF53F8242ECA4DDD6F179D30B622440666715CFBB6FD1D3678A2B25812DEA9917073E79A65F7ADE517F784DC76288EFCEB37ECAA1025E6903540702F729DA1C2ECCD93F4E6FAFCE40DF443E7FD74387169D0C6D927C7BB12882D0471C8D3E6F31B0316A42FC38F6DD9978D4351B23B2AD63E2244909E98F51185D32CB99B4AE4E22D3AB4C04027BB",
"expireTime": "Wed Aug 26 09:43:08 CST 2020",
"nodes": "[\"node1\",\"node2\",\"node3\"]",
"yjsPath": "/Users/xxx/docs/BDWareHttp/generatedlib/yjs.jar",
"nodeCenter": "ws://127.0.0.1:1719/SCIDE/NodeCenter"
}
}
{
"status":true,
"action":"onLoadNodeConfig",
"data":{
"nodeName":"Node_180",
"peerID":"",
"masterAddress":"39.104.201.40:21031",
"licence":"04AADCC7103C",
"doipConfig":"{\\"LHSProxyAddress\\":\\"http://39.104.201.40:21042/\\",\\"ownerHandle\\":\\"86.5000.470/dou.TEST\\",\\"certPath\\":\\"keys/dou.TEST.keystore\\",\\"certPassword\\":\\"123456\\",\\"repoID\\":\\"86.5000.470/doip.vcg9Mu1gSq_bdw\\",\\"listeners\\":\\"[{\\\\\\"url\\\\\\":\\\\\\"tcp://39.104.201.40:21032\\\\\\",\\\\\\"protocolVersion\\\\\\":\\\\\\"2.1\\\\\\",\\\\\\"messageFormat\\\\\\":\\\\\\"packet\\\\\\"}]\\",\\"serviceDescription\\":\\"test local Contract Repository\\",\\"serviceName\\":\\"ContractEngine021\\"}",
"clusterConnected":"false",
"nodePubKey":"0492d974b8a5b473d0ed2c81800917f76e2a1ec3666067888c85fe6922a672223f2083f95402ae13a744df58deabbe7206c4a317dd14296b0d3941a26ca4e34dc5",
"ipPort":"",
"bdledger":"39.108.56.240:18091,39.108.56.12:1809139.104.70.160:18091 47.98.247.70:18091 47.98.248.208:18091 39.104.77.165:18091 47.98.249.131:18091",
"yjsPath":"/data/bdwaas/bdcontract/yjs.jar",
"nodeCenter":"ws://39.104.201.21040/SCIDE/NodeCenter"
}
}
修改节点配置
参数
字段 | 值 |
---|---|
action | updateConfig |
key | 要改的配置项 |
val | 要更改的目标值 |
其中,key的可选项包括:
key的示 | val示例 | 说明 |
---|---|---|
yjsPath | /User/xxx/cp/yjs.jar | 合约进程启动所需的jar |
dataChain | 192.168.1.8:18090,182.173.2.3:18091 | 账本节点的ip与端口 |
nodeCenter | ws://127.0.0.1:18002 | CenterPortal所在的ip/端口 |
nodeName | Node_180 | 字符串类型 |
masterAddress | 192.168.3.2:18001 | 该NodePortal节点的ip和的TCP端口 |
其中NodePortal的TCP端口为Node的http/ws端口号+1。
修改节点名称
参数
字段 | 值 |
---|---|
action | changeNodeName |
data | 新的节点名称 |
请求示例
var param = {};
param.action = "changeNodeName";
param.data = "NewNodeName";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onChangeNodeName",
"data": true
}
修改节点YJS路径
参数
字段 | 值 |
---|---|
action | changeYJSPath |
data | 节点服务器yjs.jar路径 |
请求示例
var param = {};
param.action = "changeYJSPath";
param.data = "/Users/xxx/docs/BDWareHttp/generatedlib/yjs.jar";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onChangeYJSPath",
"data": true
}
修改NodeCenter
参数
字段 | 值 |
---|---|
action | changeNodeCenter |
data | 节点服务器要连接的NodeCenterWebSocket路径 |
请求示例
var param = {};
param.action = "changeNodeCenter";
param.data = "ws://127.0.0.1:1719/SCIDE/NodeCenter";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onChangeNodeCenter",
"data": true
}
修改账本节点
参数
字段 | 值 |
---|---|
action | changeBDledger |
data | 数链节点的IP:port,用","隔开 |
请求示例
var param = {};
param.action = "changeBDledger";
param.data = "39.108.56.240:18091,39.108.56.12:18091";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onChangeBDledger",
"data": true
}
上传节点Licence
参数
字段 | 值 |
---|---|
action | uploadLicence |
data | 节点服务器的Licence内容 |
请求示例
var param = {};
param.action = "uploadLicence";
param.data = "04AADCC7103C";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onUploadLicence",
"data": true
}
获取节点ID
参数
字段 | 值 |
---|---|
action | getNodeID |
请求示例
var param = {};
param.action = "getNodeID";
wssocket.send(JSON.stringify(param));
返回结果
{
"status": true,
"action": "onGetNodeID",
"data": "0431…d3a92e1184bbc5817ebda5c2ad498e4ff1d240009b4f06d"
}
获取节点所在的可信执行集群
参数
字段 | 值 |
---|---|
action | getNodeTrustUnits |
data | 节点ID |
msgHandler | 收到回复的回调函数, 可使用"建立连接"的msgHandler |
ws | 节点所属的NodeCenter的WebSocket地址 |
请求示例
centerportalws = createWssocket("ws://127.0.0.1:1718/NodeCenterWS",function() {
var param = {};
param.action = "getNodeTrustUnits";
param.data = "0431e311bd70840fe69965e2cabea97fafe99f2133953c01abb9bd7cb62af42f8283f474d203051e920d3a92e1184bbc5817ebda5c2ad498e4ff1d240009b4f06d";
centerportalws.send(JSON.stringify(param));
}, msgHandler);
返回结果
{
"data": [{
"key": "0475c7b061...65e55_4063665700873624164",
"value": "[\"04541429c11b094…40009b4f06d\"]"
}],
"action": "onGetNodeTrustUnits"
}
模板生成类
获取合约模板列表
参数
字段 | 值 |
---|---|
action | getTemplateList |
请求示例
req={};
req.action = "getTemplateList";
wssocket.send(JSON.stringify(req));
返回结果
{
"data": [
{
"formDesc": {
"dbPWD": {
"label": "密码",
"type": "input"
},
"contractName": {
"label": "合约名称",
"type": "input"
},
"accessPolicy": {
"label": "访问控制策略",
"type": "input",
"option": [
{
"text": "无访问控制",
"value": "NAC"
},
{
"text": "直接访问控制",
"value": "DAC"
},
{
"text": "基于角色的访问控制",
"value": "RBAC"
}
]
},
"dbUserName": {
"label": "用户名",
"type": "input"
},
"fieldList": {
"label": "字段名",
"type": "tag"
},
"dbUrl": {
"label": "数据库链接",
"type": "input"
},
"tableName": {
"label": "表名",
"type": "input"
}
},
"apiName": "generateMySQLProject"
},
{
"formDesc": {
"contractName": {
"label": "合约名称",
"type": "input"
},
"accessPolicy": {
"label": "访问控制策略",
"type": "input",
"option": [
{
"text": "无访问控制",
"value": "NAC"
},
{
"text": "直接访问控制",
"value": "DAC"
},
{
"text": "基于角色的访问控制",
"value": "RBAC"
}
]
}
},
"apiName": "generateEmptyProject"
}
],
"action": "onTemplateList"
}
空白合约模板
参数
字段 | 值 |
---|---|
action | generateEmptyProject |
contractName | 字符串类型,合约名称 |
isPrivate | 布尔类型,是否为私有项目 |
accessPolicy | 若为"DAC",则实现直接访问控制 |
请求示例
var req = {};
req.contractName = "Empty22";
req.action = "generateEmptyProject";
req.accessPolicy = "DAC";
//wssocket为建立好的连接
wssocket.send(JSON.stringify(req));
返回结果
{
"action":"onListProjects",
"data":"[\"AnnotationSample\",\"AppDataAnalysis\",\"AppDataSource\"]",
"executeTime":0,
"isPrivate":false
}
MySQL接入合约
参数
字段 | 值 |
---|---|
action | generateMySQLProject |
contractName | 字符串类型,合约名称 |
isPrivate | 布尔类型,是否为私有项目 |
dbUrl | 字符串类型,数据库的URI |
dbUserName | 字符串类型,数据库的用户名 |
dbPWD | 字符串类型,数据库密码 |
accessPolicy | 若为"DAC",则实现直接访问控制,若为"NAC"则没有访问控制 |
tableName | 字符串类型,数据库的表名 |
fieldList | 字符串列表,数据库的字段列表 |
defaultAccept | 布尔值,表示申请时是否默认有权 |
请求示例
var req = {};
req.contractName = "MySQLFromTemplate";
req.action = "generateMySQLProject";
req.pubKey = global.sm2Key.publicKey;
req.isPrivate = true;
req.tableName = "data";
req.dbUrl = "jdbc:mysql://xxx:xxx/xxx";
req.dbUserName = "loushuai";
req.dbPWD = "loushuai";
req.fieldList = [{"name":"名字","code":"*"}];
req.basicInfo={"type":"所属分类","name":"资源名称"};
req.accessPolicy = "DAC";
req.defaultAccept = true;
//global.wssocket为建立好的连接
global.wssocket.send(JSON.stringify(req));
返回结果
{
"action":"onListProjects",
"data":"[\"CSVFromTemplate\",\"Empty22\",\"Hello\",\"MySQLFromTemplate\",\"test\"]",
"executeTime":0,
"isPrivate":true
}
CSV接入合约
参数
字段 | 值 |
---|---|
action | generateCSVProject |
contractName | 字符串类型,合约名称 |
base64EncodedData | 字符串类型,通过base64编码后的CSV文件内容 |
isPrivate | 可选字段,布尔类型,是否为私有项目 |
accessPolicy | 若为"DAC",则实现直接访问控制,若为"NAC"则没有访问控制 |
defaultAccept | 可选字段,布尔值,表示申请时是否默认有权 |
请求示例
var req = {};
req.contractName = "CSVFromTemplate";
req.action = "generateCSVProject";
req.pubKey = global.sm2Key.publicKey;
req.isPrivate = true;
req.tableName = "data";
req.accessPolicy = "DAC";
req.defaultAccept = true;
req.base64EncodedData = "bmFtZSwgc2NvcmUsCmphY2ssIDkwLApsdWN5LCA5MQo=";
//global.wssocket为建立好的连接
global.wssocket.send(JSON.stringify(req));
返回结果
{
"action":"onListProjects",
"data":"[\"CSVFromTemplate\",\"Empty22\",\"Hello\",\"MySQLFromTemplate\",\"test\"]",
"executeTime":0,
"isPrivate":true
}
路由节点WebSocket接口
用户管理类
获取Session
登录前获取session以便进行签名。
参数
字段 | 值 |
---|---|
action | getSessionID |
请求示例
var req = {};
req.action = "getSessionID";
wssocket.send(JSON.stringify(req));
返回结果
{
"action": "onSessionID",
"session": "9782323_session"
}
用户登录
用户进行公私钥身份验证,需先调用"getSessionID"获取sessionID以便于签名。
参数
字段 | 值 |
---|---|
action | login |
请求示例
var loginParam = {};
loginParam.pubKey = global.sm2Key.publicKey;
loginParam.signature = sm2.doSignature(global.session,
global.sm2Key.privateKey);
loginParam.action = "login";
wssocket.send(JSON.stringify(loginParam));
返回结果示例
{
"action": "onLogin",
"data": "CenterManager"
}
用户获取当前角色(删除)
用户根据登录时的公钥获取对应的角色,如果是第一次登录则此时的公钥默认称为准入管理员
参数
字段 | 值 |
---|---|
action | getRole |
请求示例
var param = {};
param.action = "getRole";
wssocket.send(JSON.stringify(param));
返回结果示例
{
"action": "onGetRole",
"data": "CenterManager"
}
申请角色
在准入管理员界面可以申请称为组网中某个节点的节点管理员
参数
字段 | 值 |
---|---|
action | applyRole |
role | 申请的角色名称 |
请求示例
var param = {};
param.action = "applyRole";
param.role="
wssocket.send(JSON.stringify(param));
返回结果示例
{
"action": "onApplyRole",
"data": "failed"
}
添加节点
参数
字段 | 值 |
---|---|
action | addNode |
nodePubKey | 要添加的节点公钥 |
请求示例
var req = {};
//某节点的publicKey可通过连接该节点,并通过"获取节点配置信息"接口获取
req.nodePubKey = publicKey;
req.action = "addNode";
wssocket.send(JSON.stringify(req));
删除用户角色
参数
字段 | 值 |
---|---|
action | delete |
pubKey | 对应用户的公钥 |
请求示例
var deleteInfo = {};
deleteInfo.pubKey = user.publicKey;
deleteInfo.action = "delete";
wssocket.send(JSON.stringify(deleteInfo));
返回结果示例
{
"action": "onDelete",
"data": "success"
}
查看授权用户列表
查看准入管理员当前组网中已经授权的节点管理员
参数
字段 | 值 |
---|---|
action | listAllUsers |
请求示例
var param = {};
param.action = "onListAllUsers";
wssocket.send(JSON.stringify(param));
返回结果示例
{
"action": "onListAllUsers",
"kv": {
"key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7",
"value": " NodeManager"
},
"time": {
"key": "049999ebd14ff3b96ebf7f7325e1da94a1c4c376573a1dc1cec2b4f7a3b09ed7b07252134e93b6ac2e1853268b82f4b541d34fb42b0182cd61043e99d3489e2cf7",
"value": 1587398989914
}
}
查看申请用户列表
参数
字段 | 值 |
---|---|
action | listApplyList |
请求示例
var param = {};
param.action = "onListApplyList";
wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onListApplyList",
"kv": {
"key": "04b00f32eab70c78d1b43738f190d326d36c021af2124acefe6d057016b11ea31c750bb473e565c9d89e4993a44f4d30adf447d3026a21ff4b3b64cef523074ef7",
"value": " NodeManager"
},
"time": {
"key": "04b00f32eab70c78d1b43738f190d326d36c021af2124acefe6d057016b11ea31c750bb473e565c9d89e4993a44f4d30adf447d3026a21ff4b3b64cef523074ef7",
"value": 1587398989914
}
}
查看用户类型分布
参数
字段 | 值 |
---|---|
action | queryUserStat |
请求示例
var param = {};
param.action = "onQueryUserStat";
wssocket.send(JSON.stringify(param));
返回结果示例
{
"action": "onQueryUserStat",
"userListCount": 3,
"applyListCount":0
}
节点管理类
查看节点列表
查看该用户有权限查看的节点列表(仅准入管理员及合约管理者可用)
参数
字段 | 值 |
---|---|
action | listNodes |
请求示例
var param = {};
param.action = "listNodes";
wssocket.send(JSON.stringify(param));
返回结果
{
"offline": [{
"key": "0431e31...40009b4f06d",
"value": "0431e311bd708...b4f06d"
}],
"action": "onListNodes",
"online": [{
"contracts": [],
"pubKey": "0431e311...09b4f06d",
"nodeName": "NewNodeName",
"udpID": "528822126",
"cimanager": ""
}]
}
查看可信执行集群列表
查看该用户有权限查看的节点列表(仅中心管理员及合约管理者可用)
参数
字段 | 值 |
---|---|
action | listTrustUnits |
请求示例
var param = {};
param.action = "listTrustUnits";
wssocket.send(JSON.stringify(param));
返回结果
{
"data": [{
"key": "0470b2f27f4f6…1cb855f1ecec11",
"value": "[...]"
}],
"action": "onListTrustUnits"
}
建立可信执行集群
参数
字段 | 值 |
---|---|
action | createTrustUnit |
data | 节点公钥组成的Json数组 |
Msg | 集群名称 |
请求示例
var param = {};
param.action = "createTrustUnit";
param.data = "[\"382r0934309t...\",\"345343rr3f34...\"]";
param.msg = "newUnit1";
global.wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onCreateTrustUnit",
"status": "Success"
}
删除可信执行集群
参数
字段 | 值 |
---|---|
action | deleteTrustUnit |
data | 可信执行集群ID |
请求示例
var param = {};
param.action = "deleteTrustUnit";
param.data = "0475d34rf3434..._1583410158761";
global.wssocket.send(JSON.stringify(param));
返回结果
{
"action": "onDeleteTrustUnit",
"status": "Success"
}
日志查看类
查看组网管理操作的统计
参数
字段 | 值 |
---|---|
action | queryActionLog |
date | 当前时间 |
请求示例
request.action = "onQueryActionLog";
request.date = new Date().getTime() - 24 * 3600 * 1000 * n;
wssocket.send(JSON.stringify(request));
返回结果
{ "action":"onQueryActionLog",
"data":"[{\"action\":\"login\",\"pubKey\":\"null\",\"status\":\"accept\",\"date\":1583139323822}\",]"
}
查看本地近n日合约日志
参数
字段 | 值 |
---|---|
action | listLocalContractLog |
date | 当前时间 |
请求示例
request.action = "listLocalContractLog";
request.date = new Date().getTime() - 24 * 3600 * 1000 * n;
wssocket.send(JSON.stringify(request));
返回结果
{
"data":"[\"{\"action\":\"startContract\",\"pubKey\":\"04405d7b...\",\"contractID\":\"845581788\",\"contractName\":\"null\",\"date\":1583141525539}\"]"
}
Bash接口
已废弃。可使用BDWareConfigTool代替。
通过命令行发送Socket指令, 执行调用ContractController
类中方法, 完成以下功能. (需要在本机的1615
端口运行ContractManager
实例)
指令
java -jar yjs.jar function_name arguments
function_name
为调用的方法名;
arguments
为方法参数.
启动合约
参数
function_name
为startContract
;
arguments
为启动合约需要的参数, 包括合约类型type
, 合约IDid
, 合约脚本script
.
指令示例
java -jar yjs.jar startContract "{\"type\":\"Algorigthm\",\"id\":\"656565\",\"script\":\"contract c{function main(arg){return arg/1.0+1;}}\"}"
调用合约
参数
function_name
为executeContract
;
arguments
为调用合约需要的参数, 包括调用参数arg
, 合约IDcontractID
.
指令示例
java -jar yjs.jar executeContract "{\"arg\":\"http://www.baidu.com\",\"contractID\":\"656564\"}"
停止合约
参数
function_name
为stopContract
;
arguments
为调用合约需要的参数, 即合约IDcontractID
.
指令示例
java -jar yjs.jar stopContract "{\"arg\":\"http://www.baidu.com\",\"contractID\":\"656564\"}"
停止全部合约
参数
function_name
为stopAllContracts
.
指令示例
java -jar yjs.jar stopAllContracts
查询全部合约
参数
function_name
为listContracts
.
指令示例
java -jar yjs.jar listContracts