-
Notifications
You must be signed in to change notification settings - Fork 3
/
transaction_api.go
96 lines (82 loc) · 2.41 KB
/
transaction_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package antchain
// 创建账户
func (c *Client) CreateAccount(orderID string, newAccount string, newKmsID string) (publicKey string, err error) {
c.Shakehand()
params := ParamsMap{
"orderId": orderID,
"bizid": c.BIZID,
"method": "TENANTCREATEACCUNT",
"account": c.Account,
"mykmsKeyId": c.MykmsKeyID,
"newAccountId": newAccount,
"newAccountKmsId": newKmsID,
"accessId": c.AccessID,
"token": c.Token,
"tenantid": c.TenantID,
}
data, err := c.doRequest(CHAIN_CALL_FOR_BIZ, params)
if err != nil {
return
}
publicKey = string(data)
return
}
// 存证
func (c *Client) Deposit(orderID string, content string, gas int) (hash string, err error) {
c.Shakehand()
params := ParamsMap{
"orderId": orderID,
"bizid": c.BIZID,
"account": c.Account,
"content": content,
"mykmsKeyId": c.MykmsKeyID,
"method": "DEPOSIT",
"accessId": c.AccessID,
"token": c.Token,
"gas": gas,
"tenantid": c.TenantID,
}
data, err := c.doRequest(CHAIN_CALL_FOR_BIZ, params)
hash = string(data)
return
}
// 部署Solidity合约
func (c *Client) DeploySol(orderID string, contractName string, contractCode string, gas int) (data []byte, err error) {
c.Shakehand()
params := ParamsMap{
"orderId": orderID,
"bizid": c.BIZID,
"account": c.Account,
"contractName": contractName,
"contractCode": contractCode,
"mykmsKeyId": c.MykmsKeyID,
"method": "DEPLOYCONTRACTFORBIZ",
"accessId": c.AccessID,
"token": c.Token,
"gas": gas,
"tenantid": c.TenantID,
}
data, err = c.doRequest(CHAIN_CALL_FOR_BIZ, params)
return
}
// 异步调用Solidity合约
func (c *Client) CallSol(orderID string, contractName string, methodSignature string, inputParams string, outTypes string, gas int) (data []byte, err error) {
c.Shakehand()
params := ParamsMap{
"orderId": orderID,
"bizid": c.BIZID,
"account": c.Account,
"contractName": contractName,
"methodSignature": methodSignature,
"mykmsKeyId": c.MykmsKeyID,
"method": "CALLCONTRACTBIZASYNC",
"inputParamListStr": inputParams,
"outTypes": outTypes,
"accessId": c.AccessID,
"token": c.Token,
"gas": gas,
"tenantid": c.TenantID,
}
data, err = c.doRequest(CHAIN_CALL_FOR_BIZ, params)
return
}