Private
layer1This call will return the USD value for the specified amount of ETH. This API requires that the amount be specified in wei
(1018 wei
= 1 token) as a string, and will return a floating point value in units of USD. You can easily convert an ETH value to wei by using the Web3.utils.toWei()
function.
let layerOneOracle = await getSDK('LayerOneOracle', web3);
let usdPrice = await exchangelayerOneOracleRate.ethToUsd(amountInWei);
console.log(`USD value: $${usdPrice.toFixed(2)} USD`);
This returns a function that converts an amount of ETH in wei to USD. The returned function accepts a string that represents an amount in wei and returns a number that represents the USD value of that amount of ETH.
let layerOneOracle = await getSDK('LayerOneOracle', web3);
let converter = await layerOneOracle.getEthToUsdConverter();
console.log(`USD value: $${converter(amountInWei)} USD`);
Generated using TypeDoc
The
LayerOneOracle
API is used to get the current exchange rates in USD of ETH. This rate us fed by the Chainlink price feeds. Please supply a layer 1 web3 instance obtaining anLayerOneOracle
API from `getSDK()Example