pragma :rubidity, "1.0.0" contract :ERC20, abstract: true do event :Transfer, { from: :address, to: :address, amount: :uint256 } event :Approval, { owner: :address, spender: :address, amount: :uint256 } string :public, :name string :public, :symbol uint8 :public, :decimals uint256 :public, :totalSupply mapping ({ address: :uint256 }), :public, :balanceOf mapping ({ address: mapping(address: :uint256) }), :public, :allowance constructor(name: :string, symbol: :string, decimals: :uint8) { s.name = name s.symbol = symbol s.decimals = decimals } function :approve, { spender: :address, amount: :uint256 }, :public, :virtual, returns: :bool do s.allowance[msg.sender][spender] = amount emit :Approval, owner: msg.sender, spender: spender, amount: amount return true end function :transfer, { to: :address, amount: :uint256 }, :public, :virtual, returns: :bool do require(s.balanceOf[msg.sender] >= amount, "Insufficient balance") s.balanceOf[msg.sender] -= amount s.balanceOf[to] += amount emit :Transfer, from: msg.sender, to: to, amount: amount return true end function :transferFrom, { from: :address, to: :address, amount: :uint256 }, :public, :virtual, returns: :bool do allowed = s.allowance[from][msg.sender] require(s.balanceOf[from] >= amount, "Insufficient balance") require(allowed >= amount, "Insufficient allowance") s.allowance[from][msg.sender] = allowed - amount s.balanceOf[from] -= amount s.balanceOf[to] += amount emit :Transfer, from: from, to: to, amount: amount return true end function :_mint, { to: :address, amount: :uint256 }, :internal, :virtual do s.totalSupply += amount s.balanceOf[to] += amount emit :Transfer, from: address(0), to: to, amount: amount end function :_burn, { from: :address, amount: :uint256 }, :internal, :virtual do require(s.balanceOf[from] >= amount, "Insufficient balance") s.balanceOf[from] -= amount s.totalSupply -= amount emit :Transfer, from: from, to: address(0), amount: amount end end