Replies: 7 comments 6 replies
-
I think you may be using the wrong bytecode. The contract being deployed in that tx is massive. And the test contract above should be tiny. Make sure you are using the correct initicode. The miners have zero control over how much gas your deployment can take. It is fully deterministic and based on things the miners do not control. |
Beta Was this translation helpful? Give feedback.
-
I was getting the bytecode from Remix. I just tried with solcjs and the deployedTransaction.wait() is just hanging (not resolving and no error yet after 5 minutes) EDIT: it failed with only "transaction failed" as far as the error message I can see, but on Etherscan it says the execution/stirage didn't have enough gas. I put about $50 in gas on the msg.sender address here is the bytecode (about 7kb) which I'm getting from solcjs (I put it inside a JS object so I can require it and reference the value separately { "obj": Important to note that solcjs produces two files, one for the contract above and one with 0 bytes for the FiatTokenV2 contract referenced in the contract above. I don't know why it does that. |
Beta Was this translation helpful? Give feedback.
-
If it's failing to execute with $50 in ETH at the msg.sender/signer address then maybe I should just put in $100 and see? I was afraid it would consume it all and still fail. Is there a way to assess how much a contract would cost to get it up and running before burning real money? |
Beta Was this translation helpful? Give feedback.
-
Keep in mind that a byte is 2 nibbles, so the above code (when I compiled it) is 3.7kb (not 7kb, it's 7662 nibbles or 3831 bytes; Is there any reason you are using mainnet? I just simulated deploying your contract (in Remix) and unoptimized it requires 879657 gas to deploy, and optimized it requires 556592 to deploy. So, all your above gas limits are definitely too low, so it is running out of gas. I just deployed it to Goerli and it cost 483k gas. That was with optimizations turned on. You can always use |
Beta Was this translation helpful? Give feedback.
-
EDIT: sorry just got your reply, so replying by updating this, |
Beta Was this translation helpful? Give feedback.
-
<<Is there any reason you are using mainnet?>> Yes, I can only get USDC by purchasing it from Coinbase et al and transferring to Mainnet. I have not been able to find a USDC faucet on any of the test nets. I suppose I could deploy the USDC contract myself and become its owner at that address and create a free source of tokens that way, but I didn't think of it till now. 8) |
Beta Was this translation helpful? Give feedback.
-
@ricmoo that ended up being around $28 for the one I had written and $5 for the USDC contract method I am calling from the contract I deployed. I am not sure why that one contract deployment created these two different transactions:
do you have any idea? Also, any way I can buy you a beer? :) you saved me so much trouble to realize I had to turn on optimization ! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Suggestion
So I just spent over $70 trying to deploy a very simple contract
It succeeds at first but fails during execution
It feels like a racket to me because when I raise the gasLimit to say 250000 it will use it up 100% for the deploy and leave nothing for the execut BUT if I raise it to say 750000 then once again it will use it all up 100% for the deploy and leave nothing for the execution. So it feels like if I raise it to 2000000 it will also eat it all up during contract deployment and leave no gas for execution.
https://etherscan.io/tx/0x877ba3d2dab77221289d11eb1c78c4b53ba22ecbc01706dfc90f657b287a3d6c
This was my 3rd attempt I tried 50000 then 250000 then 750000 then 250000 again after I simplified the constructor. It should only run the constructor which current just sets owner to msg.sender
How the heck are you even supposed to deploy a contract (to Mainnet) without miners taking up all the gas to deploy regardless of what the gas limit (they always take 100% of it for deploy) and leaving nothing for execution.
So frustrrating.
here is my test contract below:
Beta Was this translation helpful? Give feedback.
All reactions