I have a contract like the following:
contract HoneyPot {
mapping (address => uint) public balances;
function HoneyPot() payable {
balances[msg.sender] = msg.value;
}
}
When deploying the contract I want to send some ether so the balances[msg.sender]
for the account deploying the contract gets a balance equal to the amount of ether sent. How should this be done?
Here is how I am deploying the contract:
const fs = require("fs");
const solc = require('solc');
let Web3 = require('web3');
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
let go = fs.readFileSync('HoneyPot.sol').toString();
let compiledContract = solc.compile(go);
abiDefinition = JSON.parse(compiledContract.contracts[':HoneyPot'].interface);
contract = web3.eth.contract(abiDefinition);
byteCode = '0x'+compiledContract.contracts[':HoneyPot'].bytecode;
let gasEstimate = web3.eth.estimateGas({data: byteCode});
And finally the line that deploys it (without sending ether):
deployedContract = contract.new({from:web3.eth.accounts[0],data:byteCode,gas: gasEstimate+40000});