13

I have never written a smart contract before because there is a lot attached to it getting it working. But I finally want to learn it now.

I want to write a simple mininmal working smart contract which prints out something or does something similar to saying "Hello World". Is that possible?

How would such a contract look like? How to deploy it, what tools do I need?

J-B
  • 8,941
  • 16
  • 46
  • 77
q9f
  • 32,913
  • 47
  • 156
  • 395
  • Here is a guide that worked for me. https://scbuergel.wordpress.com/2015/11/03/first-steps-in-ethereum/ – akhmed May 24 '16 at 07:22
  • This website have nice guide from with clear code and screenshots on how to get started: https://ethereumdev.io/ – GrandMarquis Jul 21 '17 at 06:18

1 Answers1

21

The Greeter tutorial covers a basic Hello World contract. https://ethereum.org/greeter

As a quick summary, I just tested the following steps on Ubuntu 14.04. The install-geth script should also detect and work on other environments.

Note: I had to run the installation script in the first step below twice as it failed the first time.

  • Install geth: bash <(curl -L https://install-geth.ethereum.org)
  • Launch geth in developer mode so that we do not need to fetch the entire blockchain and can mine our own test-ether: geth --dev console
  • Create a test account from geth console : personal.newAccount()
  • Check your account balance (should be 0): eth.getBalance(eth.accounts[0])
  • Start the miner and let it run: miner.start()
  • Attach to geth via a second terminal session: geth attach
  • Check that your account balance has increased: eth.getBalance(eth.accounts[0])
  • Go to the online solidity compiler/editor at https://chriseth.github.io/browser-solidity/. It defaults to a Greeter contract.
  • Copy and paste the greeter's Web3 deploy code to a text editor and replace /* var of type string here */ with "Hello World"
  • Copy and paste the updated code to geth and wait for the Contract mined!.. message
  • Test the contract with greeter.greet()
  • You can destroy the contract with greeter.kill.sendTransaction({from:eth.accounts[0]})
hcvst
  • 2,018
  • 2
  • 21
  • 24
  • This was using Ubuntu/Linux. What about other OS? I want to try it on Windows. Can you cover for all OS, new learners will be benefited from it a lot. – Jimit Patel Nov 13 '17 at 14:47