Override transaction options (from, gas, gasPrice) in create and upgrade proxy
Add from, gas, and gasPrice as optional values to the options parameter of createProxy and upgradeProxy, so the user can change the defaults for a specific transaction. For example:
await upgradeProxy(existing.address, BoxV2, { deployer, from: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', gasPrice: 10e9, gas: 1e6 });
(found in truffle plugin, unsure if applies to builder as well)
We potentially want these settings to be granular since each function can correspond to multiple transactions.
We potentially want these settings to be granular since each function can correspond to multiple transactions.
@frangio Agree, but at least the from option would be great to support.
Note that the plugin will use the signer that comes attached to the ImplFactory in the Hardhat plugin, and I believe it also uses the same from default that was set for the contract class passed in the Truffle plugin.
This means that you can customize from by setting it in the contract abstraction you give the plugin (e.g. a MyContractV2 class).
I had a nightmare deploying to mainnet using deployProxy. I was unable to set maxPriorityFeePerGas which made me wait 36 hours to get the implementation deployed. After that I resumed the process, got the Admin contract deployed quickly, but then got stuck on Proxy deployment for another 2 days.
Overriding maxPriorityFeePerGas and maxFeePerGas is a must.
Ideally we should be able to resume the process and bump the fees.
Its totally a bad idea to not allow configuring the max base fee when deploying.... Not sure if i've seen any workaround for now, is there any to achieve cheap deployment of many contracts?
Here is a possible workaround for ethers.js:
const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits('100', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
};
// Wrap the provider so we can override fee data.
const provider = new ethers.providers.FallbackProvider([ethers.provider], 1);
provider.getFeeData = async () => FEE_DATA;
// Create the signer for the mnemonic, connected to the provider with hardcoded fee data
const signer = ethers.Wallet.fromMnemonic(/* mnemonic */).connect(provider);
// Get the contract factory connected to signer so it uses hardcoded fee data
const MyContract = await ethers.getContractFactory('MyContract', signer);
// Should now use hardcoded fee data for deployments
await upgrades.deployProxy(MyContract);
I'm trying the above @frangio still the same result. everything works fine on the mainnet (even without the workaround above), but the same configuration fails on testnet (harmony)
@gitbaq Please share more information about the error.
When the gas price is set to >15 mins slow, it times out with : timed out waiting for transaction "txHash" error, any solution to that or should just revert to suggested ethers.js gas price? Not sure if the transaction can continue without manual intervention
@noobshow Note that if it times out, you can just run the deployProxy function again and it will continue waiting for the transaction to be confirmed (you can also use the timeout and pollingInterval options to change how long it waits). Does that help, or are you more looking for a way to replace the transaction with a different gas price?
There are lots of deployments set up to go after each other. I was hoping it was possible for the deployment of implementation and the proxy to happen without waiting for the other or maybe a replacement transaction with a higher gas fee, since the script I use updates according to some gas prices recommendations
the deployment of implementation and the proxy to happen without waiting for the other
We don't do this because if the implementation deployment fails, then the proxy deployment will fail as well and it will cost a lot of gas for no reason.
@frangio I am trying to deploy the contract at https://github.com/superpowerlabs/synr-seed/blob/main/contracts/SeedFarm.sol All tests pass and I can deploy it without issues on localhost. I can also deploy the other upgradeable contracts without issues on all chains. Still, I cannot deploy SeedFarm because hardhat returns a gas estimation issue. The problem is that it seems that there is no way to set up a limit manually. Any suggestion for a work-around? I have a deadline coming soon and if I do not find a solution, I have to rewrite it and use a different approach to upgradeability. Thanks!
BTW, I didn't try on main net, yet. It fails on Ropsten, Mumbai and BSC Testnet.
There is a workaround above: https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/85#issuecomment-1028435049
Still no solution ?
I am trying to simply do a npx hardhat test of my proxy - upgradable contract, but not working:


Hello everyone, I am having problem with deployProxy function, the script worked as well for goerli and rinkeby (without using the workaround above) but on mumbai I am not able to deploy the contract.
These are the library used:
"@nomiclabs/hardhat-ethers": "^2.0.6"
"@openzeppelin/hardhat-upgrades": "^1.18.1"
This is the script:
const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits('100', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
};
// Wrap the provider so we can override fee data.
const provider = new ethers.providers.FallbackProvider([ethers.provider], 1);
provider.getFeeData = async () => FEE_DATA;
// Create the signer for the mnemonic, connected to the provider with hardcoded fee data
const signer = new ethers.Wallet(config.privateKey).connect(provider)
// const [signer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", signer.address);
console.log("#################################")
console.log("STARTING DEPLOY ACCESS TOKEN CONTRACTS")
const AccessTokenManager = await ethers.getContractFactory("AccessTokenManager", signer)
const accessTokenManager = await upgrades.deployProxy(AccessTokenManager,{ initializer: 'initialize', kind: 'uups'})
Can someone please tell me was is wrong here?
Thanks in advance.
@SalvatoreCataniaVS Please post this question in the OpenZeppelin Forum and include the error message you are seeing.
Is from supported yet for deployProxy() in hardhat-upgrades?
Here is a possible workaround for ethers.js:
const FEE_DATA = { maxFeePerGas: ethers.utils.parseUnits('100', 'gwei'), maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'), }; // Wrap the provider so we can override fee data. const provider = new ethers.providers.FallbackProvider([ethers.provider], 1); provider.getFeeData = async () => FEE_DATA; // Create the signer for the mnemonic, connected to the provider with hardcoded fee data const signer = ethers.Wallet.fromMnemonic(/* mnemonic */).connect(provider); // Get the contract factory connected to signer so it uses hardcoded fee data const MyContract = await ethers.getContractFactory('MyContract', signer); // Should now use hardcoded fee data for deployments await upgrades.deployProxy(MyContract);
Maybe extending the Hardhat HRE following this example of the docs with the modifications indicated by @frangio :
- In hardhat.config.js:
extendEnvironment((hre) => { const Web3 = require("web3"); hre.Web3 = Web3;
// hre.network.provider is an EIP1193-compatible provider. hre.web3 = new Web3(hre.network.provider); });