1

I am very new to Ethereum and don't really understand the problem spec very well, so bear with me.

There is a function named GetVotesCount() in the contract MordorVote which I must limit to only being called by a 'vote master'. How can I determine who is calling a function in the contract?

Also, when I invoke a function in Embark, I get a hex string returned, but not whatever the function returns. How can I find out what a function is returning?

1 Answers1

1
  1. msg.sender will have the address of the caller. In your function you can do if (msg.sender != addressOfVoteMaster) throw;.

See also: What's the difference between 'msg.sender' and 'tx.origin'?

  1. You get a hex string, which is the transaction hash. Depending on the type of function, you could make it constant to get the function's return value. See What is the difference between a transaction and a call?
eth
  • 85,679
  • 53
  • 285
  • 406
  • Thanks.

    Also, how should I determine the address of vote master? Is that just an IP address? (so 127.0.0.1?)

    Unrelated to this question, but I cannot post another question; do you know how I can increase my gas? I am trying to test a contract given to me, but I can no longer call some functions due to being out of gas.

    – Daniel Paczuski Bak Apr 19 '17 at 00:00
  • This example may help you: https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html#subcurrency-example Like it, the simplest might be to have the vote master be the one to deploy the contract. To increase the gas, in the transaction object add a gas property like: {from: ..., gas: 1000000}. As a new user, you may need to give some time between asking questions. We'll have to continue there. Also, the 2 questions here aren't related so should be asked separately in the future. – eth Apr 19 '17 at 00:38