I'm a new to Ethereum and Solidity, and I don't understand how Truffle executes transaction calls.

From what I learned and understood, if I try to use a contract method which changes the contract's state(changes any values), this means I(sender) have to make a transaction to that contract. In this way, I need my account's data, such as private key, or this stuffs are done by Metamask.

But I don't see any signing or verification process in the test code provided by Truffle docs. In it block, just execute any contract's method, and we can see the changes.

Does this mean Truffle internally addresses the verification stuff, as this is test environment provided by itself? I don't get how Truffle test handle transactions. Can somebody explain what is going on inside the box? Or maybe I'm missing some of the concepts.

Thank you for advance for your explanations.

  • are you using Ganache to test?
    – Majd TL
    Commented Jul 13, 2019 at 9:38
  • @MajdTL That's right. All default settings.
    – cadenzah
    Commented Jul 14, 2019 at 3:25
  • the accounts in Ganache are not locked, so the request can sign the transaction with the public key
    – Majd TL
    Commented Jul 14, 2019 at 9:37
  • @MajdTL Oh that is interesting. So there is no need to provide the private key to sign...
    – cadenzah
    Commented Jul 15, 2019 at 5:09
  • no sorry i worte public key instead of private key...., anyway there is an option in Ganache where you can lock all accounts
    – Majd TL
    Commented Jul 15, 2019 at 8:45

1 Answer 1


Truffle test by default uses ganache which is a local blockchain running inside your computer.

When you start Ganache CLI, it will automatically create 10 accounts associated with 10 private keys. Each account has 100 ethers for testing purpose.

When you send a transaction that modifies blockchain data or you just transfer ether, truffle test already has access to the private keys provided so it doesn't need you to make an extra step.

Hope I was clear!

  • So does this mean even if I write test scripts for contracts and they all passes, when it comes to using it in the real situation, there has to be explicit processes related to signing and verifications - either by using Metamask or something else?
    – cadenzah
    Commented Jul 15, 2019 at 5:12
  • @cadenzah Exactly! Though truffle test is mainly used to test the contract within a local blockchain Commented Jul 15, 2019 at 18:58
  • Thx for your explanation
    – cadenzah
    Commented Jul 16, 2019 at 6:44
  • hi there! Do you know what's the best way to also sign messages with web3 from within a truffle test? web3.eth.accounts.sign requires a privateKey
    – G.G.
    Commented Jan 11, 2022 at 22:01

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.