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 deploy 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
I believe you are using a newer version of web3. You can revert to the previous version 0.20.0 or use the new syntax below.
When using version 1.0.x of web3 you need to pass in the Application Binary Interface, i.e. abi. And use the
new
keyword
Docs https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#eth-contract
Here is an example
var contractABI = [{your contract abi}]
var subtestContract = new web3.eth.Contract(contractABI,{
from: account1,
data: "your contract data",
gas: '4700000'
})
//arguments go inside deploy() using an array as follows
subtestContract.deploy({arguments: ["hello"]})