omnia_getTokenPrice

Return the price of an ERC-20 token.

Please make sure that the token address for which the price is requested is corresponding to an ERC-20 token and the token is available on the network (endpoint) the request is sent to.

Parameters

  1. DATA, 20 Bytes - tokenAddress. ERC-20 token address for which the price is requested. REQUIRED

  2. DATA, positive number - pricingDecimals. Number of decimals used for the returned price. Default value: 5. OPTIONAL

Returns

  1. tokenAddress: address of the ERC-20 token

  2. tokenSymbol: ERC-20 symbol as stored in the token smart contract

  3. tokenDecimals: ERC-20 decimals as stored in the token smart contract

  4. usdPrice: Positive number representing token price denominated in U.S. dollars. (0 if the price of the token cannot be determined)

Example

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "omnia_getTokenPrice",
    "params": [{
        "tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "pricingDecimals": 5

    }]
}

Response

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "tokenSymbol": "WETH",
        "tokenDecimals": 18,
        "usdPrice": 2022.86554
    }
}

Last updated