钱包 API
获取签名所需数据

获取签名所需数据#

该接口提供各个链,签名交易时所需数据。 例如 EVM 网络所需的网络费用、nonce 。UTXO 模型网络需要的费率,输出大小等最参数。

请求路径#

POST https://www.okx.com/api/v5/wallet/pre-transaction/sign-info

请求参数#

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

extJson

ParameterTypeRequiredDescription
inputDataStringNocalldata
protocolStringNo查询指定的协议:
1: BRC-20
2: ARC-20
3: Runes
4: ordi_nft
5: SRC-20

响应参数#

EVM#

ParameterTypeDescription
gasLimtStringgas 消耗数量
nonceString当前数,只返回上链 nonce。比如当前地址链上已成功的最大 nonce 为 10,则请求的结果为 11。如需内存池的 nonce 请查看获取 nonce
gasPriceObjectgas 消耗单价
>normalString中档 gasPrice,单位为 wei
>minString低档 gasPrice,单位为 wei
>maxString高档 gasPrice,单位为 wei
>supportEip1559Boolean是否支持 1559
>eip1559ProtocolObject1559 协议

eip1559 Protocol

ParameterTypeDescription
eip1559ProtocolObject1559 协议
>baseFeeString基础费用
>proposePriorityFeeString中档小费,单位为 wei
>safePriorityFeeString低档小费,单位为 wei
>fastPriorityFeeString高档小费,单位为 wei

UTXO#

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

请求示例#

shell
curl --location --request POST 'https://www.okx.com/api/v5/wallet/pre-transaction/sign-info' \
--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 '{
        "chainIndex": "0",
        "fromAddr": "bc1pyyn077ps82t7t0zjs0rlueg5876sdrqk79esr5e2w44g5f59dsmsl6m02d",
        "toAddr": "bc1pyyn077ps82t7t0zjs0rlueg5876sdrqk79esr5e2w44g5f59dsmsl6m02d",
        "txAmount": "0",
        "extJson": {
            "protocol": "1"
        }
    }

响应示例#

200
{
  "code": "0",
  "data": [
    {
      // EVM
      "gasLimit": "21000",
      "nonce": "15",
      "gasPrice": {
        "normal": "21289500000", //中档gasPrice
        "min": "15670000000", //低档gasPrice
        "max": "29149000000", //高档gasPrice
        "supportEip1559": true, //是否支持1559
        "eip1599Protocol": {
          "suggestBaseFee": "15170000000", //建议基础费用
          "baseFee": "15170000000", //基础费用
          "proposePriorityFee": "810000000", //中档小费
          "safePriorityFee": "500000000", //低档小费
          "fastPriorityFee": "3360000000" //高档小费
        }
      }
    },
    {
      // utxo/ BRC-20
      "normalFeeRate": "27",
      "maxFeeRate": "35",
      "minFeeRate": "22",
      "inscriptionOutput": "546",
      "minOutput": "1500",
      "normalCost": "1800",
      "maxCost": "3600",
      "minCost": "600"
    }
  ],
  "msg": ""
}