I am trying to build a small app that would rely on a private Ethereum Blockchain. I am relatively new to this and am still having a few questions about the whole process. I will try to be as clear as I can explaining the difficulties I am facing.

What I have

A running private blockchain, installed on a specific server (that I manage)

A working synchronisation between multiple nodes

A smart contract that I have written

What I want to do

I want to add the smart contract to my private blockchain

What I am trying now

I am using Browser-Solidity and selected the Web3 Provider, where I wrote down the IP address of my server and the port 8545.

I then see the Create button... but am told that the account is locked.

Here are my current thoughts:

How do I know which account is to be unlocked? When I type web3.eth.accounts, 4 accounts are returned...

I tried unlocking an account but I am running into the following error : Failed to unlock account (no key for given address or file). I do not remember setting up a key for any account. Am I doing something wrong? How can I get past this step?

I am guessing that once the smart contract will be added to my private blockchain, it would have to be mined. How would I go on and do this? Would it be by simply executing miner.start() from one of my nodes? Every time I mine, it never stops until I make it stop, and to be honest, I haven't really understood what is being mined.

1 Answer
1

Deploying a compiled contract to the network costs ether and is usually signed by your default account(coinbase) unless you specify another address (source). You can get the address of this account through eth.coinbase command and unlock it using personal.unlockAccount(eth.coinbase,"<password>").

I do not remember setting up a key for any account. Am I doing something wrong? How can I get past this step?

When creating an account using geth account new, you'll be prompted to enter a password/key for this account after which the account address will be displayed. This password should be remembered as it's used to unlock this account. One more way to create an account is to use personal.newAccount("<password>"). I don't think there's a way to create accounts without a password so I don't know how you did that. Since you're running on a private blockchain, the ether in your accounts shouldn't matter and if you want to re-do everything, delete the contents of keystore(caution: all the accounts will be lost) folder in your datadir and create new accounts again.

I am guessing that once the smart contract will be added to my private blockchain, it would have to be mined. How would I go on and do this? Would it be by simply executing miner.start() from one of my nodes?

Yes. After initiating a transaction involving the contract code, you can start mining using miner.start(<threads>). Check this link to understand the mining process.

Suggestion: You might want to check out DApp development frameworks like Truffle to work on your application.