Setup an Ethereum Node on Microsoft Azure and Deploy a Solidity Smart Contract

in #ethereum6 years ago

Blockchain-as-a-Service on Azure

Microsoft Azure PaaS provides the capability to run Ethereum nodes as an instance. The platform supports different Blockchain platforms. It provides an easy way to launch an ethereum instance with minimal effort on node setup. To be able to deploy an Ethereum Blockchain node on Azure make sure you have an active account on Azure, then follow these steps to get your node working and ready to be accessed and deploy a smart contract on.

Step 1: Create Azure Ethereum Node

Once logged in into the Azure portal click on Create a Resource at the very top left and then from the marketplace list click on Blockchain and then select Ethereum Consortium Blockchain.
Follow the steps to setup your node by defining the features on number of nodes, mining nodes, network ID and passwords.

Once completed you will see the resource on the dashboard.

Step 2: Confirm Node Availability

To see the networking details of your node click on the item of type virtual machine with the name containing your resource name.

The next screen we should look at is the NetwrokSecurityGroup instance and in this screen we will make sure that all ports that we need for accessing the node are open.
• Port 22 for ssh, to access remotely the node
• Port 8545 for RPC, to be able to issue the RPC calls
• Port 3000 for gethadmin, to access the node and be able to access the ethereum client from the terminal

Step 3: Configure Access to the node

After finishing spinning the instance and confirming it is running, we need two extra steps to be able to access the node and execute RPC calls.
First we need to unlock the main account for the node so we will need to ssh to the node using its dns name or ip address

ssh –p 3000 user@node

once the ssh connection is open at the terminal run this command

geth attach http://nodename:8545

This command will start the ethereum cosnsole, and then run this command, where 0 is the index for the base account.
personal.unlockAccount(eth.accounts[0])

It will ask for the password to unlock the account
Unlock account 0xe79fd5eae01eaf2611f640af8ef8520a70a63593
Passphrase:
Once done we should see true typed at the console.

Now exit the Ethereum console and then find the file start-private-blockchain.sh. Use a text editor to edit the file and add the text in italic in the section starting with Starting geth node

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 =====";

Save the file and restart the instance

Step4: Accessing the node and run first smart contract

Smart contract can be developed usin the Solidity language and there are few framewoks that provide a complete environement the most famous is Truffle. However, we will use the ethereum Remix IDE since it is simple and can be used without any need to install a softaware.
Launch the browser and open this link http://remix.ethereum.org/. Make sure tha the protocol is http and not https to avoid problems connecting with the Azure Ethereum instance later on. Inside the Remix IDE you will see an IDE where you can write your code, compile and deploy and interact with the Smart Contract.

To link to your node click on the Run tab on the top right corner. Then go to Environment option and select Web3 Provider. You will see a dialog box requesting the address. Type in your node address followed by the port 8545 and make sure that the protocol is http.
Once you contract is compiled with no errors hit in create and wait for to the node to mine the transaction.

Now on the right side we can see new text area and buttons that represent the interface to the Smart Contract

Sort:  

Uncomplicated article. I learned a lot of interesting and cognitive. I'm screwed up with you, I'll be glad to reciprocal subscription))

@asghaier, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!

Please also take a moment to read this post regarding bad behavior on Steemit.

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.029
BTC 58522.98
ETH 3089.61
USDT 1.00
SBD 2.41