Prepare for the Blockchain Developer Certification. Master blockchain concepts with flashcards and multiple choice questions. Explanation-based learning for your success!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What is the primary difference between calling a function and sending a transaction to a function?

  1. Both modify the contract's data

  2. Calling is free and instant; sending costs money and takes time

  3. Calling returns the transaction ID while sending does not

  4. Sending can only be done by the contract owner

The correct answer is: Calling is free and instant; sending costs money and takes time

The primary difference between calling a function and sending a transaction to a function lies in the nature of the operations and their implications on the blockchain. When you call a function, this is typically a local operation that doesn't require any alteration of the blockchain state. It is instantaneous and incurs no gas costs. This means that the function can be executed by anyone without needing to pay for it, and the result can be returned immediately. On the other hand, sending a transaction is a more significant action because it involves altering the state of the blockchain. This requires processing by the network, incurs gas fees, and can take time to be confirmed. When you send a transaction, you're registering a change in the blockchain, such as updating contract state or transferring tokens, which necessitates the consensus of the network and thus introduces both cost and latency. This distinction is crucial for understanding how interactions with blockchain contracts function and how developers should architect their applications to either utilize read-only calls or state-changing transactions accordingly.