0

I am using embark to deploy my contracts.What I need is to call a contract function from a different account rather than account[0] generated by testrpc. i.e. msg.sender should contain the address of account[1] or account[2] or account[n] where n is less than the number of accounts generated. There should be a way to do so for manual testing purposes in embark console right?

3
  • Have you tried: MyContract.MyMethod.call({from: accounts[1]});? Assuming you already have your accounts array. Jan 25, 2018 at 20:24
  • @RomanFrolov Thanks it worked! I just had to use MyContract.MyMethod({from:web3.eth.accounts[1]}) and it also worked by passing address directly. If you copy this in the answer I will accept it as right. Jan 26, 2018 at 5:49
  • Glad to hear it! Jan 26, 2018 at 8:06

1 Answer 1

0

This should work:

MyContract.MyMethod({ from: accounts[1] });

Assuming you already have your accounts array:

var accounts = web3.eth.accounts;

Your Answer

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

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