0

so i made a contract named "Voting" with Remix IDE and a constructor with arguments for this contract

i called the contract by doing this :

var Contractabi = web3.eth.contract(contract Abi from Remix)
 var vote = Contractabi.at(Smart contract @ in REMIX );

so until now everything works fine ! but now i need to call the smart with it constructor with arguments

i found few methods like this one :

    var MyContract = web3.eth.contract(abiArray);

// deploy new contract
var contractInstance = MyContract.new([constructorParam1] [, constructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});

but it did not work for me ! How could i call My smart contract constructor with arguments in REMIX from my web3.eth.contract ! Thanks :D

Thanks :D

1 Answer 1

0

the constructor function is called during the deployment of the contract. This can be done

  1. in Remix: By providing the corresponding values to the arguments of your constructor function in the text entry field next to the orange "create" button to the right in Remix,

or

  1. using the web3 library, with the MyContract.new command you already provided. Hint: When having a contract ready to deploy in Remix, it provides you a code piece for web3 which you can just copy and use to migrate the contract.

Generally, I would recommend using the http://truffleframework.com/ !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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