Solidity Hello World with Ethereum Wallet

come to the classic Helloworld Solidity contract class using Ethereum Wallet. In this class we’ll see how to write a simple contract and deploy it on the block chain. We’ll also see how to interact with our contract by sending and reading data.

The syntax for a contract in Solidity is really similar to a class in oriented object programming languages. A contract have functions we can call and variables we can store and read.

Our Counter contract will store the number of times it has been called and make the value available for everyone to read on the blockchain.

 

To publish our contract on the blockchain, open Ethereum Wallet and go to My contracts.

Click Deploy a new contract.

In the code text area past our Counter contract code.

On the right select the contract you want to publish: our Counter contract.

Enter your password and press Send transaction. The gas price is the amount of Ethereum that will be required to publish your contract to the block chain.

You can see the counter value is equal to 0. On the blockchain, it does not cost anything to read a value, that’s why you can see the value displayed here.

Now if you execute our increment function guess what will happen? Our counter value will be equal to 1. That may take some time as the execution of the code must be written in the blockchain when the next block is mined.

If you execute the increment function another time you’ll see the counter value changing!

Congratulations, you published and interacted with your first contract. In the next tutorial we will see how we can improve our contract so only the owner (you) can interact with it.

3 thoughts on “Solidity Hello World with Ethereum Wallet

  1. Hi. I don’t have a “select contract” menu button anywhere, and it won’t let me deploy without selecting a contract. Would appreciate your help, thanks.

Leave a Comment