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
The Optimism utilities is a small package to provide some
additional utilities required for those that wish to more
closely interact with Optimism-sepcific features.
This package is currently experimental and beta; the API is subject to change.
By default, estimateGas will connect to the Ethers default Optimism
provider. When providing a transaction, using a fully populated
transaction will result in the best possible L1 estimation.
import{estimateGas}from"@ethers-ext/utils-optimism";// Given a transaction// const tx = wallet.populateTransaction(...txParams);// ... or ...// const tx = contract.foobar.populateTransaction(...args);const{ gas, gasL1, gasL2 }=awaitestimateGas(tx);
An optional second parameter may be passed into choose another
Provider:
// Connect to the default Optimism Goerli providerresult=awaitestimateGas(tx,"optimism-goerli")// Connect to a local JSON-RPC providerresult=awaitestimateGas(tx,"https://localhost:8545")// Connect to a normal Ethers provider, like MetaMaskprovider=newBrowserProvider(window.ethereum)result=awaitestimateGas(tx,provider)
Estimate the L1 and L2 gas requirements for tx. If provider is
not specified the default Ethers provider for Optimism is used. If
a string is provided the standard getDefaultProvder logic is used.
License
MIT License.
About
Ethers extension package for additional Optimism-specific utilities.