exchange.IO("encodePacked", ...)
The exchange.IO("encodePacked", ...) function is used to perform encodePacked encoding operations.
exchange.IO(k, dataFormat, ...args)Examples
When using Uniswap V3, parameters such as trading path need to be passed in, which requires the use of encodePacked encoding operations:
javascript
function main() {
var fee = exchange.IO("encodePacked", "uint24", 3000)
var tokenInAddress = "0x111111111117dC0aa78b770fA6A738034120C302"
var tokenOutAddress = "0x6b175474e89094c44da98b954eedeac495271d0f"
var path = tokenInAddress.slice(2).toLowerCase()
path += fee + tokenOutAddress.slice(2).toLowerCase()
Log("path:", path)
}Returns
| Type | Description |
string | The |
Arguments
| Name | Type | Required | Description |
k | string | Yes | The |
dataFormat | string | Yes | The |
arg | string / number / tuple / array / any (any type supported by the platform) | Yes | The There can be multiple |