资源加载中... loading...

exchange.IO("abi", …)

In the FMZ Quant Trading Platform, it mainly implements various functions, calls related to blockchain through exchange.IO() function. The following document describes the exchange.IO() function separately according to its function. The call method of the exchange.IO("abi", ...) function is used to register an ABI.

exchange.IO(k, address, abiContent)

The k parameter is used to set the function of the exchange.IO() function, set to "abi" means that the function is used to register ABI. k true string The address parameter is used to specify the address of the smart contract. address true string The abiContent parameter is used to specify the ABI of the smart contract. abiContent true string

function main() {
    // register Uniswap SwapRouter02 abi
    var routerAddress = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"
    var abi = `[{"inputs":[{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMaximum","type":"uint256"}],"internalType":"struct IV3SwapRouter.ExactOutputParams","name":"params","type":"tuple"}],"name":"exactOutput","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"payable","type":"function"}]`
    
    // Get the ```ABI``` content of the contract can be obtained with the following URL, taking the ```result``` field only, e.g:
    exchange.IO("abi", routerAddress, abi)
}

The methods of calling smart contract do not need to be registered if they are standard ERC20 methods. Get the ABI content of the contract can be obtained with the following URL, taking the result field only, e.g:

https://api.etherscan.io/api?module=contract&action=getabi&address=0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
Threads exchange.IO("api", "eth", ...)