Getting Started with Ethereum Tutorials on Azure


On Ethereum.org are some tutorials (e.g. https://www.ethereum.org/token) to get started with Ethereum. If you want to try them using the Ethereum templates in Azure you may find some blockers going through the tutorials. This blog post should get you started so far with your private Ethereum Blockchain that you can proceed with the tutorials you find in the web.

Introduction

In Azure you are able to create several private Blockchains using ARM (Azure Resource Manager) templates. This way you save time to deploy and configure small or large Blockchain networks. Those private Blockchains come very handy for developing and testing smart contracts in Blockchains.

Problems

I was not able to follow standard tutorials for creating Smart Contract like those available on ethereum.org. My issues belonged to three groups:

  1. using the GUI of Mist to create a new account
  2. using the GUI of Mist to deploy a contract
  3. using geth interactively to manage accounts

mist - create new account

Starting mist connecting to my private Ethereum Blockchain.

mist --rpc http://blogbcx7m.westeurope.cloudapp.azure.com:8545

If you want to create a new account via the GUI the new account does not get created. In the log of the console you get the following error:

[2017-07-12 09:15:50.882] [ERROR] ipcProviderBackend - Send request failed { code: -32601,
message: 'The method personal_newAccount does not exist/is not available' }

mist - deploy contract

If you want to deploy a contract to your private Ethereum Blockchain you get the following error.

[2017-07-12 09:21:39.468] [INFO] (ui: popupWindow) - Choosen Gas: 0x1197e9 1153001
[2017-07-12 09:21:39.477] [ERROR] ipcProviderBackend - Send request failed { code: -32601,
message: 'The method personal_sendTransaction does not exist/is not available' }
[2017-07-12 09:21:48.936] [ERROR] ipcProviderBackend - Send request failed { code: -32602,
message: 'invalid argument 0: missing 0x prefix for hex data' }

geth - interactive use in the console

Using geth to connect to your private Ethereum Blockchain you get the following information about the modules. Only the modules eth, net, rpc, and web3 are available.

C:\Users\adm_pk\AppData\Roaming\Mist\binaries\Geth\unpacked\geth-windows-amd64-1.6.6-10a45cb5>geth attach http://blogbcx7m.westeurope.cloudapp.azure.com:8545
Welcome to the Geth JavaScript console!

instance: Geth/blogbcx7m-tx0/v1.6.0-stable-facc47cb/linux-amd64/go1.8.1
coinbase: 0x657ff5d656ad5b88bdc0b87b66276ac0220ed98c
at block: 9079 (Wed, 12 Jul 2017 09:31:09 GMT)
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0

This means that important functions like newAccount or unlockAccount do not work.

personal.newAccount("MySecurePassphrase")
 Error: The method personal_newAccount does not exist/is not available
eth.accounts
 ["0x657ff5d656ad5b88bdc0b87b66276ac0220ed98c"]
 > personal.unlockAccount("0x657ff5d656ad5b88bdc0b87b66276ac0220ed98c", "MySecurePassphrase")
 Error: The method personal_unlockAccount does not exist/is not available

If you look on the running geth instance on the server all modules are available.

gethadmin@blogbcx7m-tx0:~$ geth attach
Welcome to the Geth JavaScript console!

instance: Geth/blogbcx7m-tx0/v1.6.0-stable-facc47cb/linux-amd64/go1.8.1
coinbase: 0x657ff5d656ad5b88bdc0b87b66276ac0220ed98c
at block: 9141 (Wed, 12 Jul 2017 09:48:09 UTC)
datadir: /home/gethadmin/.ethereum
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

Solution

The solution is quite simple. As always, if you know what to do. 😉 Connect to the transaction nodes of your private Ethereum Blockchain to change the RPC APIs of the running geth instances.

Change the config file $/start-private-blockchain.sh (or /home/[username]/start-private-blockchain.sh) to enable the RPC APIs for the modules admin and personal.

Per default there are no arguments configured for the RPC APIs of geth.

So change the line starting with nhub geth:

echo "===== Starting geth node =====";
set -x;
nohup geth --datadir $GETH_HOME -verbosity $VERBOSITY --bootnodes $BOOTNODE_URLS --maxpeers $MAX_PEERS --nat none --networkid $NETWORK_ID --identity $IDENTITY $MINE_OPTIONS $FAST_SYNC --rpc --rpcaddr "$IPADDR" --rpccorsdomain "*" >> $GETH_LOG_FILE_PATH 2>&1 &
if [ $? -ne 0 ]; then echo "Previous command failed. Exiting"; exit $?; fi
set +x;
echo "===== Started geth node =====";
Add the --rpcapi configuration: (in my case it's line 54)
echo "===== Starting geth node =====";
set -x;
nohup geth --datadir $GETH_HOME -verbosity $VERBOSITY --bootnodes $BOOTNODE_URLS --maxpeers $MAX_PEERS --nat none --networkid $NETWORK_ID --identity $IDENTITY $MINE_OPTIONS $FAST_SYNC --rpc --rpcaddr "$IPADDR" --rpccorsdomain "*" --rpcapi "eth,net,web3,admin,personal" >> $GETH_LOG_FILE_PATH 2>&1 &
if [ $? -ne 0 ]; then echo "Previous command failed. Exiting"; exit $?; fi
set +x;
echo "===== Started geth node =====";
Now restart geth or the machine. If you have more than one transaction node, you have to do this on all transaction nodes.
That's it. That little issue had cost me some hours. After that I was able to follow all typical tutorials on my private Ethereum blockchain.
Comments (1)

  1. Gilang says:

    Thank you very much. This is very helpful.
    I have a question: Since this opens the RPC API’s what is the impact on security? And how do you mitigate the possible risks of having someone accessing your RPC API and ddos your network?

Skip to main content