SwapBox V1 接口文档
请求与返回
RESTFUL访问格式:
添加请求头 Content-Type: application/json;charset=UTF-8
接口地址:
https://api.v2.nabox.io/nabox-api
返回格式:
//成功示例
{
"code": 1000, //返回码,1000表示成功,其余表示失败
"msg": "成功", //返回信息
"data": { //返回数据
"success":true
}
}
//错误示例
{
"code": 1002,
"msg": "语言类型错误",
"data": null
}
接口详情
Swap Transactions
查询链配置
详细描述: 查询SwapBox当前支持的各条链的Swap配置信息,所有应用应该首先调用此接口获取链配置(链信息和资产信息),并缓存在本地。
访问:
url
method
说明
/swap/info
get
查询Swap配置信息
参数: 无
返回:
{
"chain": "Ethereum", //链名称
"evmChainId": 1, //EVM的ID
"chainId": 101, //Nerve跨链系统给当前链分配的链ID
"chainType": 2, //链类型:1:Nerve链,2:EVM链
"configs": { //链的其他配置
"multiCallAddress": "0x6899aa135037a4c8a3cab11622d35cea4cd63747",
//批量查询合约地址
"crossAddress": "0xc707e0854da2d72c90a7453f8dc224dd937d7e82",
//跨链swap的中间账户
"nft": "eth" //是否支持NFT
},
"stableSwapAssetList": [ //稳定币sawp的token列表
{
"chain": "Ethereum", //资产所属链
"chainId": 101, //资产所属链对应Nerve跨链系统的链id
"assetId": 0, //Nerve链给资产分配的资产id,每条链的代币assetId=1,
"contractAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
//token的合约地址
"decimals": 6, //资产小数位
"symbol": "USDT",
"channelInfo": { //资产支持的swap渠道信息
"iSwap": { //iswap渠道信息
"code": [
"BIG", //大额兑换
"BRG", //大额跨链桥
"SWP" //普通兑换
],
"token": "USDT"
},
"NERVE": { //Nerve稳定币兑换渠道信息
"pairAddress": "NERVEepb7WDfEU4ZKsEFmwCfGwCaYWgdHgk5tW",
//稳定币交易对合约地址
"coinIndex": 0, //当前资产对应的下标
"lpChainId": 9, //lp资产在Nerve链上对应的链id
"lpAssetId": 220 //lp资产在Nerve链上对应的资产id
}
}
}
]
查询订单详情
详细描述:通过订单ID查询SwapBox发起的Swap交易详情。
访问:
url
method
说明
/swap/tx/orderId
post
查询swap交易详情
参数:
参数名
类型
必填
描述
language
string
Y
语言:EN/CHS
orderId
string
Y
交易的订单ID
返回:
{
"id": 232,
"orderId": "25172d2b-bdb9-4dd3-8698-b5e0fe34ad97", //订单ID
"channel": "NERVE", //兑换通道
"platform": "NABOX", //发起兑换平台
"swapType": 2, //兑换类型 1:普通兑换,2:稳定币兑换,3:大额兑换
"fromChain": "Heco", //发起链
"fromAddress": "0xf8a8435f7a93c73862974e19865b7089707813F1",//发起地址
"toChain": "BSC", //兑换目标链
"toAddress": "0xf8a8435f7a93c73862974e19865b7089707813F1", //目标地址
"chainId": 103, //发起链资产对应的Nerve分配链ID
"assetId": 0, //发起链资产的资产ID,代币该值为1,Token合约资产为0
"contractAddress": "0xa71edc38d189767582c38a3145b5873052c3e47a",
//发起链资产的token合约地址
"decimal": 18, //发起链资产小数位
"symbol": "USDT", //资产符号
"swapChainId": 102, //目标链资产对应的Nerve分配链ID
"swapAssetId": 0, //目标链资产的资产ID
"swapContractAddress": "0x55d398326f99059ff775485246999027b3197955",
//目标链资产的token合约地址
"swapDecimal": 18, //目标链资产小数位
"swapSymbol": "USDT" //资产符号
"txHash": "0x7ee9e904c0183ad248587ae20052ea99485762602b5077e88e3ebfe8c3d4e4f1",
//发起链的交易hash
"nerveTxHash": "243d52b1d354fb7dbfc17b918cb0cbfe1e0441d1702b48d11c03758f96005896",
//Nerve链上做兑换处理的交易hash
"crossTxHash": "0x72c0a9f93bd04df3f81fdfb59a8e7267e81c8df86c3d6b752b2034a5536be537",
//目标链地址接收到兑换币的交易hash
"amount": "8.898993", //发起链资产的数量
"swapSuccAmount": "8.897193", //目标链兑换成功的数量
"swapFee": "0.001800", //兑换收取的手续费(收取兑换资产)
"crossFee": "0.049300", //兑换的跨链手续费(收取发起链代币)
"slippage": 0, //滑点
"pairAddress": "NERVEepb7WDfEU4ZKsEFmwCfGwCaYWgdHgk5tW",
//Nerve链兑换的合约地址
"status": 3, //订单状态 0:订单已生成, 1:发起链交易已发送,
// 2:发起链交易已确认,3:兑换成功,4:兑换失败
"nerveStatus": 2, //Nerve链上的兑换状态 0:未兑换, 1:已兑换,2:已跨链转出
"createTime": "2022-03-02 21:04:04",
"updateTime": "2022-03-02 21:04:03",
"errorMsg": "" //兑换失败信息
}
查询订单列表
详细描述:通过发起地址查询订单列表, 返回最近的10条记录。
访问:
url
method
说明
/swap/tx/query
post
查询Swap交易列表
参数:
参数名
类型
必填
描述
language
string
Y
语言:EN/CHS
nativeId
int
Y
evmChainId
address
string
Y
用户地址
返回:
{
"code": 1000,
"msg": "success",
"data": [
{
"id": 103,
"orderId": "7f1426ad-36b4-4786-9b01-524d4bdff4ac",
"channel": "NERVE",
"platform": "SWFT",
"swapType": 2,
"fromChain": "BSC",
"fromAddress": "0x3083f7ed267dca41338de3401c4e054db2a1cd2f",
"toChain": "NERVE",
"toAddress": "TNVTdTSPVaHLGXQJDVCyNAo67zAoUcvbpeUri",
"chainId": 102,
"assetId": 0,
"contractAddress": "0xd0a347e0ebea8f8efc26d539e17853c8e7a721c4",
"decimal": 18,
"symbol": "USDT",
"swapChainId": 5,
"swapAssetId": 90,
"swapContractAddress": "",
"swapDecimal": 6,
"swapSymbol": "USDT",
"txHash": "0x4e94169c2dc457dbac3af5a7d90c80eb825abf29b0414da6d2a7f2d1d42a9efe",
"nerveTxHash": "0929249e710c203851a4f723a8d2774dc4d0fb9ecdcebbd058e6cbc82051372e",
"crossTxHash": "0x4c07ee6e235af2e4cbb95d6a459fe37e365c71de55563036c78d90fef856d675",
"amount": "100",
"swapSuccAmount": "99.9500",
"swapFee": "0.05",
"crossFee": "0.0001",
"slippage": 0,
"pairAddress": "TNVTdTSQoL9quSyGJCA9sY8pcMEVy4RN4EjbB",
"status": 3,
"nerveStatus": 2,
"createTime": "2022-03-09 14:18:12",
"updateTime": "2022-03-23 14:27:20",
"errorMsg": ""
},
{
"id": 102,
"orderId": "90c9784a-8ce9-4271-8c0b-037ac7fd918d",
"channel": "NERVE",
"platform": "SWFT",
"swapType": 2,
"fromChain": "BSC",
"fromAddress": "0x3083f7ed267dca41338de3401c4e054db2a1cd2f",
"toChain": "NERVE",
"toAddress": "TNVTdTSPVaHLGXQJDVCyNAo67zAoUcvbpeUri",
"chainId": 102,
"assetId": 0,
"contractAddress": "0xd0a347e0ebea8f8efc26d539e17853c8e7a721c4",
"decimal": 18,
"symbol": "USDT",
"swapChainId": 5,
"swapAssetId": 90,
"swapContractAddress": "",
"swapDecimal": 6,
"swapSymbol": "USDT",
"txHash": "0xb94eaeb65630d536a2313f6bea20ccf6f2eb735dd20e2f65c15a972fb5b6379d",
"nerveTxHash": "e62cba9f464d5fca04d90f0280bbbe763eb148255ef2c41b8788ef6c8c744e94",
"crossTxHash": "0x68a8c10c638d4412a8638e1a0799584facfa7eccad1b3a2581ed760af1089260",
"amount": "100",
"swapSuccAmount": "99.9500",
"swapFee": "0.05",
"crossFee": "0.0001",
"slippage": 0,
"pairAddress": "TNVTdTSQoL9quSyGJCA9sY8pcMEVy4RN4EjbB",
"status": 3,
"nerveStatus": 2,
"createTime": "2022-03-09 14:14:32",
"updateTime": "2022-03-23 14:27:20",
"errorMsg": ""
}
Last updated