Unable to deploy to mainnet via Truffle/Infura

Greetings Community!
It has been a while, but I am now back at it. :mechanical_arm: :smiley:

On 12/26/2020 I successfully compiled, migrated and tested on Ropsten via Truffle the following contract https://github.com/estudios-amazonia/FilmVault/blob/main/contracts/FVP_Token.sol. See Ropsten Contract Address: 0x82Bc5871e30FB2C00A3E5B5E6475A2baD88978ba

Yesterday, 12/27/2020 I tried to deploy the same contract using the same truffle-config.js file on Mainnet and it gets frozen after compilying. I have used an array of gas / gasPrice combinations. The latest is as follows:

mainnet: {
  networkCheckTimeout: 100000000,
  provider: function() {
    return new HDWalletProvider(maimnem, 'https://mainnet.infura.io/v3' + key);
  network_id: 1,
  gas: 4000000,
  gasPrice: 65000000000, // 65Gwei

Therefore, I tried to use Remix, with GASLIMIT 350000 and VALUE 60 Gwei and it failed twice. See the following Tx https://etherscan.io/tx/0xdbdbe42e7f937f18952db19e94c6e6b42628f90241653f06d724999e278698e5 https://etherscan.io/tx/0x794243d66ba78ab9b349bb0a9abd38c3b2e6de55b396dd7a6b6a1f6258cff005

Therefore I submitted a ticket at https://ethereum.stackexchange.com/questions/91597/unable-to-deploy-migrate-to-mainnet-via-truffle-infura/91605#91605 and was recently informed that “The contract you are trying to deploy has a non-payable constructor and you are sending a 0.00000008 Ethers.”

I searched on this subject and I found https://ethereum.stackexchange.com/questions/27059/the-constructor-should-be-payable-if-you-send-value-but-constructor-is-not-pay “This error jumps out for some (unpredictable) reasons when, may be, the internal remix ide stack is corrupted and/or your deployment silently fails. Very often if you save, exit and reload it does not appear anymore. If it appears again and again with your code, try to save/exit/reload and then deploy it again using a 10x gas limit.”

However, I truly want to deploy via Truffle/Infura since I already wasted almost $10 via Remix.

Would anyone be able to shed some light on how exactly I need to modify the contract so that it deploys/migrates into Mainnet via Truffle/Infura??

Greatly appreciated.

1 Like

I just found the following Two Statements on here https://ethereum.stackexchange.com/questions/12119/solidity-web3-js-cannot-send-value-to-non-payable-constructor

Statement A: " This always worked - I’m using MetaMask to sign the payments and inintiate the contracts. Since a week or something, I’m getting an error in my console from Web3: Cannot send value to non-payable constructor

I then started to Google around, and found out about a function needed to be payable and that there should be a fallback function in my contract."

and this

Statement B: " A little explanation. I renamed “reject” to “kill” and removed payable from the functions I don’t imagine should have it.

There are two ways to inject funding into the contract:

1. When deploying the contract , add value. You can do that through meta.mask as you deploy the contract.
2. After it’s deployed , you can send Ether to the contract’s address in the same way you would send ETH to your other wallet. No function named needed. The unnamed (fallback) function, which is payable , will run.

You can also trigger the fallback from JavaScript web3.eth.sendTransaction({from: me, to: contract, value: amount}) or from another contract with contractAddress.send(amount) . The contract is going to execute the fallback function when no function is specified, or when the function specified doesn’t exist.

I added an event emitter to the fallback function to show how you can use the fallback for something useful. For consistency, I dropped it into the constructor as well, and added a similar event for send().

We can safely say the “necessary accounting” (logs in this case) is performed for all funds that arrive and depart this contract. Nothing will sneak in through functions like send() that aren’t designed to process receipts."

Could anyone shed some light on how should the Open Zeppeling Functions ought to be modified to become payable so that they work? The wierd thing is that these very same contracts were deployed successfully via Truffle/Infura over a year ago. ALL THE FUNCTIONS ON CONTRACT THE ARE EXACTLY THE SAME, I only changed the constructor :man_shrugging:

1 Like

Guidance on how this issue was finally resolved came from another contributor. Details can be found at https://ethereum.stackexchange.com/questions/91597/unable-to-deploy-migrate-to-mainnet-via-truffle-infura

Although I was unable to deploy/migrate via Truffle/Infura with plenty ETH, the contract was finally deployed/migrated via Remix/Metamask by setting GAS LIMIT=800000 and VALUE=0 at a non-peak time.

See https://etherscan.io/tx/0xde603058609d800d0ee2ccc5cf4cfa086a7161a25b9ce774cabae52a7514282c

1 Like

Hi @jaureguino,

Glad you were able to resolve.

1 Like

I am definitely rusted and outdate, since it has been a while since I coded Smart Contracts last; besides this is not my main skill, but I do it out of necessity. :man_shrugging:

However, I will probably be more involved in Q1-2021; therefore, I will definitely be back when I get in some deep trouble… :smiley:

1 Like

Hi @jaureguino,

The tools have improved :rocket:, but gas prices have increased :frowning_face:. Feel free to ask all the questions that you need.

1 Like

Will do. :bowing_man:t2:

1 Like