Solidity Basics

I could say YES, the changelog between the versions are minimal, the huge step was from 0.6 to 0.7. So we update our course by that time to stay up to date. Now the difference between 0.7 to 0.8 are not critical enough to update the course to that version (meaning the course content is still valid to learn the fundamentals of solidity).

You can read more about this changes here: https://docs.soliditylang.org/en/latest/080-breaking-changes.html

Carlos Z.

1 Like

it means the licence your using is incorrect. can u show screenshot

Does it matter which compiler I use? The video “contract structure” is using 0.7.5, but now I can see there’s 0.8.15. SHould I follow the video and use 0.7.5 or use the most recent one 0.8.15?

1 Like

I’m learning from the “contract structure” video. Flilip said I need to choose “hello world” under “Contract” before deploy the contract. But there’s nothing I can click under “contract”. What should I do?

1 Like

Yes, you should stick with the course version.

Carlos Z

2 Likes

You have to compile the contract first, you can do it through the compilation icon
image

Then go back to deploy menu (icon below compilation) and deploy the contract.

Carlos Z

2 Likes

Thanks for the reply!! May I know why it is giving me error as stated in the photo below please? It doesn’t like me having “_” before “number” and “index”.

1 Like

Your array is declared as number but you typed numbers on both functions.

Carlos Z

3 Likes

no usually it does not matter which compiler version you use. in fact for the scope of this course and beyound it does not mater at all. the only time you should be careful when choosing a compiler version is when your writing a contract that is inheriting the smart contracts of another protiocol (uniswap for example), in this case the creators contracts may be dependanct on older versions where certain code might be deprecated in newer versions. in this case to make your code compatibale with theres its important. but for here its not

1 Like

@thecil @mcgrane5 Thanks for the info!!

1 Like

no worries at all @cyl2chan

I noticed the Javascript VM environment option isn’t there anymore when deploying a contract, you can just use Remix VM

1 Like

remix has updated recently. for just use teh remix vm its the equivilent

Hi, I had a hard time finding what option/setting I can enable on Remix to get it to display variable values including “decoded output” in the console log. Example for this is in video “Constructors” at 03:35. If you are in the same boat, go to the “Home” file, click “More”, then activate your “Debugger” module. You may even need to reload the webpage for this to take full effect. Now when you run the program it will display a “Debug” button on the bottom-right which you can toggle/open and it will show what you’re looking for… Phew!

1 Like

yeah think the reason for this is the remix ui has changed a lot over the years since filip made the videos on this course. great that you found a solution tho

Filip created a ‘from’ param in the private function ‘_transfer’ instead of simply using ‘msg.sender’ like he does in ‘transfer’ function (see screen shot). I tested using ‘msg.sender’ in the private function ‘_transfer’ as well and it works just fine so not getting why we would create a separate param for this. Any thoughts?

2 Likes

@filip

Hi! The compiler keeps stopping this program. I wrote it exactly like in the video, but the complier is not satified!

I get:
ParserError: Expected ‘(’ but got identifier
–> HelloWorld.sol:18:14:
|
18 | function getBalance() public view returns (uint){
| ^^^^^^^^^^

on lines 18 and 19 I wrote:
function getBalance() public view returns (uint){
return balance[msg.sender];

Sincerely,
Aaron

1 Like

There is a public function, which is transfer that everyone can use, this function have hard coded that only the caller is able to transfer funds from himself to another (recipient).

While the internal function _transfer is only accessible to the contract itself, no one can use it, and its the one that override the values of the balance mapping of the contract, basically it does the critical step, which is transfer funds.

Since this function does not contain any security measure, if you made it public, everyone will be able to transfer funds from everyone to any. Meaning, I could transfers funds from your wallet to mine.

Instead, the transfer function is the only one that the public can use to made transfer, and its hard coded to allow the caller (msg.sender) to transfer from his funds, to any.

Hope I explained myself clear, if not let me know :nerd_face:

Carlos Z

1 Like

Please share your code in the following way so i can review it properly :slight_smile:

Carlos Z

2 Likes

Hi Carlos, thx for the reply!

Below is what I did and tested yesterday and since msg.sender is hard-coded in private function _transfer, it’s still only possible for the account invoking the smart contract to send funds to a recipient. Is the problem, perhaps, that on a real blockchain a private function that’s not directly invoked doesn’t know about msg.sender and this only works within Remix with fake accounts/addresses?

    function transferAmt(address recepient, uint amt) public {
        _transferAmt(recepient, amt);
    }

    function _transferAmt(address to, uint amt) private {
        balance[msg.sender] -= amt;
        balance[to] += amt;
    }

Thx in advance!
Gabe

1 Like