1
pragma solidity v^0.4.0;

contract Goldbar 
{
  address public creator;
  mapping (address=>uint)  public balance ;

  function Goldbar()
  {
      creator = msg.sender;
  }
//  if(creator.balance  <10)creator.transfer(1);
  event delivered(addressfrom, address to, uint amount) /// by using this function we can track the transfered funds.
//  function transfer(address reciver ,uint amount)

function transfer(address receiver,uint amount)
{
    if(balance[msg.sender] <amount)throw ;
    balance[msg.sender]  -=amount;
    balance[msg.reciver] +=amount;
    delivered(msg.sender,receiver,amount);
}


}

While compiling I got a error:

browser/Goldbars.sol:16:1: ParserError: Expected ';' but got 'function'
function transfer(address receiver,uint amount)
^------^
1
  • You seem to be missing a ';' somewhere between the end of your event command and the start of the function :p – Vignesh Karthikeyan May 31 '18 at 17:38
0

You need a semicolon at the end of the transfer function as well as after "...address to, uint amount)".

if(creator.balance  <10)creator.transfer(1);
  event delivered(address from, address to, uint amount);
function transfer(address reciever ,uint amount);
0

You just need to put a semicolon at the end of your event declaration

event delivered(address from, address to, uint amount);

Also you need to add a space between "address" and "from" in the same event in your code. At the moment it is addressfrom as one word which throws an error.

2
  • Thanks for your info. I have one more compilation error . TypeError: Member "receiver" not found or not visible after argument-dependent lookup in msg balance[msg.receiver] +=amount; ^----------^ – Ramya Sai Jun 1 '18 at 14:40
  • Wouldn't it just be balance[receiver] instead of balance[msg.receiver]? – machine-uprising Jun 1 '18 at 14:50

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.