Home Bitcoin How to develop Ethereum Smart Contract – Part 1

How to develop Ethereum Smart Contract – Part 1

by cryptocreed

Last Updated on December 31, 2020 by cryptocreed

Basic Solidity Smart Contract

[Notice: This Guide is only for Dummies, Not for Pro so if you are a PRO Kindly close this before You start Laughing and wasting your Time]

Hia!

First of all, I am not a Teacher or professional so my way of stating a fact or theory will not be conventional. I am an amateur and I believe that the best way to learn with fun is to lear with the amateur because he might give some hilarious examples which you can remember throughout the life on the that is why I always prefer to learn from books with titles Java for dummies, C# for dummies…etc., because they state the fact in a very amusing way. I don’t want to bore you guys so let’s get started into this Solidity for Dummies.

 

1.1 First Things First

We are beginners so we will make mistakes but if we start making mistake on the main ethereum blockchain then each mistake or erroneous deployment will cost us some ether. So to make mistakes and not lose any money we will use Test net ( Ropsten ), the more we make mistakes the more and better the dummies will learn.

Before that also we need to have a chrome browser. Go to Chrome and download Metamask. After Installing Metamask > Click on the right menu bar on Metamask symbol > Configure everything like Password etc. > Click on the drop-down menu on the Metamask window and select the Ropsten Network.

metamask

 

Now as you have not set up the Metamask in Test Mode with Ropsten Test Net let’s get some Dummy ether to get a kick start.

After you have set up the Metamask account, click on the Buy button, and then it will take you to the Faucet, where you can claim some free ether for testing on the test net.

matamask faucet

 

No, you have a Test net and some Ethers to put your steps into the Solidity world where smart contracts will be deployed. After we have deployed the First smart contract we will verify it.

Remember in the Altcoin section when devs create a smart contract and it is not verified then people start to chant scam, scam stuff. 😛

 

Things we will do NOW

1. First we will Make the most simple smart contract that we can make.
2. Deploy it on Test Net.
3. Verify it to make look more credible.
4. Then we will deploy it on Main Net, Yeah baby. [ Same steps as step 2 ]
5. Then we will verify it on the main net. [ Same steps as step 3 ]

To get into code we should know where to code, I mean you can even code on NOTE PADor Sublime Text Editor or any Crazy Editor you like, But if your code in the program friendly code editor then most of the codes will come as suggestions in the form of dropdown as you keep typing, We are dummies though but not Dumb so we will not waste time in Notepad, even we are much conscious about our data pack and don’t want to download any software so we will use the Online Solidity Remixer.

 

After Opening the solidity remixer < Delete everything written on the right-hand side, and now paste the given below code, don’t worry I will explain each and every single line of code.

eth

Explanation of Code:

Above smart contract is just a simple contract to store a value to variable dummyData.

Line 1: simply says that the solidity version is 0.4.4 and Pragma stands the same as #define in C++, basically it imports the basic rules for solidity, and in more simple terms it is a preprocessor that is importing the rules from solidity 0.4.4 standard.

Line 2: Now as we are making a contract so we say the compiler that we want to make contract followed by any name, here I have kept my contract name as DummyContract, you can choose anything you want.

DummyData is a state variable and uint (Unsigned Integer) is its type.

In Solidity smart contract is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. Notice the difference here we talk about the state, not just the variable itself.

Now as we have made a state variable dummy data now it is stored in DummyContract, from here now we can alter or call the state data by some functions called to get and set.

Line 6 and 7: line 6 declares a function set and line 7 assigns some value x to it.

Line 10 and 11: In line 10 tell we call a function to get and in line 11 we return the value of x to the function.

 

Now we have written our first smart contract, let’s get publish it on the test net.
Go to the left-hand side of the remix and select the setting tab. Now follow as said in the figure.

Select the compiler version, don’t select the nightly ones.

Select the compiler version, don’t select the nightly ones.

Uncheck enable optimization checkbox.

Uncheck enable optimization checkbox.

Go to run tab and click Create button.

Go to the run tab and click the Create button.

 

Now a Metamask window will pop out, click on Create Button on it, Hold on now you Just created your First contract on Test Net, congratulations!
After 12 Seconds Click on Metamask on the top of chrome again, Now you will see the contract published in it.

 Now a Metamask Window will pop out, click on Create Button on it, Hold on now you Just created your First contract on Test Net, congratulations! After 12 Seconds Click on Metamask on the top of chrome again, Now you will see the contract published in it.

Now click on the date of the contract in Metamask only. It will now open a new tab with the
contract and transaction, like given below figure.

 

Now after clicking the contract address new tab will open and in that click on contract code< Verify the contract. 1. Now enter the contract Name DummyContract 2. Select the compiler version that we selected previously while coding. 3. Disable the Enable Optimization to no. 4. Now in the below code space paste the code from solidity remix to it. 5. Click on verify.

 

Now after clicking the contract address new tab will open and in that click on the contract
code< Verify the contract.

1. Now enter the contract Name DummyContract
2. Select the compiler version that we selected previously while coding.
3. Disable the Enable Optimization to no.
4. Now in the below code space paste the code from solidity remix to it.
5. Click on verify.

If you had done everything correctly then you should get the contact verified now with a success message.

If you got an error while verifying then kindly pay the attention to every step minutely. Thus you have deployed your first smart contract on Ethereum test net, now repeat the same process by selecting the Main Net in Metamask and you will be done.

If you liked what I have taught then you can donate me some ether, I have tried to express everything in simple dummy language but still, I am also a dummy.

For any query comment here:  https://bitcointalk.org/index.php?topic=2407644.0

0 comment

You may also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.