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 Answer 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?
  • Thanks. Also, how should I determine the address of vote master? Is that just an IP address? (so 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. Commented Apr 19, 2017 at 0:00
  • This example may help you: solidity.readthedocs.io/en/develop/… 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
    Commented Apr 19, 2017 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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