Skip to content
linj edited this page Nov 23, 2022 · 1 revision

事件接口

[TOC]

1 发布事件

1.1 生成发布事件的交易(未签名) CreateTransaction

请求报文:

{
	"jsonrpc":"2.0",
	"id": int32,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "EventPublish",
			"payload": {
				"type": "string",
				"subType": "string",
				"time": int64,
				"content": "string",
				"introduction": "string"
			}
		}
	]
}

参数说明:

Chain33.CreateTransaction结构按通用要求填写: execer,执行器名称,这里固定为oralce actionName,操作名称,这里固定为EventPublish payload携带的内容格式如下:

参数 类型 说明
type string 事件类型
subType string 事件子类型
time int64 事件结果预计公布时间,UTC时间
content string 事件内容,例如可以用json格式表示
introduction string 事件介绍

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明:

参数 类型 说明
result string 交易十六进制编码后的字符串

示例 Request:

{
	"id": 0,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "EventPublish",
			"payload": {
				"type": "football",
				"subType": "Premier League",
				"time": 1548084600,
				"content": "test",
				"introduction": "test2"
			}
		}
	]
}

Response:

{
	"id": 0,
	"result":"0a066f7261636c65123138010a2d1208666f6f7462616c6c1a0e5072656d696572204c656167756520fe",
	"error": null
}

1.2 交易签名 SignRawTx

请求报文:

{
	"id": int32,
	"method": "Chain33.SignRawTx",
	"params": [
		{
			"addr": "string",
			"txHex": "string",
			"expire": "string"
		}
	],
}

参数说明

参数 类型 是否必填 说明
addr string addr与privkey可以只输入其一,如果使用addr则依赖钱包中存储的私钥签名
privkey string addr与privkey可以只输入其一,如果使用privkey则直接签名
txHex string 上一步生成的原始交易数据
expire string 过期时间可输入如"300s","-1.5h"或者"2h45m"的字符串,有效时间单位为"ns", "us" (or "µs"), "ms", "s", "m", "h"
index int32 若是签名交易组,则为要签名的交易序号,从1开始,小于等于0则为签名组内全部交易
token string
fee int64 费用
newToAddr string

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易签名后的十六进制字符串

1.3 发送交易 SendTransaction

请求报文:

{
	"id":int32,
	"method": "Chain33.SendTransaction",
	"params": [{"data": "string"}]
}

参数说明

参数 类型 是否必填 说明
data string 为上一步签名后的交易数据
token string 可为空

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易发送后,生成的交易哈希(后面可以使用此哈希查询交易状态和历史

2 取消发布事件

2.1 生成取消发布事件的交易(未签名) EventAbort

请求报文

{
	"id":int32,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "EventAbort",
			"payload": {"eventID": "0x2edd12dee5724526d06517ce52704470b24b89dc918497d62c152dcfe8ddd5fd"}
		}
	]
}

参数说明

Chain33.CreateTransaction结构按通用要求填写: execer,执行器名称,这里固定为oralce actionName,操作名称,这里固定为EventAbort payload携带的内容格式如下:

参数 类型 说明
eventID string 发布事件的事件ID

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易十六进制编码后的字符串

3 预发布事件结果

3.1 生成预发布事件结果交易(未签名) ResultPrePublish

请求报文:

{
	"id":int32,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "ResultPrePublish",
			"payload": {
				"eventID": "0xfa3e8d786df3085e71bcff1615847d2f353c45545724c785a9729db1c6106b13",
				"source": "............",
				"result": "0:0"
			}
		}
	]
}

参数说明

Chain33.CreateTransaction结构按通用要求填写: execer,执行器名称,这里固定为oralce actionName,操作名称,这里固定为ResultPrePublish payload携带的内容格式如下:

参数 类型 说明
eventID string 发布事件的事件ID
source string 发布结果的源,比如XX体育
result string 发布的事件结果,比如比赛比分

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易十六进制编码后的字符串

4 取消预发布的结果

4.1 生成取消预发布结果的交易(未签名) ResultAbort

请求报文

{
	"id":int32,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "ResultAbort",
			"payload": {
				"eventID": "0x1c3dc77998a4efa1b3b3bd527b83714da8c6b668d26002f06de6144277cb6ddd"
			}
		}
	]
}

参数说明

Chain33.CreateTransaction结构按通用要求填写: execer,执行器名称,这里固定为oralce actionName,操作名称,这里固定为ResultAbort payload携带的内容格式如下:

参数 类型 说明
eventID string 发布事件的事件ID

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易十六进制编码后的字符串

5 正式发布事件结果

5.1 生成正式发布事件结果交易(未签名) ResultPublish

请求报文

{
	"id":int32,
	"method": "Chain33.CreateTransaction",
	"params": [
		{
			"execer": "oracle",
			"actionName": "ResultPublish",
			"payload": {
				"eventID": "0xd0181ccc942c72d1a2d1bd10c520751fc743693c8131e59119063b324fa96796",
				"source": "............",
				"result": "1:1"
			}
		}
	]
}

参数说明

Chain33.CreateTransaction结构按通用要求填写: execer,执行器名称,这里固定为oralce actionName,操作名称,这里固定为ResultPublish payload携带的内容格式如下:

参数 类型 说明
eventID string 发布事件的事件ID
source string 发布结果的源,比如XX体育
result string 发布的事件结果,比如比赛比分

响应报文

{
	"id":int32,
	"result":"string",
	"error":null
}

参数说明

参数 类型 说明
result string 交易十六进制编码后的字符串

6 查询接口

6.1 根据发布事件的事件ID查询当前状态 QueryOraclesByIDs

请求报文

{
	"id":int32,
	"method": "Chain33.Query",
	"params": [
		{
			"execer": "oracle",
			"funcName": "QueryOraclesByIDs",
			"payload": {
				"eventID": ["0xd0181ccc942c72d1a2d1bd10c520751fc743693c8131e59119063b324fa96796"]
		  }
		}
	]
}

参数说明

Chain33.Query结构按通用要求填写: execer,执行器名称,这里固定为oracle funcName,操作名称,这里固定为QueryOraclesByIDs payload携带的内容格式如下:

参数 类型 说明
eventID []string 需要查询信息的事件ID数组

响应报文

{
	"id":int32,
	"result": {
		"status": [
			{
				"eventID": "0xd0181ccc942c72d1a2d1bd10c520751fc743693c8131e59119063b324fa96796",
				"addr": "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt",
				"type": "football",
				"subType": "Premier League",
				"time": "1548084600",
				"content": "test007",
				"introduction": "test007-intr",
				"status": {
					"opAddr": "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt",
					"status": 5
				},
				"source": "............",
				"result": "1:1",
				"preStatus": {
					"opAddr": "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt",
					"status": 3
				}
			}
		]
	},
	"error": null
}

参数说明

参数 类型 说明
status.eventID string 事件ID
status.addr string 事件的地址
status.type string 事件的类型
status.subType string 发布事件的子类型
status.time int64 事件结果预计公布时间,UTC时间
status.content string 事件内容,例如可以用json格式表示
status.introduction string 事件介绍
status.status json 当前状态,包括操作者地址,当前状态值;0:初始状态,1:事件已发布,2:事件已取消,3:事件结果已预发布,4:事件预发布的结果已取消,5:事件结果已发布
status.source string 发布结果的源,比如XX体育
status.result string 发布事件的结果,比如比赛比分
status.preStatus json 前一个状态,包括操作者地址,当前状态值

6.2 根据事件所处状态查询事件ID QueryEventIDsByStatus

请求报文

{
	"id":int32,
	"method": "Chain33.Query",
	"params": [
		{
			"execer": "oracle",
			"funcName": "QueryEventIDsByStatus",
			"payload": {
				"status": 4,
				"addr": "",
				"type": "",
				"eventID": ""
			}
		}
	]
}

参数说明

Chain33.Query结构按通用要求填写: execer,执行器名称,这里固定为oracle funcName,操作名称,这里固定为QueryEventIDsByStatus payload携带的内容格式如下:

参数 类型 是否必填 说明
status int32 事件所处状态值
addr string 不填 创建事件的地址
type string 不填 事件的类型
eventID string 视情况 事件ID,第一次查询为空,如果得到结果数量超过一页,将eventID设置为上次查询结果的最后一个id,从而查到下一页的数据

响应报文

{
	"id":int32,
	"result": {
		"eventID": [
			"0x45aca020ca26b2e0f92590c0662978194221a6b791a97e748f599221df3f2786",
			"0x437d5ca35bbc78a8bdf72978c018270883a923fce38664be0de1e6dc569e277f"
		]
	},
	"error": null
}

参数说明

参数 类型 说明
eventID []string 符合条件的事件ID数组

6.3 根据创建事件的用户地址和事件所处状态查询事件ID QueryEventIDsByAddrAndStatus

请求报文

{
	"id":int32,
	"method": "Chain33.Query",
	"params": [
		{
			"execer": "oracle",
			"funcName": "QueryEventIDsByAddrAndStatus",
			"payload": {
				"status": 2,
				"addr": "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt",
				"type": "",
				"eventID": ""
			}
		}
	]
}

参数说明

Chain33.Query结构按通用要求填写: execer,执行器名称,这里固定为oracle funcName,操作名称,这里固定为QueryEventIDsByAddrAndStatus payload携带的内容格式如下:

参数 类型 是否必填 说明
status int32 事件所处状态值
addr string 创建事件的地址
type string 不填 事件的类型
eventID string 视情况 事件ID,第一次查询为空,如果得到结果数量超过一页,将eventID设置为上次查询结果的最后一个id,从而查到下一页的数据

响应报文

{
	"id":int32,
	"result": {
		"eventID": [
			"0xdd6b4ebfb7560e803cc4500490d2b7e6818296eed19d938446f2230eaa04a5e1",
			"0x1aae4290800019f6ba97ac45acba334aa919faff1a37c4adffce5eb12c6d3a06"
		]
	},
	"error": null
}

参数说明

参数 类型 说明
eventID []string 符合条件的事件ID数组

6.4 根据创建事件的类型和事件所处状态查询事件ID

请求报文

{
	"id":int32,
	"method": "Chain33.Query",
	"params": [
		{
			"execer": "oracle",
			"funcName": "QueryEventIDsByTypeAndStatus",
			"payload": {
				"status": 1,
				"addr": "",
				"type": "football",
				"eventID": ""
			}
		}
	]
}

参数说明

Chain33.Query结构按通用要求填写: execer,执行器名称,这里固定为oracle funcName,操作名称,这里固定为QueryEventIDsByTypeAndStatus payload携带的内容格式如下:

参数 类型 是否必填 说明
status int32 事件所处状态值
addr string 不填 创建事件的地址
type string 事件的类型
eventID string 视情况 事件ID,第一次查询为空,如果得到结果数量超过一页,将eventID设置为上次查询结果的最后一个id,从而查到下一页的数据

响应报文

{
	"id":int32,
	"result": {
		"eventID": [
			"0xdd6b4ebfb7560e803cc4500490d2b7e6818296eed19d938446f2230eaa04a5e1",
			"0x1aae4290800019f6ba97ac45acba334aa919faff1a37c4adffce5eb12c6d3a06"
		]
	},
	"error": null
}

参数说明

参数 类型 说明
eventID []string 符合条件的事件ID数组
Clone this wiki locally