# Transaction vs Call

There are two ways we can invoke functions.

1. Call
2. Send a transaction (data modification)

![](https://1628544884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTgomzlmn9NrxUY0OQ3cD%2Fuploads%2Flp8PfP2p73DMRdcQcsWm%2Fimage.png?alt=media\&token=b1168d74-3e3a-421b-9622-2e03be8c3de9)

{% hint style="info" %}
A transaction is necessary, if a value in a Smart Contract needs to be updated (state change).&#x20;

A call is done, if a value is read.&#x20;

Transactions cost Ether (gas), need to be mined and therefore take a while until the value is reflected, which you will see later. Calls are virtually free and instant.
{% endhint %}

![transaction followed by call](https://1628544884-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTgomzlmn9NrxUY0OQ3cD%2Fuploads%2FyNAwT047TE2KzBajKuxS%2Fimage.png?alt=media\&token=f5ac56ad-8dc3-42d8-8c1e-92c9dc5d0fc7)

### Sending a transaction to a function

Anytime we send a transaction to the network it takes time to be process (it must be confirmed by other nodes and mined).

When we send a transaction to a function, we are returned a transaction hash that identifies the transaction.&#x20;

* We do not get a return value back, even if the function has a return component in it.
* Costs money.

### Transactions

Transactions always start with an externally owned account signing a transaction and submitting it to the network. The returned value is a transaction receipt.&#x20;

The outcome of the transaction is ***unknown*** because nothing has happened yet except that a ***request*** has been submitted to the network for verification ***in the future***.

A typical approach to coping with this fact of life is to wait for the transaction to be mined, then inspect the transaction log for useful output, inspect the success/fail status and draw your own conclusions, or inspect a read-only function to discover the new state after the transaction was mined.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://calnix.gitbook.io/eth-dev/compendium/solidity-basics/functions/transaction-vs-call.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
