Skip to content
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

made all the required changes #47

Open
wants to merge 22 commits into
base: fix/tutorial-09
Choose a base branch
from
Open

made all the required changes #47

wants to merge 22 commits into from

Conversation

phyBrackets
Copy link

`//SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0 <0.9.0;

interface ERC20 {
function totalSupply() external view returns (uint256 _totalSupply);

function balanceOf(address _owner) external view returns (uint256 balance);

function transfer(address _to, uint256 _value)
    external
    returns (bool success);

function transferFrom(
    address _from,
    address _to,
    uint256 _value
) external returns (bool success);

function approve(address _spender, uint256 _value)
    external
    returns (bool success);

function allowance(address _owner, address _spender)
    external
    view
    returns (uint256 remaining);

event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(
    address indexed _owner,
    address indexed _spender,
    uint256 _value
);

}

contract MyFirstToken is ERC20 {
string public symbol = "MFT";
string public name = "My First Token";
uint8 public decimals = 18;
uint256 public override totalSupply;

address public founder;
mapping(address => uint256) private __balanceOf;
mapping(address => mapping(address => uint256)) private __allowances;

constructor() {
    totalSupply = 1000;
    founder = msg.sender;
    __balanceOf[founder] = totalSupply;
}

function balanceOf(address _addr)
    public
    view
    override
    returns (uint256 balance)
{
    return __balanceOf[_addr];
}

function transfer(address _to, uint256 _value)
    public
    override
    returns (bool success)
{
    if (_value > 0 && _value <= balanceOf(msg.sender)) {
        __balanceOf[msg.sender] -= _value;
        __balanceOf[_to] += _value;
        return true;
    }
    return false;
}

function transferFrom(
    address _from,
    address _to,
    uint256 _value
) public override returns (bool success) {
    if (
        __allowances[_from][_to] > 0 &&
        _value > 0 &&
        __allowances[_from][_to] >= _value &&
        __balanceOf[_from] >= _value
    ) {
        __balanceOf[_from] -= _value;
        __balanceOf[_to] += _value;
        // Missed from the video
        __allowances[_from][_to] -= _value;
        return true;
    }
    return false;
}

function approve(address _spender, uint256 _value)
    public
    override
    returns (bool success)
{
    require(__balanceOf[msg.sender] >= _value);
    require(_value > 0);
    __allowances[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
}

function allowance(address _owner, address _spender)
    public
    view
    override
    returns (uint256 remaining)
{
    return __allowances[_owner][_spender];
}

}
`

willitscale and others added 22 commits October 26, 2018 03:23
Resolved lint warnings for tutorial-09
```
browser/ballot.sol:5:5: TypeError: Function overload clash during conversion to external types for arguments.
    function transfer(address _to, uint _value, bytes _data) external returns (bool);
    ^-------------------------------------------------------------------------------^
```
Resolved lint warnings and transfer in tutorial-24
Made tutorial 15 compatible with the latest version of Solidity
Fixed tutorial 14 to work with the latest version of solidity
Fixed tutorial 16 for the latest version of Solidity
Made tutorial 1 work for the latest version of Solidity
Made tutorial 2 work with the latest version of Solidity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants