cfx 命名空间
JSON-RPC Spec
There is a JSON-RPC API spec of cfx namespace on GitHub. You can view it in open-rpc playground
CONVENTIONS
十六进制值编码
Two key data types get passed over JSON: unformatted byte arrays and quantities. Both are passed with a hex encoding but with different requirements for formatting.
Quantities
When encoding QUANTITIES (integers, numbers): encode as hex using the most compact representation and prefix with "0x". Zero should be represented as "0x0". 例如:
0x41(65 in decimal)0x400(1024 in decimal)- WRONG:
0x(should always have at least one digit - zero is"0x0") - WRONG:
0x0400(no leading zeroes allowed) - WRONG:
ff(missing0xprefix)
未格式化的数据
当编码未格式化的数据(字节数组、哈希值、字节码数组)时:使用两个十六进制数字表示每个字节,并在前面加上“0x”作为前缀。 例如:
0x41(size 1,"A")0x004200(size 3,"\0B\0")0x(size 0,"")- WRONG:
0xf0f0f(must be even number of digits) - WRONG:
004200(missing0xprefix)
请注意,区块和交易的哈希值是用32个字节来表示的。
Base32 Address
BASE32:Base32 地址应该编码为一个ASCII字符串,包含42个字符加上网络前缀、分隔符和可选字段。 请注意以下关于base32地址作为RPC参数的限制条件:
- 网络前缀应该与节点的网络匹配,例如:
cfx:acc7uawf5ubtnmezvhu9dhc6sghea0403y2dgpyfjp可以发送给主网节点,cfxtest:acc7uawf5ubtnmezvhu9dhc6sghea0403ywjz6wtpg可以发送给测试网节点。 值得注意的是,这两个示例地址对应于不同网络上的同一个账户。 - 无论包含还是省去地址类型都是可以接受的,例如:
cfx:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg和cfx:type.user:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg是等价的。 但是,类型不正确的地址,例如:cfx:type.contract:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg,会被拒绝。 - 全大写或者全小写地址都是可以接受的,例如:
cfx:aarc9abycue0hhzgyrr53m6cxedgccrmmyybjgh4xg和CFX:AARC9ABYCUE0HHZGYRR53M6CXEDGCCRMMYYBJGH4XG都是有效的。 但混合大小写地址会被拒绝。
Refer to Addresses for more knowledge about Base32 addresses.