Skip to content

Fixed tutorial 01 & 02 for solidity 0.8.7 #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions tutorial-01/myfirstcontract.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

contract myfirstcontract {

contract MyFirstContract {
string private name;
uint private age;



function setName(string memory newName) public {

name = newName;

}

function getName() public view returns (string memory) {
return name;


}

function setAge(uint newAge) public {
age = newAge;
}

function getAge() public view returns (uint) {
return age;
}


}
63 changes: 43 additions & 20 deletions tutorial-02/myfirstcontract.sol
Original file line number Diff line number Diff line change
@@ -1,58 +1,81 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

interface Regulator {
function checkValue(uint amount) external returns (bool);
function loan() external returns (bool);
}

contract Bank is Regulator {
contract Bank is Regulator{

uint private value;

constructor(uint amount) public {

constructor(uint amount) {

value = amount;
}

function deposit(uint amount) public {
value += amount;
}

function withdraw(uint amount) public {
if (checkValue(amount)) {

function withdrawel(uint amount) public {

if (checkValue(amount)){
value -= amount;

}
}

function balance() public view returns (uint) {

return value;
}

function checkValue(uint amount) public returns (bool) {
// Classic mistake in the tutorial value should be above the amount
return value >= amount;

// Override

function checkValue(uint amount) public override view returns (bool) {

return value > amount;

}

function loan() public returns (bool) {

function loan() public override view returns (bool) {

return value > 0;

}

}

contract MyFirstContract is Bank(10) {
contract myfirstcontract is Bank(10) {

// Opposite of Java - private String firstName;
string private name;
uint private age;



function setName(string memory newName) public {

name = newName;

}

function getName() public view returns (string memory) {
return name;

}

function setAge(uint newAge) public {
age = newAge;
}

function getAge() public view returns (uint) {
return age;

}



}