Steve Nouri
HI Team,
 
I have used the following program. The initial supply is updating properly in the remix etherium IDE, where as the transfer amounts are not updating in the beneficiary accounts. Is the program in the course outdated. Or anything is missing here. Please advise.
 
**** Remix IDE Screenshot ***
 
image.png
 
*** Program Used ***
 
pragma solidity ^0.5.10;

contract MyToken {
    mapping(address => uint256) private _balances;
   
    string private _name;
    string private _symbol;
    uint8 private _decimals;
    uint256 private _totalSupply;
   
    constructor(uint256 initialSupply, string memory tokenName, string memory tokenSymbol, uint8 decimalUnits) public {
        _balances[msg.sender] = initialSupply;
        _totalSupply = initialSupply;
        _decimals = decimalUnits;
        _symbol = tokenSymbol;
        _name = tokenName;
    }
   
    function name() public view returns (string memory) {
        return _name;
    }
   
    function symbol() public view returns (string memory) {
        return _symbol;
    }
   
    function decimals() public view returns (uint8) {
        return _decimals;
    }
   
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }
   
    function setTotalSupply(uint256 totalAmount) internal {
        _totalSupply = totalAmount;
    }
   
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }
   
    function setBalance(address account, uint256 balance) internal {
        _balances[account] = balance;
    }
   
    function transfer(address beneficiary, uint256 amount) public returns(bool) {
        require(beneficiary != address(0),"Beneficiary address cannot be zero");
        require(_balances[msg.sender] >= amount, "Sender does not have enough balance.");
        require(_balances[beneficiary] + amount > _balances[beneficiary],"Additional overflow");
        _balances[msg.sender] -= amount;
        _balances[beneficiary] += amount;
        return true;
    }
   
}
 
Reply 0 0
Gurmeet Chauhan gurmeetchauhan
Hi Steve, have you used the same version while deploying the smart contract. I would also suggest using payable functions as it is mandatory as per the new standards.
 

Best Regards,

Gurmeet (Team- Blockchain Council)

Reply 0 0
Steve Nouri
Hi Gurmeet,
 
I have followed the lecture and wrote the code accordingly. Is there any git url for the lecture code? The full version of code when I execute it is saying insufficient balance. If any updated code I can get please provide the same.
 
Thank you
Reply 0 0
Gurmeet Chauhan gurmeetchauhan
Hey Steve, Please refer to this GitHub link - https://github.com/blockchain-council/Certified-Blockchain-Developer

Best Regards,

Gurmeet (Team- Blockchain Council)

Reply 0 0
Reply