Share:
Notifications
Clear all

Earn While Learning Web3 Programming>> Start Here FREE!!!

[Solved] How To Write Smart Contract in Solidity - Web3 Programming

10 Posts
3 Users
6 Reactions
921 Views
1
Topic starter

EXERCISE: Write and Deploy Your First Solidity Smart Contract:

i. Named "HelloWeb3World"

ii. Deploy and have it Return "Hello Web3 World" in Remix

iii. Post your SC code in this forum

iv. Share your experience like errors and challenges first time coding smart contract with solidity

 

NOTE:

This Is An Exercise From Our FREE Smart Contract Development With Solidity For Beginners Course (If you have not enrolled yet, you can join the course totally for FREE).

 

 

5 Answers
1

See my question getting responses like this actually make me fill like I am in actual school with a teach . This give the drive to wonting to learn because I know once I got stoked I have some that will always put me through .

Once again Sir I said thank you very much for everything.

Solomon Foskaay Solomon Foskaay Topic starter 28/10/2021 7:21 am

@leouloko this is just the beginning. Am giving this project 101% attention and in it FULL TIME to Mint at least 1Million Web3 Programmers before 2024 that Web3 is going mainstream.
So, be assured, you got someone on ground to support every courses that will be released on this platform henceforth.

1
Topic starter

I believe you will see helpful solidity smart contracts examples below from our students but in case none yet. Then, check a solidity smart contract example I wrote myself.

1

pragma solidity 0.8.7;

contract howslidityiswriten{
function helloweb3world() public view returns(string memory){
return "helloweb3world";

}
}

 

//in my case instead of returns(string memory)

i wrote return(string memory)

it took me more than an hour with out knowing where the error was coming from. i have to start afresh before i noticed there was no s in the return

Solomon Foskaay Solomon Foskaay Topic starter 28/10/2021 4:57 am

@leouloko interesting, I did same mistake in my first attempt and the reason I do encourage my students to not just watch me code in the course videos but follow me and try to re-write the code themselves.

Errors like this can not be detected just watching videos but only when you write the code yourself. And such stick to your brain for life helping you ensure you can easily spot and correct the errors in future faster within 5minutes or less instead of 1hour+ spent the first time you experience it....good job

Now to your code, see my comment on it below

Solomon Foskaay Solomon Foskaay Topic starter 28/10/2021 7:15 am

@leouloko I replied you previously via mobile and seems to screw things up that makes the display horrible but now corrected.

pragma solidity 0.8.7;

contract howslidityiswriten{
function helloweb3world() public view returns(string memory){
return "helloweb3world";

}
}

 

My comments 

(1) your name style is hard to read. You need to improve on it and it has to be now that you are starting as a beginner not later so it becomes part of your coding attitude. 

Don't use lower case for multiple words. 

function helloweb3world

should be

function helloWeb3World

Or

function hello_web3_world

You will notice the last two are much easier to read if you have like 1000 lines of code that all lowercase. So important please🙏

 

(2) Check spelling errors. I do this mistakes too even till now but we all learning and am improving on it too, so do take note as well

contract howslidityiswritten {

Misses "o" on solidity

and better rewritten as:

contract howSolidityIsWritten {

(3) Space you text when it is not a reserve keyword or function name etc to make it cleaner for your SC users or other Programmers that want to work with your code. Like:
 
return "helloweb3world";
 
may be rewritten for clarity as
 
return "Hello Web3 World";
 
Other observations are too advance for this level you are in the course but as you go further if I observe them in your code will help point them out to adjust on it. 
 
Once again kudos for taking action. 
 
1

Thank you sir.

Solomon Foskaay Solomon Foskaay Topic starter 28/10/2021 8:22 am

@leouloko you are welcome.

1
// SPDX-License-Identifier: GPL-3.0 // the IDE demands i use this line for license
pragma solidity 0.8.7;

contract helloweb3world{
    function hello_web3_world ()public pure returns(string memory){
        return"Hello Web3 World";
    }
}
Solomon Foskaay Solomon Foskaay Topic starter 10/12/2021 11:53 am

@joshua cool 👍 .

The license is okay too. It may be GPL-3.0 or MIT if the code is open-source. You can read about each license to know which to use for a production smart contract

Share: