🛡️TransitSwap Contracts

查詢支持的網路列表和合約地址

返回所有網路的合約地址

GET https://aggserver.transit.finance/v4/common/contracts

{
    "result": 0,
    "message": "success",
    "data": {
        "contracts": {
            "router": {
                "ETH": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "OP": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "BSC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "OEC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "HECO": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "MATIC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "FTM": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "KCC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "ARB": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "AVAX": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "CFX": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "GLMR": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "ETC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "KLAY": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "TRON": "TKqQ7zuL7yKp1NWuhGpoXTDiE3j2qiAbRE"
            },
            "approve": {
                "ETH": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "OP": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "BSC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "OEC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "HECO": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "MATIC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "FTM": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "KCC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "ARB": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "AVAX": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "CFX": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "GLMR": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "ETC": "0xb45A2DDA996C32E93B8c47098E90Ed0E7ab18E39",
                "KLAY": "0x4517F5065C2f1c5508DD67dd1db95227cA87Abe8",
                "TRON": "TKqQ7zuL7yKp1NWuhGpoXTDiE3j2qiAbRE"
            }
        },
        "timestamp": 1667394094096,
        "hash":"0x70e430bca6ba4f60c6ac5fcf6a07942132f9d84b8b265fbb220285c53589b8c4",
        "signature": "0x991dbfd5226d65d209d9a934787e27e5b159619578b34e31a4122514b10e9358124b77ae2b266f0100bc1b91470ffe063ac4495fd243526495a2be1008c6633a1c"
    }
}

說明:

簽名地址: 0x6eef5ad82cf83f9e60d2e96ee2029dc17c7b6612

簽名信息: Access TransitSwap for a trusted data: + hash

Access TransitSwap for a trusted data:0x9e30f587c47c65791cd58fe4d6f2e889a13d6d8f22623c65960fb625f95e13c2

驗證簽名:

可以驗證返回的數據簽名是否為TransitSwap返回,還可以檢查時間是否在有效範圍內(例如 30 秒內),防止數據被惡意修改。

使用的簽名工具:https://www.npmjs.com/package/@metamask/eth-sig-util

生成hash的工具:https://www.npmjs.com/package/ethers

const sigUtils = require("@metamask/eth-sig-util")
const ethers = require("ethers")
const routers = [..data.contracts.Router]
const approves = [..data.contracts.Approve]
//如果是波場地址,請先轉為hex格式
const hash = ethers.utils.solidityKeccak256(["address[]", "address[]", "uint256"], [routers, approves, timestamp])
const data = "Access TransitSwap for a trusted data:" + hash
const signer = sigUtils.recoverPersonalSignature({data:data,signature:signature})
if (signer == "0x6eef5ad82cf83f9e60d2e96ee2029dc17c7b6612") {
    //code
}

Last updated