I've seen some contracts like here (e.g. in line 332), use "sendTransaction" when they call contract's function. Cannot we call a function without using "sendTransaction"? As I've been calling functions without using it (on testrpc and private chain) and it works fine.

Question 1: Do we have to use "sendTransaction" when we call a contract function?

Question 2: When should we use "sendTransaction"?

  • this question may help you. – Achala Dissanayake Sep 22 '17 at 11:45
  • It should not be necessary for a non consant function contract.method(params) is equivalente to contract.method.sendTransaction(params). And for a constant function contract.method(params) is equivalente to contract.method.callparams). I remember some version failed to recognize properly a function as constant so I've to force contract.method.call(params). – Ismael Sep 23 '17 at 6:04

There are multiple ways you can interact with smart contract depending on what you want to accomplish. Here you can find detailed explanation on what does what What is the difference between a transaction and a call?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.