Commit 0e876f62 authored by Chris's avatar Chris
Browse files

Added notes and a MyContact.sol file for my first ever smart contract!

parent 79cb0cba
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-3.0

// pragma solidity >= 0.8.0 < 0.9.0; // this auto updates the compiler Remix uses
pragma solidity ^0.8.0;
 
// in soldity, comments are important

// several of commenting: normal comments, like this one

/*
    this is a normal multi-line comment
*/

/**
  this is a NatSpec multi-line comment
*/

// there is also NatSpec Format: format of commenting that the compiler can read, and it will notify developers and users alike of these messages from the smart contract
// you can write information in these to help the user, clarify the code that you write, etc.

/// @title The best smart contract
/// @author gspbirel56
/// @dev (Here is a comment where you would explain how to use this smart contract)
contract MyContract {
    string public name = "Chris's smart contract";

/// @notice This function changes the name of the `name` variable in this contract.
    function updateName(string memory _newName) public {
        name = _newName;
    }
    
}

// you can have multiple contracts too within this file, and they can talk to each other
+31 −0
Original line number Diff line number Diff line
# Learn Solidity basics

## Part 1

### Video link

https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo

### Notes

- Remix: allows you to write Solidity code; allows you to write, compile, and run the code on eth blockchain
  - remix.ethereum.org
- Remix has templates and tutorials for smart contracts
- a smart contract is basically a function that is defined with the `contract` keyword
- you can declare a variable like this:

```solidity
contract SampleContract {
    string public name = "some name";
}
```

- the `name` variable can be accessed by using a call
  - a call is a zero-cost transaction you can make on the blockchain to access data, such as this stored variable value
- smart contracts use NatSpec style comments as well as standard ones (see the sample contract code file for examples)
- smart contract creates get() methods under the hood to read the data in it
  - you do have to create setter functions yourself
  - this is because the setters will usually require logic
  - setters utilize functions and actions
    - call it a "function" because a function does something, with rules and parameters
- 
 No newline at end of file