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?

  • Have you tried: MyContract.MyMethod.call({from: accounts[1]});? Assuming you already have your accounts array. – Roman Frolov Jan 25 '18 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. – Himanshu Chandra Jan 26 '18 at 5:49
  • Glad to hear it! – Roman Frolov Jan 26 '18 at 8:06
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, privacy policy and cookie policy

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