0

I'm developing a dapp with the truffle suite and now I'm running into a problem. Everything is working locally in the ganache instance.

My contract should disallow direct payments to the contract, so my constructor looks like:

/**
 * @dev Disallow payments to this contract directly
 */
constructor() public {
    revert("No direct payments");
}

https://github.com/ethereumbook/ethereumbook/blob/develop/code/auction_dapp/backend/contracts/AuctionRepository.sol

But now the Deploy by truffle reverts with the given message.

Removing the line where the constructor is reverting and everything works fine. The contract is deployed and tested. The contracts are deployed like this:

var SecondPriceAuction = artifacts.require("./VickreyAuctionHouse.sol");
module.exports = function(deployer) {
  deployer.deploy(SecondPriceAuction);
};

Any ideas how to deploy a contract, that does not allow calling the constructor.

  • 2
    My contract should disallow direct payments to the contract, so my constructor looks like: - seriously??? How exactly is that supposed to disallow payments to the contract??? It disallows the deployment of the contract altogether!!! (and yes, for the sake of sarcasm I guess you could say that a non-existing contract cannot be paid to). – goodvibration Jul 25 at 12:24
  • hhmm, the ethereumbook desribed it like this in the given link – Artur Jul 25 at 12:41
0

It is not the constructor that should have the revert but the fallback function.

From the example you linked

/**
* @dev Disallow payments to this contract directly
*/
function() public{
    revert();
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.