Compare commits

...

2 Commits

Author SHA1 Message Date
sulenn b3e4361e1a docs: update content 2021-05-13 11:18:59 +08:00
sulenn 0bb2d5be8a init repo 2020-09-28 21:38:55 +08:00
10 changed files with 207 additions and 0 deletions

Binary file not shown.

Binary file not shown.

BIN
sendTransactionApi.docx Normal file

Binary file not shown.

27
trustie.txt Normal file
View File

@ -0,0 +1,27 @@
# 登录说明
https://baas.internetapi.cn/
用户名trustie@test.com
密码test@123
已创建好链:
已创建好简单的示例Hello这部分后续北大会参与讨论并开发对应的智能合约。
合约调用示例:(有Http/websocket两种
其中,若需签名调用则参考:
https://public.internetapi.cn/docs/bdcontract/doc/ContractAPI.html#id29
http://39.105.85.62:21030/SCIDE/SCManager?action=executeContract&contractID=-620602333&operation=main&arg=hhh
账本调用示例:
可通过https://baas.internetapi.cn/#/chain-management/nodes 查看节点列表。
https://059.node.internetapi.cn:21030/SCIDE/SCManager?action=executeContract&contractID=HelloWorld&operation=get&arg=&pubkey=04181fa77a16af26d5094e8a1fcb3225e45e0c7bf62c8ee261de4a63c243c7b06046137c6c55e6d15bbbfdc782d758ea26edfc42b524954e2bba159a91af8ca925&signature=65663714d850ca78e904e686fcef10c3342c0e7714fa14ea3c2e1e7537d0d98aa480ccbfaa6fc83e34f69bb908ab11d954970548f1c4466a9f433e317dbbb4de
使用节点列表的ip+端口可以用以下api进行存证/查证。
https://public.internetapi.cn/?dir=docs/bdledger/http-api
也有grpc版本的接口
https://public.internetapi.cn/?dir=docs/bdledger/bdledger-sdk-java/latest
对应的jar下载地址
https://public.internetapi.cn/?dir=releases/bdledger-java-sdk/dev-200922.1278255c

Binary file not shown.

Binary file not shown.

BIN
北大数瑞资料.zip Normal file

Binary file not shown.

103
合约.md Normal file
View File

@ -0,0 +1,103 @@
39.105.85.62:21030
#### 保存合约脚本
向服务器发送请求, 向服务器本地保存合约脚本内容.
##### 参数
| 字段 | 值 |
| ------- | -------------- |
| action | writeDyjs |
| target | 合约脚本文件名 |
| content | 合约脚本内容 |
##### 请求示例
```
http://39.105.85.62:21030/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
```
##### 返回结果示例
```json
{
"status": false,
"action": "onWriteDyjs",
"data": "success"
}
```
后续用户可启动并调用该合约.
#### 启动合约
向服务器发送请求, 启动某个合约.
##### 参数
| 字段 | 值 |
| ------ | --------------------------------- |
| action | startContract |
| script | 合约脚本内容, 需进行进行URIEncode |
##### 请求示例
```
http://39.105.85.62:21030/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
```
##### 返回结果示例
```json
{
"data": "{\"status\":\"Success\",\"result\":\"\"}",
"action": "onStartContract",
"cid": "-562752842",
"executeTime": 1187
}
```
#### 调用合约
向服务器发送请求, 调用某个合约.
##### 参数
| 字段 | 值 |
| -------------------- | --------------------------- |
| action | executeContract |
| contractID | 合约ID |
| *withDynamicAnalysis | true/false 是否进行动态分析 |
| operation | 调用合约的方法名 |
| arg | 调用合约的参数 |
| *pubkey | 可选,调用者公钥 |
| *signature | 可选,签名 |
`*`表示可选参数其中pubkey为sm2的公钥计算方式如下
```javascript
//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
```
##### 返回结果示例
```json
{
"data": "{\"status\":\"Success\",\"result\":\"3\"}",
"action": "onExecuteResult",
"executeTime": "13"
}
```

Binary file not shown.

View File

@ -0,0 +1,77 @@
# RepoRouter
| | 偶Repo |
| ------------- | ----------------------------- |
| 节点地址 | 024.node.internetapi.cn:21030 |
| contract name | RepoRouter |
方法:
| 方法名 | |
| --------- | ------------------------ |
| setTable | 设定节点的路由信息表 |
| getTable | 获取路由信息表 |
| getRouter | 获取发送给节点的路由信息 |
| broadcast | 分发路由信息给所有节点 |
table信息示例
```
[
{
"index":"0",
"contract":"RepositoryDB0",
"url":"023.node.internetapi.cn:21030"
},
{
"index":"1",
"contract":"RepositoryDB1",
"url":"023.node.internetapi.cn:21030"
}
]
```
router信息示例
```
{
"0":"RepositoryDB0",
"1":"RepositoryDB1"
}
```
# RepositoryDB
| | 偶Repo | 奇Repo |
| ------------- | ----------------------------- | ----------------------------- |
| 节点地址 | 023.node.internetapi.cn:21030 | 023.node.internetapi.cn:21030 |
| contract name | RepositoryDB0 | RepositoryDB1 |
接口方法名与pdf一致所有查询接口均需增加`repo_id`字段
## 调用方式示例
偶Repo
http://023.node.internetapi.cn:21030/SCIDE/SCManager?action=executeContract&contractID=RepositoryDB0&operation=getCommit&arg={%22commit_hash%22:%228f2dc2ec21876d31ffa06744f215b6a17c5d3bad%22,%22repo_id%22:%20%221002604%22}
奇Repo
http://023.node.internetapi.cn:21030/SCIDE/SCManager?action=executeContract&contractID=RepositoryDB1&operation=getCommit&arg={%22commit_hash%22:%228f2dc2ec21876d31ffa06744f215b6a17c5d3bad%22,%22repo_id%22:%20%221002603%22}
(暂时不需pubkey验证)
```
//sm2 可从sm2.js中加载获得。
signature = sm2.doSignature(contractID+"|"+operation+"|"+arg+"|"+pubkey,privateKey);
sm2.doSignature("Repository0|putCommit|{}|0496668d3a3386e4c541e124dd7af67ac3d3763fcbc4cd517807eea86b31f4ce6cd27024587f30458592c48f18c5e7c89f31e12ddea1a16b25add47fa84ddc998d", "a33d2ced99cb39484f5c3ad44aa3708c45ffee6d0225d2110f88a318cf76f3c4");
&pubkey=0496668d3a3386e4c541e124dd7af67ac3d3763fcbc4cd517807eea86b31f4ce6cd27024587f30458592c48f18c5e7c89f31e12ddea1a16b25add47fa84ddc998d&signature=909c55bb92877fe2c62db51596adfb4d7fa10172da163ff8bde9ce6a12ccd40f6c8a374bc0d1c32744669d6d73ebd3cf5510e78d7c06b5611fd4ac9d90311555
```