0

I have set up a basic project (the code isn't relevant, but you can see it here if need be).

In the project there is a Token and a "bank". I also have a series of tests. I'm mocking functionality using Ganache, and noticed that whenever I run my test suite Ganache will run one transaction per test on one address, and then once per suite on another address. I assume one address has been designated as "user account" (or Token? I'm not really sure) and one as "bank". I haven't indicated anywhere which addresses to use. I haven't even explicitly instructed my code to use Ganache anywhere.

How does truffle/ganache decide which addresses to use? I'm confused how those addresses would be assigned in a real world application without explicitly pointing them out (albeit dynamically) in my code.

1 Answer 1

0

When you call a contract method using Truffle's contract abstraction, you can always pass an extra parameter to specify some details of the transaction that will be sent, such as the from address.

You do this in your tests. For example, when you say:

await token.passMinterRole(dbank.address, { from: deployer });

the passMinterRole contract method only accepts one parameter, address dBank. The extra object specifies the from address of the transaction that will be sent, which you have set to deployer.

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.