In case we want to deploy a contract by web3.js we can easily determine the balance of the contract at time of deployment as follows:

const thisContract = new web3.eth.Contract(abi);
thisContract.deploy({  
        data: bytecode,
        arguments: [< parameters of the constructor>]
    }).send({
       from: "0x3455D7167A2EE2d660EE85F8e90C6b3B1cCB7163",
       gas: 5000000 ,
       gasPrice: '3000000000',
       value: 5000 // here we determine the balance of the contract 
    },
    function(error, transactionHash) {
        console.log(error);
        console.log(transactionHash);
        console.log('function exec');
    }).then(function(newContractInstance) {
    console.log('Contract Instance:' + newContractInstance.options.address);
});

In this example, the balance of the contract is value: 5000.

However, when we want to do this by remix, is there any option to determine the value of the balance of the contract at time of deployment ?

up vote 3 down vote accepted

Make the constructor payable and set a non-zero value for the ether before hitting deploy (see image)

enter image description here

Hope this helps.

  • Thank you, in fact I asked this question, because I have a problem to make a settlement between payer and recipient using an Ethereum base blockchain (testnet) named Tobalaba (link) I explained the problem here (link) So, I decided to test this contract by remix to find what is the problem. I appreciate any idea to solve this problem. Thanks – sas Jul 12 at 15:11

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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