签名所需数据#
该接口提供各个链,签名交易时所需数据。 例如 EVM 网络所需的网络费用、nonce 。UTXO 模型网络需要的费率,输出大小等最参数。
请求路径#
POST https://web3.okx.com/api/v5/wallet/pre-transaction/sign-info
请求参数#
| Parameter | Type | Required | Description | 
|---|---|---|---|
| chainIndex | String | Yes | 链唯一标识 | 
| fromAddr | String | Yes | From 地址 | 
| toAddr | String | Yes | To 地址 | 
| txAmount | String | No | 交易的主链币金额,默认为 0。涉及主链币转账的时候必须要携带此参数,否则将会影响 gaslimit 的计算。以主链币的最小单位传参,例如 ETH wei。 | 
| extJson | Object | Yes | 扩展参数,用于添加 calldata 等信息 | 
extJson
| Parameter | Type | Required | Description | 
|---|---|---|---|
| inputData | String | No | calldata | 
| protocol | String | No | 查询指定的协议: 1: BRC-20 2: ARC-20 3: Runes 4: ordi_nft 5: SRC-20 | 
| tokenAddress | String | No | 只适用于 Solana 链 | 
| permissionType | String | No | 只适用于 Tron 链。1:对地址有 owner 管理控制权限 2:对地址有 witness 副监管权限 默认为"1"  | 
| feeLimit | String | No | 只适用于 Tron 链。合约交互必填,默认为 "30000000" | 
响应参数#
EVM#
| Parameter | Type | Description | 
|---|---|---|
| gasLimt | String | gas 消耗数量 | 
| nonce | String | 当前数,只返回上链 nonce。比如当前地址链上已成功的最大 nonce 为 10,则请求的结果为 11。如需内存池的 nonce 请查看获取 nonce | 
| gasPrice | Object | gas 消耗单价 | 
| >normal | String | 中档 gasPrice,单位为 wei | 
| >min | String | 低档 gasPrice,单位为 wei | 
| >max | String | 高档 gasPrice,单位为 wei | 
| >supportEip1559 | Boolean | 是否支持 1559 | 
| >eip1559Protocol | Object | 1559 协议 | 
eip1559 Protocol
| Parameter | Type | Description | 
|---|---|---|
| eip1559Protocol | Object | 1559 协议 | 
| >baseFee | String | 基础费用 | 
| >proposePriorityFee | String | 中档小费,单位为 wei | 
| >safePriorityFee | String | 低档小费,单位为 wei | 
| >fastPriorityFee | String | 高档小费,单位为 wei | 
UTXO#
| Parameter | Type | Description | 
|---|---|---|
| normalFeeRate | String | 中档位费率 | 
| maxFeeRate | String | 高档位费率 | 
| minFeeRate | Object | 低档位费率 | 
| inscriptionOutput | String | 铭文输出大小。若 protocol 为空,默认为 BRC20 的铭文输出大小 | 
| minOutput | String | 铭文最小输出大小,单位为聪(通常为 546 聪) | 
| normalCost | String | 单笔铭刻交易的消耗,单位为聪 | 
| maxCost | String | 单笔铭刻交易的最大消耗,单位为聪 | 
| minCost | String | 单笔铭刻交易的最小消耗,单位为聪 | 
Solana#
| Parameter | Type | Description | 
|---|---|---|
| baseFee | String | 基础费用 | 
| priorityFee | String | 优先费 | 
| >normalUnitPrice | Object | 中档gasPrice | 
| >minUnitPrice | String | 低档gasPrice | 
| >maxUnitPrice | String | 高档gasPrice | 
| recentBlockHash | String | 最近的区块哈希 | 
| lastValidBlockHeight | String | 上一区块高度 | 
| fromAddressRent | String | 发送地址租金 | 
| toAddressRent | String | 目的地址租金 | 
| tokenAccountInfo | String | from 地址的代币账户信息。代币转账时存在 | 
| >lamports | String | 余额 | 
| >ownerAddress | String | form 地址 | 
| >mintAddress | String | 代币地址 | 
| >tokenAccountAddress | String | 代币账户地址 | 
| >decimal | String | 精度 | 
Tron#
| Parameter | Type | Description | 
|---|---|---|
| fee | String | 手续费 | 
| refBlockBytes | String | 交易引用块的高度,使用了引用块高度的第6到8(不包含)字节,用于帮助验证交易是否基于当前区块链的有效状态,防止分叉交易重放 | 
| refBlockHash | Object | 交易引用块的hash,使用了引用块hash的第8到16(不包含)字节。如果交易的ref_block_hash与实际存在的区块哈希不匹配,那么这笔交易可能会被拒绝或标记为无效 | 
| expiration | String | 过期时间 | 
| timestamp | String | 时间戳 | 
请求示例#
shell
curl --location --request POST 'https://web3.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
// EVM
{
  "code": "0",
  "data": [
    {
      "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" //高档小费
        }
      }
    }
  ],
  "msg": ""
}
// UTXO/ BRC-20
{
  "code": "0",
  "data": [
    {
      "normalFeeRate": "27",
      "maxFeeRate": "35",
      "minFeeRate": "22",
      "inscriptionOutput": "546",
      "minOutput": "1500",
      "normalCost": "1800",
      "maxCost": "3600",
      "minCost": "600"
    }
  ]
}
//Solana
{
    "code": "0",
    "msg": "success",
    "data": [
        {
          
            "baseFee": "5000",
            "priorityFee": {
                "normalUnitPrice": "4325963",
                "minUnitPrice": "4325963",
                "maxUnitPrice": "4325963"
            },
            "recentBlockHash": "C7Qq7cLjBQSU2eTS7458DDe1HvmBubLv9wi4NMH9GGtc",
            "lastValidBlockHeight": "280957599",
            "fromAddressRent": "890880",
            "toAddressRent": "0",
            "tokenAccountInfo": {
                "lamports": "2039280",
                "ownerAddress": "HnRfqMVCpYAvTVRZJJtrR5j2Kx8qvz4HvE3eL4hUgheV",
                "mintAddress": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
                "tokenAccountAddress": "CFYZjn1dVWzbwDq7zuXtwa2NystiqA4QALKqMoA98TB6",
                "decimal": "6"
            }
        }
    ]
}
// TRON
{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "fee": "3150000",
            "refBlockBytes": "8cfe",
            "refBlockHash": "dc8399fedb8cf542",
            "expiration": "1732088289000",
            "timestamp": "1732084764202"
        }
    ]
}
