The scenario is: I am executing my contract from remix which is connected to my blockchain and I am able to execute functions from both geth console (by creating a contract instance using abi and address) as well as from the remix UI.
Now I try to do the same using a javascript file so that I can have a UI for it. So I create a js file, include web3 library to it and connect it to my blockchain. Till here, I am able to work successfully. On executing document.write(web3.eth.getBalance(web3.eth.accounts[0])
I get the correct balance. But when I try to execute contractInstance.deposit(web3.eth.accounts[0], 10000)
(deposit is a method in my contract which takes two parameters, account address and amount) it throws an invalid address error. However, I am able to execute the same line of code from the geth console.
I guess I am making some silly mistake.
PS: I've tried contractInstance.deposit(web3.eth.accounts[0], 10000).call()
and contractInstance.deposit(web3.eth.accounts[0], 10000).call
but still it throws the same error.
This is the JS file. (apart from get()
method, rest everything is working fine).
Output from the browser (note that the js file is able to print address and balance to the browser's console).