I launch the ethereum blockchain by running testrpc
. That is creating 10 test accounts with sufficient funds.
When I use web3 with node.js to to deploy a new smart contract, I can use:
MyContract.new(['MyProps'],{data: byteCode, from: web3.eth.accounts[0], gas: 4800000})
When I use web3 with Java, I need a Credentials object. The following line seems not to work, because the deployment returns that the account has not sufficient funds.
String account = web3.ethAccounts().send().getAccounts().get(0);
Credentials c = Credentials.create(account);
Contract_sol_Contract contract = Contract_sol_Contract.deploy(web3, c, new BigInteger("240000"),new BigInteger("2400000"), props).send();
-->sender doesn't have enough funds to send tx. The upfront cost is: 576 and the sender's account only has: 0
Obviously, the Credentials object is not correct. As far as I understand, the private key must be passed and I used the public address.
- How can I access the private address in Java web3j?
- Why is it sufficient in web3 (node.js) to use the public address for the deployment of the contract?
Thanks in advance, Marco