0

This Is My First ERC20 Smart Contract Token. I Am Trying To Compile It Using Solidity 0.5.0. Plz Need Your Help Guys.

pragma solidity ^0.5.0;

    contract TusharCoin {

  uint256 public totalSupply;  
  string public name;  
  string public symbol;  
  uint32 public decimals; 

    constructor () public {
  symbol  = "TUSHAR";  
  name = "TusharCoin";  
  decimals = 5;  
  totalSupply = 100000000000;
    }

    constructor() public { 
  owner = msg.sender;  
  balances[msg.sender] = totalSupply;
    }
    emit Transfer(0x0, msg.sender, totalSupply);  
 }

Error- Function, Variable, Struct Or Modifier Declaration Expected. 

emit Transfer(0x0, msg.sender, totalSupply); 
^--^
1

This should implement the functionality you tried to implement in the question

pragma solidity ^0.5.0;

contract TusharCoin {

  uint256 public totalSupply;  
  string public name;  
  string public symbol;  
  uint32 public decimals;
  address public owner;

  mapping(address => uint256 ) balances;

  event Transfer(address to, uint256 amount);

  constructor () public {
    symbol  = "TUSHAR";  
    name = "TusharCoin";  
    decimals = 5;  
    totalSupply = 100000000000;
    owner = msg.sender;  
    balances[msg.sender] = totalSupply;
    emit Transfer(msg.sender, totalSupply);
    }
 }

But to implement an ERC20 token, you have to implement all the functions described in the interface standard. You can have a look at openzeppelin implementation here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.