[Ethereum] How to deploy contract into local running node using solidity browser

contract-deploymentremix

I am running a local ethereum node and I did unlock an account.
Now I want to use the solidity browser to deploy that contract, but when I switch to the web3 provider deploy option and I press the Create button at the address 'http://localhost:8000' all I see is an error that says 'Error: account is locked'. I don't know why and how is this working?

Also what is the easiest way to deploy an smart contract into a local running node?

Best Answer

I see you are changing the Web3 Provider Endpoint in Solidity Browser, and make sure to unlock account.

An alternative way is to just leave the default: Javascript VM, then:

  1. Click Create and copy the values in Web3 deploy.
  2. Open a Geth console with account 0 unlocked.
  3. Paste the Web3 deploy values into the Geth console, and wait for your transaction to be mined.

Here's the Web3 deploy values for the simplest contract Test {} and you can see that web3.eth.accounts[0] needs to be unlocked (or change it to your unlocked account).

var testContract = web3.eth.contract([]);
var test = testContract.new(
   {
     from: web3.eth.accounts[0], 
     data: '6060604052600a8060106000396000f360606040526008565b00', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })
Related Topic