预估交易成本
POST/transaction/estimate
提交调用的函数和参数来预估调用智能合约的手续费,返回的是包含网络费和交易哈希等的交易信息,不会真正发起交易。
信息
该接口被签名工具使用,商户一般不需要调用。
Request
- application/json
Body
chainId int32required
链 ID
此为平台内部 ID,不是链上或者钱包里的链 ID,可以从查询链列表接口获取
address stringrequired
owner地址
合约调用者的钱包地址
contractAddress stringrequired
交易调用的合约地址
encodedFunction stringrequired
Possible values: Value must match regular expression ^0x[a-fA-F0-9]*$
经过编码的合约函数调用数据
functionSelector stringrequired
Possible values: Value must match regular expression ^[a-zA-Z0-9_]+\([a-zA-Z0-9,]*\)$
合约函数声明
格式:函数名(参数类型)
Responses
- 200
- 401
- 403
- 404
OK
- application/json
- Schema
- Example (from schema)
- Example
Schema
- 对于以太链,交易预计消耗的原生代币数量为 (gasLimit * gasPrice) / 10^18 ETH。
- 对于波场,交易预计消耗的原生代币数量为 gasLimit / 10^6 TRX。
- 如果调用者钱包地址中的原生代币余额不足,合约函数执行将会失败,并且已消耗的网络费不会返还。
code int32required
状态码
msg stringrequired
成功或错误提示
description string
错误提示详情
data
object
required
chainId stringrequired
Possible values: Value must match regular expression ^0x[a-fA-F0-9]+$
真实的链 ID
区块链对外声明的链 ID,格式为十六进制字符串
contractAddress stringrequired
交易调用的合约地址
gasLimit int64required
区块链执行此交易预估需要消耗的网络费
该值仅为预测值,与最终消耗的网络费不保证一致
gasPrice int64required
网络费当前的单位价格
nonce int64
交易顺序
仅发生于以太链的交易会返回此字段
hexTransaction string
交易数据的十六进制表示
仅发生于波场的交易会返回此字段
txHash string
交易哈希
仅发生于波场的交易会返回此字段
此交易哈希为预测值,作签名使用,不表示已在区块链上发布
{
"code": 0,
"msg": "string",
"description": "string",
"data": {
"chainId": "string",
"contractAddress": "string",
"gasLimit": 0,
"gasPrice": 0,
"nonce": 0,
"hexTransaction": "string",
"txHash": "string"
}
}
{
"code": 200,
"msg": "success",
"data": {
"gasPrice": 420,
"gasLimit": 7809984,
"txHash": "0xca9f2e41f0f59f83e237c8ad2b95c73ade7da07f659034026b64522be22a905b",
"hexTransaction": "0x0af5020a029e9f220801d2113c177d62ed40e8989fdbe5315ad002081f12cb020a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e74726163741295020a1541e33ccff0de3ce13636f66a507f6e3cdf7a963562121541fdb2c4d5364d061fcf941af600a45564d2d2033022e4018d80ff0a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000098ea51342dabbb928ae1e576bd39eff8aaf070a8c600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000005f11063c669a79ec55d2008de2f754fd4a37ce0000000000000000000000000000000000000000000000000000000000989680000000000000000070fac59bdbe5319001c0d7dc032a00",
"chainId": "0xcd8690dc",
"contractAddress": "TZ6e7fuFHX1E7uhpAFcCHmSzBfaBtb6spS"
}
}
Unauthorized
Forbidden
Not Found
Loading...