I've noticed that the deploying address in my truffle .js tests is equal to the address at accounts[0].

Since it's important to me to test the ownership of a contract, I'd like to know if it's guaranteed that contacts deployed by accounts[0] in the test suite.

1 Answer 1


Yes, that is the case. accounts[0] is the default. If you like to test calling a function from another account, you can pass {from: accounts[1]} as the last parameter of your function. If you would have a function like this:


It would look like this:

MyContract.getBalance.call(address, {from: accounts[1]});

You can get your accounts in truffle console with:

var accounts = web3.eth.accounts;

I hope that helps.

  • Thanks! The answer would be even better if you'd change to MyContract.getBalance.call(address); May 10, 2017 at 12:28

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.