1

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"?

2
  • this question may help you. Commented Sep 22, 2017 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
    Commented Sep 23, 2017 at 6:04

1 Answer 1

4

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?

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.