钱包 API
获取签名所需数据

获取签名所需数据#

该接口提供签名时所需的网络费用和 nonce 等参数。

查询 nonce,只返回上链数据。比如 当前地址链上已成功的交易最大 nonce 为 10,则请求的结果为 11。

广播了 nonce 为11的交易以后,当该交易没有上链还在 pending 的状态时,再次请求的结果也是11。请自行维护 nonce,或等交易上链后再进行下一笔交易的广播。

请求路径#

GET https://www.okx.com/api/waas/wallet/pre-transaction/sign-info

请求参数#

ParameterTypeRequiredDescription
chainIndexStringYes链唯一标识
fromAddrStringYesFrom地址
toAddrStringYesTo地址
txAmountStringNo交易的主链币金额,默认为 0。涉及主网币转账的时候必须要携带此参数,否则将会影响 gaslimit 的计算。
extJsonObjectYes扩展参数,用于添加 calldata 等信息

extJson

ParameterTypeRequiredDescription
inputDataStringNocalldata

响应参数#

EVM#

ParameterTypeDescription
gasLimtStringgas 消耗数量
nonceString当前数,只返回上链数据。比如 当前地址链上已成功的交易最大 nonce 为 10,则请求的结果为 11。
广播了 nonce 为 11 的交易以后,当该交易没有上链还在 pending 的状态时,再次请求的结果也是 11。请自行维护 nonce,或等交易上链后再进行下一笔交易的广播。
gasPriceObjectgas 消耗单价
>normalString中档 gasPrice,单位为 wei
>minString低档 gasPrice,单位为 wei
>maxString高档 gasPrice,单位为 wei
>supporteip1559Boolean是否支持 1559
>eip1559ProtocolObject1559 协议
eip1559 Protocol
ParameterTypeDescription
eip1559ProtocolObject1559 协议
>suggestBaseFeeString建议基础费用=基础费用*1.25,单位为 wei
>baseFeeString基础费用
>proposePriorityFeeString中档小费,单位为 wei
>safePriorityFeeString低档小费,单位为 wei
>fastPriorityFeeString高档小费,单位为 wei

BRC-20/UTXO#

ParameterTypeDescription
normalFeeRateString中档位费率
maxFeeRateString高档位费率
minFeeRateObject低档位费率
inscriptionOutputString铭文输出大小
minOutputString铭文最小输出大小,单位为聪(通常为 546 聪)
normalCostString单笔铭刻交易的消耗,单位为聪
maxCostString单笔铭刻交易的最大消耗,单位为聪
minCostString单笔铭刻交易的最小消耗,单位为聪

请求示例#

shell
curl --location --request POST 'https://www.okx.com/api/v5/waas/wallet/transaction/sign-info?chainIndex=1&fromAddr=oxsieeelxd&toAddr=ekljljlnbc&txAmount=1&extJson="xxx"' \
--header 'Content-Type: application/json' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z' \
--data-raw '{
    "accountId":"0x04ad62387d1f1c7034087bbe4d16163d06fae42d",
    "chainIndex": "1",
    "tokenAddress": "0xdf54b6c6195ea4d948d03bfd818d365cf175cfc2"
}'

响应示例#

200
// EVM
{
    "code": "0",
    "data": [
        { // EVM
            "gasLimit" : "21000", 
            "nonce" : "15",
            "gasPrice" : {
                "normal" : "21289500000", //中档gasPrice
                "min" : "15670000000", //低档gasPrice
                "max" : "29149000000", //高档gasPrice            
                "supportEip1559" : true, //是否支持1559
                "erc1599Protocol": {
                    "suggestBaseFee" : "15170000000", //建议基础费用
                    "baseFee" : "15170000000", //基础费用
                    "proposePriorityFee" : "810000000", //中档小费
                    "safePriorityFee" : "500000000", //低档小费
                    "fastPriorityFee" : "3360000000" //高档小费
                }
            }     
        }
    ],
    "msg": ""
}

// UTXO
{
    "code": "0",
    "data": [
        {
          "normalFeeRate": "27",
          "maxFeeRate": "35",
          "minFeeRate": "22",
          "inscriptionOutput": "546",
          "minOutput": "1500",
          "normalCost": "1800",
          "maxCost": "3600",
          "minCost": "600"
        }
    ],
    "msg": ""
}