I am trying to understand the test provided at:


("Test balance after deposit", function() {
        return SimpleBank.deployed().then(function(instance) {
            sb = instance;
            return sb.deposit({ from: accounts[0], value: web3.utils.toWei('10', 'ether') });

The smart contract code is given below:

contract SimpleBank{
   uint public transactions;
   mapping (address=>uint) balances;
   function deposit() public payable{
      balances [msg.sender] +=msg.value;

The test invokes :

sb.deposit({ from: account[0], value:  web3.utils.toWei('10', 'ether') });

To which account the ‘10’ ether is going from account[0]? What is the purpose of 'transactions' state variable?

1 Answer 1


The 10 Ethers goes to the contract SimpleBank and stays there. In the deposit function the contract sets some additional data which marks who sent how much Ethers, but this is only contract's internal book-keeping and doest't move any Ethers anywhere.

As for the transactions variable, it probably just shows how to use a state variable. It doesn't have any real benefit, it's just an example. As is all of the contract - just an example for reference purposes.

  • how can we check the balance of SimpleBank?
    – zak100
    Commented Jan 20, 2021 at 18:08

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.