How to call functions with another account?

I am new,maybe my problem is very simple.
In ganache,there are 10 accounts,
The system will interact with the contract by default using the first account.
I write some functions and want to test them.
How can i use others accounts?
thank you
:computer: Environment

:memo:Details

:1234: Code to reproduce

1 Like

Hi @wangyuyue,

In our tests we can specify the from account. Which is the account that will send the transaction.

await this.contract.store(42, { from: owner });

For an example test see the Learn guides documentation:
https://docs.openzeppelin.com/learn/writing-automated-tests#writing-unit-tests

If you get stuck, feel free to share your test and what testing environment you are using (e.g. Truffle Test, OpenZeppelin Test Environment etc)

I see , Thank you for your help :grinning:

1 Like

Hi @wangyuyue,

I hope that answered your question, if not, let me know what testing environment you are using and I can dig out an example of how to set the account.

A post was split to a new topic: Error installing @openzeppelin/test-environment