trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

void #811

Closed ghost closed 6 years ago

cgewecke commented 6 years ago

@lazaridiscom Is this closable? Does it seem like the constructor argument validation is working correctly?

cgewecke commented 6 years ago

@lazaridiscom Is the error you saw correct? i.e for some reason the constructor was called without arguments? If so we should close this because it's un-related to #596 - that's a re-compilation bug.

ghost commented 6 years ago

@cgewecke , its "similar to #596", not 100% sure if related. Placed this just for info. I cannot verify this at this moment, the error exists (although its something else what triggers it, possibly command-line handling). For sure: there is something wrong. And until someone pinpoints it, this should stay open.

cgewecke commented 6 years ago

@lazaridiscom - Where / when is the error being triggered? We just recently added this constructor error message in order to address silent failures caused by the ability to instantiate a contract that requires constructor arguments without actually specifying them. The error you're seeing is definitely from Truffle (rather than web3) and intentional.

Don't you get a line number for the error? Does it originate in migrations or a test?

cgewecke commented 6 years ago

@lazaridiscom Thanks for the reminder about the EthPM, will look at that shortly.

jbarros35 commented 6 years ago

Error: Ballot contract constructor expected 1 arguments, received 0 that's the same contract in tutorial website. please can you help me find a solution?

FabiolaBusch commented 6 years ago

My code:

`contract Listing {

address public creator;
uint public id;
bytes32 public title;

function Listing(address _creator, uint _id, bytes32 _title) public {
    creator = _creator;
    id = _id;
    title = _title;
}

}`

Same here, truffle version Truffle v4.1.5 (core: 4.1.5).

And the output with truffle migrate:

Error: Listing contract constructor expected 3 arguments, received 0 at /usr/local/lib/node_modules/truffle/build/webpack:/home/truffle-contract/contract.js:390:1 at /usr/local/lib/node_modules/truffle/build/webpack:/home/truffle-contract/contract.js:374:1 at process._tickCallback (internal/process/next_tick.js:103:7)

cgewecke commented 6 years ago

Hi @FabiolaBusch If you're passing Listing to the deploy method, you'll also need to specify the values of its constructor parameters. For example:

address = "0xabc.......";
id = 5;
title = web3.fromAscii("Hello!");

deployer.deploy(Listing, address, id, title);

There's more info about the deployer API in the docs here.

FabiolaBusch commented 6 years ago

@cgewecke Thanks a lot, that helped me!