RPC API

net_version

返回当前连接网络的ID。

参数

返回值
  • String - 当前连接网络的ID
    • “1”: MAN Mainnet
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'

响应:

1
2
3
4
5
{
"id":67,
"jsonrpc": "2.0",
"result": "1"
}

net_listening

如果客户端处于监听网络连接的状态,该调用返回true。

参数

返回值
  • Boolean - 客户端处于监听状态时返回true,否则返回false
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":67}'

响应:

1
2
3
4
5
{
"id":67,
"jsonrpc":"2.0",
"result":true
}

net_peerCount

返回当前客户端所连接的对端节点数量。

参数

返回值
  • QUANTITY - 整数,所连接对端节点旳数量
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":67}'

响应:

1
2
3
4
5
{
"id":67,
"jsonrpc": "2.0",
"result": "0x2" // 2
}

man_protocolVersion

返回当前协议的版本。

参数

返回值
  • String - 当前的MAN协议版本
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_protocolVersion","params":[],"id":67}'

响应:

1
2
3
4
5
{
"id":67,
"jsonrpc": "2.0",
"result": "54"
}

man_mining

如果客户端在积极挖矿则返回true。

参数

返回值
  • Boolean – 当客户端在挖矿时返回true,否则返回false。
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_mining","params":[],"id":71}'

响应:

1
2
3
4
5
{
"id":71,
"jsonrpc": "2.0",
"result": true
}

man_hashrate

返回节点挖矿时每秒可算出的哈希数量。

参数

返回值
  • QUANTITY - 每秒算出的哈希数量
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_hashrate","params":[],"id":71}'

响应:

1
2
3
4
5
{
"id":71,
"jsonrpc": "2.0",
"result": "0x38a"
}

man_getDepositByAddr

返回指定账户的抵押信息

参数
  • String – 字符串,MAN地址
  • QUANTITY|TAG - 整数块编号,或字符串”latest”
返回值
  • OBJECT –抵押账户信息,信息结构如下:
    • AddressA0:STRING-抵押地址
    • SignAddressA1: STRING-签名地址
    • OnlineTime: QUANTITY-整形,在线时长,按照块高计数
    • Role:QUANTITY-参选身份, 128:验证者;16:矿工
    • PositionNonce: QUANTITY-整形,仓位nonce值
    • Dpstmsg:OBJECT-抵押仓位信息列表,抵押仓位信息结构如下:
      • DepositType:QUANTITY-整形,//0-活期,1-定期1个月,3-定期3个月,6-定期6个月
      • DepositAmount:QUANTITY-整形,以韦为单位的抵押值
      • Interest:QUANTITY-整形,以韦为单位的利息值
      • Slash:QUANTITY-整形,以韦为单位的惩罚值
      • BeginTime: QUANTITY-整形,UTC时间,抵押开始时间;活期为0
      • EndTime: QUANTITY-整形,UTC时间,定期表示退选时间;活期表示最早退款时间。
      • Position: QUANTITY-整形仓位号
    • WithDrawInfo:OBJECT-退款对象数组,退款对象信息结构如下:
      • WithDrawAmount:QUANTITY-整形,以韦为单位的退款金额
      • WithDrawTime:QUANTITY-整形,UTC时间,退款时间
示例

请求:

1
curl -X POST --data {"jsonrpc":"2.0","method":"man_getDepositByAddr","params":["MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb", "latest"],"id":67}

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"jsonrpc": "2.0",
"id": 67,
"result": {
"AddressA0": "MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb",
"AddressA1": "MAN.Tfr4DZYNeWqqTth87phrg2KZcqya",
"OnlineTime": "0x81923",
"Role": "0x80",
"PositionNonce": 0,
"Dpstmsg": [
{
"DepositType": 0,
"DepositAmount": "0x8631d81fc94c92f9b336d",
"Interest": "0x2bf9f54df6717b96ef",
"Slash": "0x0",
"BeginTime": 0,
"EndTime": 0,
"Position": 0,
"WithDrawInfolist": []
}
]
}
}

man_getDeposit

返回指定区块的抵押信息,通过高度指定区块

参数
  • QUANTITY|TAG - 整数块编号,或字符串”latest”、”earliest”
1
2
3
params: [
' 0xac477 '// 705655
]
返回值
  • OBJECT –抵押账户信息数组,信息结构如下:

    • Address:STRING-抵押地址
  • SignAddress: STRING-签名地址

  • Deposit: QUANTITY-抵押金额

  • WithdrawH: QUANTITY-参选状态,0, 在选;非0,退选高度

  • OnlineTime: QUANTITY-整形,在线时长,按照块高计数

  • Role:QUANTITY-参选身份, 128:验证者;16:矿工

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getDeposit","params":["0x01"],"id":67}'

响应:

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
{
"jsonrpc": "2.0",
"id": 67,
"result": [
{
"Address": "MAN.4M29vNSn7jG1dwLs7bxG2RHYLikWG",
"SignAddress": "MAN.3EX7HepVHi85wAh6duzGotYGbpBQR",
"Deposit": 1e+25,
"WithdrawH": 0,
"OnlineTime": 0,
"Role": 128
},
{
"Address": "MAN.439xNJTQrmmYEkm2wm5ThU79UsMiu",
"SignAddress": "MAN.4URp9YU7ufxNf1i1EbUs1PGhYwFzJ",
"Deposit": 1e+25,
"WithdrawH": 0,
"OnlineTime": 0,
"Role": 128
},
{
"Address": "MAN.2LrYy4EbhAi7Az4HdzKHbbyraMPBj",
"SignAddress": "MAN.4PMxVeKv9JZpBxK8oWcMDmcTUZtn9",
"Deposit": 1e+22,
"WithdrawH": 0,
"OnlineTime": 0,
"Role": 16
}
]
}

man_getMatrixCoin

返回多币种信息。

参数
  • QUANTITY|TAG - 整数块编号,或者字符串”latest”, “earliest”
1
2
3
params:  [
"latest"
]
返回值
  • OBJECT – STRING数组,多币种名称
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getMatrixCoin","params":[ "latest"],"id":67}'

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"jsonrpc": "2.0",
"id": 67,
"result": [
"MBN",
"MCN",
"MDN",
"MEN",
"MIN",
"MSN",
"MUSD"
]
}

man_getMatrixCoinConfig

返回多币种的配置信息

参数
  • STRING – 币种名称
  • QUANTITY|TAG - 整数块编号,或者字符串”latest”, “earliest”
1
2
3
4
params: [
'MEN',
'latest'
]
返回值
  • OBJECT – 币种配置信息。结构如下:

    • CoinRange:STRING。扩展保留。
  • CoinType:STRING。支付币种名称。

  • PackNum:QUANTITY。整形,每区块打包交易最大值。

  • CoinUnit:QUANTITY。整形,币种单位。

  • CoinTotal:QUANTITY。整形,币种发行量。

  • CoinAddress:DATA,20字节。币种交易费账户地址。

示例

请求:

1
curl -X POST --data '  {"jsonrpc":"2.0","method":"man_getMatrixCoinConfig","params":["MEN", "latest"],"id":67}'

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"jsonrpc": "2.0",
"id": 67,
"result": [
{
"CoinRange": "MEN",
"CoinType": "MEN",
"PackNum": 9999,
"CoinUnit": "0xde0b6b3a7640000",
"CoinTotal": "0x33b2e3c9fd0803ce8000000",
"CoinAddress": "0x8000000000000000000000000000000000000001"
}
]
}

man_getDestroyBalance

返回创建多币种消耗MAN的数量。

参数

返回值

QUANTITY - 整数,以zhu为单位的当前创建多币种消耗MAN的数量。

示例

请求:

1
{"jsonrpc":"2.0","method":"man_getDestroyBalance","params":[ "latest"],"id":67}

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 67,
"result": "0x152d02c7e14af6800000" // 100000000000000000000000
}

man_getSignAccountsByHash

返回指定区块的区块签名列表,通过Hash指定区块

参数
  • DATA - 32字节,块哈希
1
2
params: [       '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]
返回值
  • Object Array-签名对象数组。签名结构如下:

    • Sign: DATA, 65字节 – 签名
  • Account:STRING,–签名账户

  • Validate:BOOL, -签名状态。TRUE:签名;FALSE:未签名

  • Stock: QUANTITY ,股权。目前无效。

示例

#请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getSignAccountsByHash","params":["0x43cfffb8029e9ac1f380f0b970b0be0bdfdf96bc42599cc110ca31f00aa14d12"],"id":67}'

#响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"jsonrpc": "2.0",
"id": 67,
"result": [
{
"sign": "0xf3fd53b57786bee28aa27e8439251e8c1c5233db964b8b69528ebc46861e79090f4ae49e617707c11e121e24ef099160262bcdf2347033d399d003ef7f6d69e100",
"account": "MAN.3pTAH8pGwmJ94Zm1B1sNMcm4q1kVr",
"validate": true,
"stock": 0
},
{
"sign": "0xcd577141ac1a9173316f20df9a39318a107169c5d93659a04b749cddb606e9f16e70b37cad5230c4e4a0e2c071f5d6b701dadf005211539b92309a9fc75e6c4501",
"account": "MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb",
"validate": true,
"stock": 0
},
{
"sign": "0xdc61de03cae70a4e010c695c123142e51aa9beff7b29be25c09cf784130558c634044c5d86f9c19898255d95494283a19ac77bb7ab59c96159537b6fa94a858f01",
"account": "MAN.23983gYFh8YH1ovpzKa3wpcNaRVn7",
"validate": true,
"stock": 0
}
]
}

man_getSignAccountsByNumber

返回指定区块的区块签名列表,通过高度指定区块

参数
  • QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”
1
2
3
params: [
'0x1b4', // 436
]
返回值

参考man_getSignAccountsByHash返回值

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getSignAccountsByNumber","params":["0x1b4"],"id":67}'

响应:

参考man_getSignAccountsByHash响应

man_call

立刻执行一个新的消息调用,无需在区块链上创建交易。

参数
  • Object - 交易调用对象
    • from: STRING - 发送交易的原地址,可选
    • to: STRING - 交易目标地址
    • Currency:STRING-交易币种名称
    • gas: QUANTITY - 交易可用gas量,可选。man_call不消耗gas,但是某些执行环节需要这个参数
    • gasPrice: QUANTITY - gas价格,可选
    • value: QUANTITY - 交易发送的MAN数量,可选
    • data: DATA - 方法签名和编码参数的哈希,可选
    • QUANTITY|TAG - 整数块编号,或字符串”latest”、”earliest”
返回值

DATA - 所执行合约的返回值

示例

请求:

1
curl -X POST --data '{"jsonrpc": "2.0","method": "man_call","params": [{"to": "MAN.468kLTuAEjm53ro2pPErnAAHqbccK","data": "0x58975919","currency": "MAN"},"latest"],"id": 67}'

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 67,
"result": "0x0000000000000000000000000000000000000000000000000000000000000006"
}

man_getValidatorGroupInfo

返回指定区块联合挖矿信息,通过块高指定区块。

参数
  • QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”
1
2
3
params: [
'latest'
]
返回值

OBJECT-联合挖矿信息MAP。MAP:以子合约地址为键值, STRING;合约存储信息为值的切片,OBJECT。
合约存储信息结构如下:

  • OwnerInfo。OBJECT对象,合约创建信息,结构如下:

    • Owner:String- Owner账户地址

    • SignAddress:String-签名账户地址

    • WithdrawAllTime:QUANTITY-全部撤销时间

  • Reward。OBJECT对象,回报分配信息,结构如下:

    • LevelRate:OBJECT对象数组-参与者门限和回报比例信息,结构如下:

      • Rate:对象。分配比例系数。{ Decimal : 分母; Rate :分子};

      • Threshold:QUANTITY –整形,参与的最低门限。单位韦。

    • NodeRate:OBJECT对象-管理费信息,结构如下:

      • Decimal:QUANTITY –整形,管理费比例的分母

      • Rate:QUANTITY –整形,管理费比例的分子

    • OwnerRate:OBJECT对象数组-owner回报比例信息,结构如下:

      • Decimal:QUANTITY –整形,owner回报比例的分母

      • Rate:QUANTITY –整形,owner回报比例的分子

    • ValidatorMap : OBJECT, 参与者信息数组,包括Owner;参与者信息结构如下:

      • Address:STRING-参与者账户地址;

      • Reward: QUANTITY –整形,奖励分配累加值。当用户提取奖励后,该值会减去用户提取值。

      • AllAmount: QUANTITY –整形,总抵押值

      • Current: OBJECT-活期抵押信息,结构如下:

        • Amount: QUANTITY –整形,活期抵押金额

        • PreAmount: QUANTITY –整形,上一轮的活期抵押金额

        • Interest: QUANTITY –整形,活期利息

        • WithdrawList:退出抵押信息列表.a) WithDrawAmount 退出金额;b)

      • WithDrawTime 退出时间

      • Positions : OBJECT-定期抵押仓信息列表;定期抵押信息结构如下:

        • DType: QUANTITY –整形,定期抵押类型

        • Position: QUANTITY –整形, 定期抵押仓号

        • Amount: QUANTITY –整形,定期抵押金额

        • EndTime: QUANTITY –整形,定期结束时间

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getValidatorGroupInfo","params":["0x910f0"],"id":1}'

响应:

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
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"MAN.w8Nvei3g98GAtbuCzPWHb9UiDRZj": {
"OwnerInfo": {
"Owner": "MAN.s7jf4pkbZdfnUaZyDL4EGZprWrHm",
"SignAddress": "MAN.4SYA8BxUZaevRXczJvdoSMT2p89Np",
"WithdrawAllTime": 0
},
"Reward": {
"LevelRate": [
{
"Rate": {
"Decimal": "1000000000",
"Rate": "1"
},
"Threshold": "0"
},
{
"Rate": {
"Decimal": "1000000000",
"Rate": "1"
},
"Threshold": "10000000000000000000000"
},
{
"Rate": {
"Decimal": "1000000000",
"Rate": "1"
},
"Threshold": "100000000000000000000000"
}
],
"NodeRate": {
"Decimal": "1000000000",
"Rate": "0"
},
"OwnerRate": {
"Decimal": "1000000000",
"Rate": "1"
}
},
"ValidatorMap": [
{
"Address": "MAN.B1dmKTmWqNfHpv6mKytRrCy2NkWi",
"AllAmount": "100000000000000000000",
"Current": {
"Amount": "100000000000000000000",
"Interest": "5891875148930089",
"PreAmount": "0",
"WithdrawList": []
},
"Positions": [],
"Reward": "57970186835851759"
},
{
"Address": "MAN.G8dYKuZvPQAqVXRSzCTV7sYPhGFK",
"AllAmount": "10000000000000000000000",
"Current": {
"Amount": "10000000000000000000000",
"Interest": "589187514893008924",
"PreAmount": "0",
"WithdrawList": []
},
"Positions": [],
"Reward": "0"
}
]
}
}
}

man_getStorageAt

返回指定地址存储位置的值。

参数
  • STRING –字符串,MAN地址
  • QUANTITY - 存储中的位置号
  • STRING –字符串,币种名称
  • QUANTITY|TAG - 整数块号,或字符串”latest”、”earliest”
返回值

DATA - 指定存储位置的值

示例

根据要提取的存储计算正确的位置。考虑下面的合约,由MAN.o8WM6Sq643rUfAHvpx2MYZLFWwhr部署在地址MAN.aR54tfdEWDfsfHhdsy6BkRVGRYL

1
2
3
4
5
6
7
8
9
10
contract Storage {
uint pos0;
mapping(address => uint) pos1;


function Storage() {
pos0 = 1234;
pos1[msg.sender] = 5678;
}
}

提取pos0的值很直接:

1
curl -X POST --data '{"jsonrpc":"2.0", "method": "man_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "MAN", "latest"], "id": 1}' localhost:8545

响应结果:

1
{"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000004d2"}

要提取映射表中的成员就难一些了。映射表中成员位置的计算如下:

1
keccack(LeftPad32(key, 0), LeftPad32(map position, 0))

这意味着为了提取pos1[“MAN.o8WM6Sq643rUfAHvpx2MYZLFWwhr“]的值,我们需要如下计算:

1
keccak(decodeHex("000000000000000000000000391694e7e0b0cce554cb130d723a9d27458f9298" + "0000000000000000000000000000000000000000000000000000000000000001"))

gman控制台自带的web3库可以用来进行这个计算:

1
2
3
4
> var key = "000000000000000000000000391694e7e0b0cce554cb130d723a9d27458f9298" + "0000000000000000000000000000000000000000000000000000000000000001"
undefined
> web3.sha3(key, {"encoding": "hex"})
"0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9"

现在可以提取指定位置的值了:

1
curl -X POST --data '{"jsonrpc":"2.0", "method": "man_getStorageAt", "params": ["MAN.aR54tfdEWDfsfHhdsy6BkRVGRYL", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "latest"], "id": 1}' localhost:8545

响应结果如下:

1
{"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000000000000000000000000000000000000000162e"}

man_getTopologyStatusByNumber

获取指定区块顶层节点拓扑信息,通过高度指定区块。

参数
  • QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”
1
2
3
params:  [
'0xac477', // 705655
]
返回值

Object - 匹配的拓扑信息对象。结构如下:

  • leader_reelect:BOOL-验证者重选状态。False:未发生验证者重选;True:发生验证者重选;

  • validators:验证者信息数组。验证者信息结构如下:

    • account:STRING-账户;

    • online:BOOL-在线状态。True:在线;False:离线

    • position:QUANTITY-位置编号

  • backup_validators:备份验证者信息数组。备份验证者信息结构见验证者信息结构

  • miners:矿工信息数组。矿工信息结构见验证者信息结构

  • elect_validators:验证者主节点共识上下线信息。信息结构见验证者信息结构

  • elect_backup_validators:验证者备份节点共识上下线信息。信息结构见验证者信息结构

示例

请求:

1
curl -X POST --data {"jsonrpc":"2.0","method":"man_getTopologyStatusByNumber","params":["0xac477"],"id":67}

响应:

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
{
"jsonrpc": "2.0",
"id": 67,
"result": {
"leader_reelect": false,
"validators": [
{
"account": "MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb",
"online": true,
"position": 8192
},
{
"account": "MAN.23983gYFh8YH1ovpzKa3wpcNaRVn7",
"online": true,
"position": 8193
},
… //省略
{
"account": "MAN.2JJ1KuzNDAgfRRby6hfM7V256V1mD",
"online": true,
"position": 8210
}
],
"backup_validators": [
{
"account": "MAN.31uRb2uAFrGvAoJwurJaZrNwpw6vn",
"online": true,
"position": 12288
},
…//省略
{
"account": "MAN.3ygAdEiWqv9U8pdQxw6T5C8DGqYqF",
"online": true,
"position": 12291
},
{
"account": "MAN.kaXBV56J1MayJzrcTQdm4LaGKA6a",
"online": true,
"position": 12292
}
],
"miners": [
{
"account": "MAN.253ZT6RZWK28o78gqAn2HkS73mcdN",
"online": true,
"position": 0
},
{
"account": "MAN.3pFY9DFmU3MWTFQeQRiCzs9bzKyqm",
"online": true,
"position": 1
},
…//省略
{
"account": "MAN.NcLaq3ZuHvuahrBn1tBNzGz55giv",
"online": true,
"position": 31
}
],
"elect_validators": null,
"elect_backup_validators": [
{
"account": "MAN.2mHv8WkPczgZaoruUx9nn8b7dQaev",
"online": false,
"position": 61440
}
]
}
}

man_getBlackList

返回交易黑名单账户,该账户无法进行转账交易。

参数

返回值

OBJECT:字符串数组-加入黑名单的交易账户地址

示例

请求:

1
curl -X POST --data {"jsonrpc":"2.0","method":"man_getBlackList ","params":[],"id":67}

响应:

1
2
3
4
5
{  
"jsonrpc": "2.0",
"id": 67,
"result": {"MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb"," MAN.Tfr4DZYNeWqqTth87phrg2KZcqya"
}

备注:非共识数据,节点数据,链上无法验证。

man_blockNumber

返回最新块的编号。

参数

返回值

QUANTITY - 节点当前块编号

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_blockNumber","params":[],"id":83}'

响应:

1
2
3
4
5
{
"id":83,
"jsonrpc": "2.0",
"result": "0x4b7" // 1207
}

man_estimateGas

执行并估算一个交易需要的gas用量。该次交易不会写入区块链。注意,由于多种原因,例如EVM的机制 及节点旳性能,估算的数值可能比实际用量大的多。

参数

Object - 交易调用对象。

  • 参考man_call调用的参数,所有的属性都是可选的。如果没有指定gas用量上限,gman将使用挂起块的gas上限。 在这种情况下,返回的gas估算量可能不足以执行实际的交易。
返回值

QUANTITY - gas用量估算值

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_estimateGas","params":[{see above}],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0x5208" // 21000
}

man_getBalance

返回指定地址账户的余额。

参数
  • STRING - 要检查余额的地址
  • QUANTITY|TAG - 整数块编号,或者字符串”latest”, “earliest”
1
2
3
4
params: [
'MAN.21LDRQtTVBdv3EcktxrVQebpQmLEA',
'latest'
]
返回值

OBJECT – 对应账户币种余额对象数组,结构如下:

  • accountType:QUANTITY –整形,币种编号。0,表示主币种,MAN

  • balance:QUANTITY –整形,余额,单位:zhu

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getBalance","params":["  MAN.21LDRQtTVBdv3EcktxrVQebpQmLEA ", "latest"],"id":1}'

响应:

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
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"accountType": 0,
"balance": "0xaf572216ba03ec528459"
},
{
"accountType": 1,
"balance": "0x0"
},
{
"accountType": 2,
"balance": "0x0"
},
{
"accountType": 3,
"balance": "0x0"
},
{
"accountType": 4,
"balance": "0x0"
}
]
}

man_getSelfLevel

返回当前节点在网络中的身份.

参数

返回值

QUANTITY –身份标志。0:错误;1~4桶序号;5顶层节点;6普通节点

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getSelfLevel","params":[],"id":71}'

响应:

1
2
3
4
5
{
"id":71,
"jsonrpc": "2.0",
"result": "6" //普通节点
}

man_getCode

返回指定地址的代码。

参数
  • STRING - 字符串,MAN地址
  • STRING - 字符串,币种名称
  • QUANTITY|TAG - 整数块编号,或字符串”latest”、”earliest”
1
2
3
4
5
params: [
'MAN.3MouXqgBjKoaEhEn2y11qDqUwpZGi',
'MAN', //MAN币
'0x2' // 2
]
返回值

DATA - 指定地址处的代码

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getCode","params":["MAN.3MouXqgBjKoaEhEn2y11qDqUwpZGi","MAN", "0x2"],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}

man_getGasPrice

返回当前的gas价格, 单位: zhu。

参数

返回值

QUANTITY – 整型,当前gas价格,单位:zhu

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_gasPrice","params":[],"id":73}'

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 73,
"result": "0x430e23400" //18000000000
}

man_getUpTime

返回指定账户从最新抵押开始到指定区块的在线时长。通过块高指定区块。

参数
  • STRING – 账户地址
  • QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”
1
2
3
4
params:  [
‘MAN.4Kq1ciivykmrCFzz5YjLgamcNdU76’,
‘0xac441’ // 705601
]
返回值

QUANTITY – 整型值在线时长,按照块高计数。

示例

请求:

1
curl -X POST --data '  {"jsonrpc":"2.0","method":"man_getUpTime","params":["MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb", "latest"],"id":67} '

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 67,
"result": "0x85edb"
}

man_getTransactionByBlockNumberAndIndex

返回指定块内具有指定索引序号的交易。通过高度指定区块。

参数
  • QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”
  • QUANTITY - 交易在块内的索引序号
1
2
3
4
params: [
'latest',
'0x0' // 0
]
返回值

查阅man_getTransactionByHash的返回值

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getTransactionByBlockHashAndIndex","params":["latest", "0x0"],"id":1}'

响应:

请参考man_getTransactionByHash的返回值。

man_getTransactionByBlockHashAndIndex

返回指定块内具有指定索引序号的交易。

参数
  • DATA, 32字节 - 块哈希
  • QUANTITY - 交易在块内的索引序号
1
2
3
4
params: [
'0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
'0x0' // 0
]
返回值

查阅man_getTransactionByHash的返回值

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getTransactionByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],"id":1}'

响应:

返回值请参考man_getTransactionByHash的返回值。

man_getTransactionByHash

返回具有指定哈希值的交易。

参数

DATA, 32 字节– 交易哈希值

1
2
3
params:  [
"0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4"
]
返回值

Object – 交易对象。如果没有找到匹配的交易,则返回null。结构如下:

  • hash: DATA, 32字节 – 交易哈希

  • nonce: QUANTITY – 发送方在此交易之前发生的交易数

  • blockHash: DATA, 32 字节– 包含交易的块的哈希值。挂起状态区块返回null

  • blockNumber: QUANTITY – 包含交易的块的块号。挂起状态区块返回null

  • transactionIndex: QUANTITY – 交易索引。挂起状态区块返回null

  • from: String, - 交易发送方地址

  • to: String, - 交易接收方地址

  • value: QUANTITY – 发送MAN币数量,单位:zhu

  • gasPrice: QUANTITY – 发送方支付的gas费,单位:zhu

  • gas: QUANTITY – 发送方可用gas总量

  • input: DATA – 随交易发送的数据

  • v: QUANTITY - ECDSA 恢复 id

  • r: DATA, 32 字节 - ECDSA 签名 r

  • s: DATA, 32 字节 - ECDSA 签名 s

  • TxEnterType:交易池类型(正常的交易设置为0)

  • matrixType:交易类型(正常的交易设置为0)

  • IsEntrustTx :

    • 0:自己 支付gas费

    • 1:他人代付gas费

  • CommitTime: 提交时间,仅对定时交易和可撤销的交易可用

  • Currency: 币种

  • ExtraTo: 扩展交易(应该填写一个到多个交易)

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getTransactionByHash","params":["0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4"],"id":1}'

响应:

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
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0xcbab7bd316a0a3be43d614f4d9beac8a7d8769c21e5a72dd3ee2edf3abab0a58",
"blockNumber": "0x52e8d",
"from": "MAN.4TZg4pDv6pVvAC8JDeKSCsYvH4g2Y",
"gas": "0x33450",
"gasPrice": "0x430e23400",
"hash": "0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4",
"input": "0x",
"nonce": "0x10000000000000",
"to": "MAN.pTopMhASaNr9WaKSRnj7p4WuEtE4",
"transactionIndex": "0x3",
"value": "0x21e27c1806e59a40000",
"v": "0x25",
"r": "0x1dc72ba66c23a3994b4fa9d7c55db71909bcb1452a459a6c337807990792f5ab",
"s": "0x29daa105765b7363de8b9bf553f0e94382a70efb10b104f9f8e5c48b264b2bba",
"TxEnterType": 0,
"IsEntrustTx": false,
"Currency": "MAN",
"CommitTime": "0x5ce45b01",
"matrixType": 0,
"extra_to": null
}
}

man_getBlockTransactionCountByHash

返回指定块内的交易数量,使用哈希来指定块。

参数

DATA - 32字节,块哈希

1
2
3
params: [
'0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]
返回值

QUANTITY - 指定块内的交易数量,整数

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getBlockTransactionCountByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0xb" // 11
}

man_sendRawTransaction

发起交易或合约来签署交易。

参数

Object – 结构如下:

  • from: String – 指定发送方的地址。如果没有指定,则使用man.defaultAccount

  • to: String – 交易的目标地址。如果是由合约创建的,则为空

  • value: Number|String|BigNumber - 交易中携带的货币数量,以zhu为单位。如果交易是通过合约创建的,则为初始资金

  • gas: Number|String|BigNumber - 交易使用的gas量;未使用的gas将被退还

  • gasPrice: Number|String|BigNumber – 交易的gas费

  • data: String – (可选)包含相关数据的字节字符串。如果是通过合约创建的,则它是用于初始化的代码。

  • nonce: Number - 整型,使用此值可以使用相同的nonce覆盖您自己的挂起交易。

  • V:签名结果

  • R:签名结果

  • S:签名结果

  • Currency: 币种

  • TxType:交易类型(正常交易设置为0)

  • LockHeight: 预留字段

  • IsEntrustTx :

    • 0:自己 支付gas费

    • 1:带人代付gas费

  • CommitTime: 提交时间,仅对定时交易和可撤销的交易可用

  • ExtraTo: 扩展交易(应该填写一个到多个交易)

  • TxEnterType:交易池类型(正常的交易设置为0)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
params: [{
"to": "MAN.3RuQmefCBZes1NX2h6pxRrYVQyTd6",
"value": "0x0de0b6b3a7640000",
"gas": "0x033450",
"gasPrice": "0x0430e23400",
"data": "0x",
"nonce": "0x10000000000004",
"r": "0x9125ae7fc89139883c88f8e1ebb02f4bc274f980208bc2aa8687cafd597e003b",
"s": "0x308789e24be11df0332aa1c3e29ef97218073ddfc7f9398ef3abd5a310bcc42f",
"v": "0x26",
"currency": "MAN",
"txType": 0,
"lockHeight": 0,
"isEntrustTx": 0,
"commitTime": 1558506847,
"extra_to": [],
"txEnterType": 0
}]
返回值

DATA – 32 字节,交易哈希. 如果交易无效,则返回null。

创建合约时,可使用man_getTransactionReceipt获取合约地址。

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_sendRawTransaction","params":[{"to":"MAN.3RuQmefCBZes1NX2h6pxRrYVQyTd6","value":"0x0de0b6b3a7640000","gas":"0x033450","gasPrice":"0x0430e23400","data":"0x","nonce":"0x10000000000004","r":"0x9125ae7fc89139883c88f8e1ebb02f4bc274f980208bc2aa8687cafd597e003b","s":"0x308789e24be11df0332aa1c3e29ef97218073ddfc7f9398ef3abd5a310bcc42f","v":"0x26","currency":"MAN","txType":0,"lockHeight":0,"isEntrustTx":0,"commitTime":1558506847,"extra_to":[],"txEnterType":0}],"id":1}'

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xb1234994c858b02f0d50e8986d577aec1c0cd67a40262346c7a7cb43bbd5ea7c"
}

man_getTransactionCount

返回从指定地址发送的交易数。

参数
  • DATA – address

  • QUANTITY|TAG –整数块编号,或字符串”earliest”、”latest”

1
2
3
4
params:  [
' MAN.499Pb2d1yiYrDpynfyTekLnSWDVvX',
'latest' // state at the latest block
]
返回值

QUANTITY – 从指定地址(整数)发送的交易数。起始编号是0x10000000000000。

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getTransactionCount","params":[" MAN.499Pb2d1yiYrDpynfyTekLnSWDVvX","latest"],"id":1}'

响应:

1
2
3
4
5
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x10000000000000"
}

man_getTransactionReceipt

返回指定交易的收据。使用哈希指定交易。

请注意,挂起交易的收据无效。

参数

DATA, 32 字节– 交易哈希

1
2
3
params:  [
'0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4'
]
返回值

Object – 交易接收对象。如果收据不存在,则返回null。交易选项的结构如下:

  • transactionHash: DATA, 32 字节 – 交易哈希
  • transactionIndex: QUANTITY – 交易索引
  • Currency:STRING-币种名称
  • blockHash: DATA, 32 bytes – 交易区块的哈希
  • blockNumber: QUANTITY – 交易区块号
  • from: String, 交易发送方地址
  • to: String, 交易接收方地址
  • cumulativeGasUsed: QUANTITY – 区块在交易过程中消耗的总gas量
  • gasUsed: QUANTITY – 在交易中消耗的gas量
  • contractAddress: String – 在新合约创建交易中,此值是新创建的合约地址。否则,返回null
  • logs: Array – 此交易生成的日志对象数组
  • logsBloom: DATA, 256 字节– bloom filter,轻量级客户端用于快速提取相关日志
  • status: QUANTITY, 1 (成功) or 0 (失败)
示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getTransactionReceipt","params":["0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4"],"id":1}'

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"Currency": "MAN",
"blockHash": "0xcbab7bd316a0a3be43d614f4d9beac8a7d8769c21e5a72dd3ee2edf3abab0a58",
"blockNumber": "0x52e8d",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
"from": "MAN.4TZg4pDv6pVvAC8JDeKSCsYvH4g2Y",
"gasUsed": "0x5208",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "MAN.pTopMhASaNr9WaKSRnj7p4WuEtE4",
"transactionHash": "0x069a568bd06988107b78266fbf66ff9cbdd0fedf35226056e01bbbdaa096fad4",
"transactionIndex": "0x3"
}
}

man_sendTransaction

发起一个交易。如果数据字段包含代码,则创建一个合约。

参数

Object – 交易对象。结构如下:

  • from: String –指定发送方的地址。如果没有指定,则使用man.defaultAccount
  • to: String – 交易的目标地址。如果是由合约创建的,则为空
  • 注:如果是发布合约的交易,则为空
  • value: Number|String|BigNumber - 交易中携带的货币数量,以zhu为单位。如果交易是通过合约创建的,则为初始资金
  • gas: Number|String|BigNumber - 交易使用的gas量;未使用的gas将被退还
  • gasPrice: Number|String|BigNumber – 交易的gas费
  • data: String – (可选)包含相关数据的字节字符串。如果是通过合约创建的,则它是用于初始化的代码
  • nonce: Number - 整型,使用此值可以使用相同的nonce覆盖您自己的挂起交易
  • Currency: 币种
  • ExtraTo: 扩展交易(应该填写一个到多个交易)
1
2
3
4
5
6
7
8
9
params: [{
"from": "MAN.499Pb2d1yiYrDpynfyTekLnSWDVvX",
"to": "MAN.3KfF5p9bmPFmS4RYPVVrYociDXm5q",
"currency":"MAN",
"gas": "0x76c0", // 30400
"gasPrice": "0x9184e72a000", // 10000000000000
"value": "0x9184e72a", // 2441406250
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]
返回值

DATA, 32 字节 – 交易哈希. 如果交易无效,则返回0。

创建合约时,可使用man_getTransactionReceipt获取合约地址。

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_sendTransaction","params":[{see above}],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

man_sign

使用如下公式计算Matrix签名:sign(keccak256("\x19Matrix
Signed Message:\n" + len(message) + message)))

通过给消息添加一个前缀,可以让结果签名被识别为Matrix签名。这可以组织恶意DApp签名任意数据(例如交易)并使用 签名冒充受害者。

需要指出的是,进行签名的地址必须是解锁的。

参数

账户、消息

  • STRING - MAN地址
  • DATA - 要签名的消息
返回值

DATA: 签名

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_sign","params":["MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo", "0xdeadbeaf"],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
}

man_getBlockTransactionCountByNumber

返回指定块内的交易数量,使用块编号指定块。

参数

QUANTITY|TAG - 整数块编号,或字符串”earliest”、”latest”

1
2
3
params:  [
'0xe8', // 232
]
返回值

QUANTITY - 指定块内的交易数量

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getBlockTransactionCountByNumber","params":["0xe8"],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0xa" // 10
}

man_accounts

返回客户端持有的地址字符串列表。

参数

返回值

客户端持有的地址字符串列表。

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_accounts","params":[],"id":1}'

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"jsonrpc": "2.0",
"id": 1,
"result": [
[
"MAN.37FK8J1LXLXHmZV1HxSmkbjKBKYyX",
"MBN.37FK8J1LXLXHmZV1HxSmkbjKBKYy8",
"MCN.37FK8J1LXLXHmZV1HxSmkbjKBKYyF",
"MDN.37FK8J1LXLXHmZV1HxSmkbjKBKYyK",
"MEN.37FK8J1LXLXHmZV1HxSmkbjKBKYy4",
"MIN.37FK8J1LXLXHmZV1HxSmkbjKBKYyz",
"MSN.37FK8J1LXLXHmZV1HxSmkbjKBKYy7",
"MUSD.37FK8J1LXLXHmZV1HxSmkbjKBKYyd"
]
]
}

man_newBlockFilter

在节点中创建一个过滤器,以便当新块生成时进行通知。要检查状态是否变化, 请调用man_getFilterChanges

参数

返回值

QUANTITY - 过滤器编号

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_newBlockFilter","params":[],"id":73}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0x1" // 1
}

man_uninstallFilter

写在具有指定编号的过滤器。当不再需要监听时,总是需要执行该调用。另外,过滤器 如果在一定时间内未接收到man_getFilterChanges调用会自动超时。

参数

QUANTITY - 过滤器编号

1
2
3
params:  [
"0xb" // 11
]
返回值

Boolean - 如果成功卸载则返回true,否则返回false

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_uninstallFilter","params":["0xb"],"id":73}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": true
}

man_newPendingTransactionFilter

在节点中创建一个过滤器,以便当产生挂起交易时进行通知。 要检查状态是否发生变化,请调用man_getFilterChanges

参数

返回值

QUANTITY - 过滤器编号

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_newPendingTransactionFilter","params":[],"id":1}'

响应:

1
2
3
4
5
{
"id":1,
"jsonrpc": "2.0",
"result": "0x36c51b60b6ec98165c2f00c4958c44a8" // 1
}

man_getEntrustList

根据指定授权账户所有最新区块的委托信息。

参数

STRING- 授权账户地址。

1
2
3
params:  [
'MAN.21LDRQtTVBdv3EcktxrVQebpQmLEA ' // 232
]
返回值

OBJECT-委托账户信息列表。委托账户信息结构如下:

  • EntrustAddres : STRING-委托账户地址

  • IsEntrustGas:BOOLEAN-是否委托GAS代付。True表示是委托Gas代付。

  • IsEntrustSign:BOOLEAN-是否委托签名。True表示是委托签名。

  • EnstrustSetType :DATA, 1byte- 0:按高度委托,1:按时间委托,2:按次数委托

  • StartHeight :QUANTITY - 整数块编号,委托的起始高度

  • EndHeight:QUANTITY - 整数块编号,委托的结束高度

  • StartTime:QUANTITY – UTC时间,委托的起始时间

  • EndTime:QUANTITY – UTC时间,委托的结束时间

  • EntrustCount:QUANTITY–委托次数

示例

请求:

1
curl -X POST --data '{"jsonrpc":"2.0","method":"man_getEntrustList","params":["MAN.21LDRQtTVBdv3EcktxrVQebpQmLEA"],"id":1}'

响应:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"id":1,
"jsonrpc": "2.0",
"result": [
{
"EntrustAddres": "MAN.CUVXBNBpqXipn5JtDsnWKz3e59to",
"IsEntrustGas":false,
"IsEntrustSign":false,
"EnstrustSetType":2,
"StartHeight":0,
"EndHeight":0,
"StartTime":0,
"EndTime":0,
"EntrustCount": 5
}
]
}