You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`async function getNetworkStatusMethods() {
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum);
// provider.getNetwork( ) ⇒ Promise< Network > - Returns the Network this Provider is connected to.
console.log(await provider.getNetwork());
// provider.getBlockNumber( ) ⇒ Promise< number > - Returns the block number (or height) of the most recently mined block.
console.log(await provider.getBlockNumber());
// provider.getGasPrice( ) ⇒ Promise< BigNumber > - Returns a best guess of the Gas Price to use in a transaction.
const gasPrice = await provider.getGasPrice();
console.log(ethers.utils.formatUnits(gasPrice, "gwei"));
// provider.getFeeData( ) ⇒ Promise< FeeData > - Returns the current recommended FeeData to use in a transaction.
const feeData = await provider.getFeeData();
console.log(ethers.utils.formatUnits(feeData.maxFeePerGas, "gwei"));
// provider.ready ⇒ Promise< Network > - Returns a Promise which will stall until the network has heen established, ignoring errors due to the target node not being active yet.
console.log(await provider.ready());
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
https://docs.ethers.org/v5/api/providers/provider/#Provider-getFeeData
https://docs.ethers.org/v5/api/providers/provider/#Provider-ready
`async function getNetworkStatusMethods() {
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum);
}
}`
Beta Was this translation helpful? Give feedback.
All reactions