What is a call?
- Invoking a smart contract function without broadcasting to the network.
- It does not change any blockchain or contract state.
- Read only operation.
- Since it is read only operation it does not need any gas.
What is a transaction?
- Transaction is something that is broadcasted to the entire network.
- It changes the state of blockchain or contract.
- It is a write operation so; it requires signing from user wallet. That's why whenever we do a transaction, we need to sign the transaction in order make the payment successful.
- Transaction can not be done without private key.
- Needs gas and these gases are paid in native tokens like ETH for Ethereum, SOL for Solana, MATIC for polygon.
When to use either of them?
If we want to read data, then we need to use call.
For Example,
If we want to check the balance of the contract then we use call.
If we want to write data, then we need to use transaction.
For Example,
If we want to transfer a token or send an ETH from one contract to another, then we need to use Transaction.