Skip to content

Commit

Permalink
Merge pull request #268 from MoralisWeb3/update-eth-call
Browse files Browse the repository at this point in the history
Update eth call and logs
  • Loading branch information
Nazeim authored Sep 27, 2023
2 parents 41d4b55 + 4ff9136 commit 64d841f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/01-web3-data-api/evm/blockchain-api/01-Get Blocks/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ Furthermore, this article also showcases how Moralis simplifies and streamlines
You can learn how to get a block by number using the Moralis Events API by following the [Get logs for contract](/web3-data-api/evm/how-to-get-block-content-by-block-number) article.
:::

## Understanding eth_call and eth_getBalance

### Exploring eth_call

While exploring contract interactions and blockchain data retrieval, it is important for DApp developers to use the `eth_call` method to simulate and execute message calls directly in the node’s Virtual Machine (VM), without making any modifications and without creating a transaction to the blockchain. This read-only interaction capability is quintessential for querying smart contract functions, such as retrieving ERC-20 token balances with the `balanceOf` function.

Moralis offers a groundbreaking equivalent for `eth_call` with the [getBlock](/web3-data-api/evm/reference/get-block) RPC method, showcasing its innovative approach to data retrieval and blockchain interactions. This endpoint serves as a modern alternative, allowing developers to access extensive information about transactions, contract interactions, and more, all in a user-friendly manner.

### Exploring eth_getBalance

Developers use `eth_getBalance` to get the Ether balance of a given address or in other words to return account's balance of a given address. This method is a fundamental aspect for managing transactions and displaying real-time user balance information.

Moralis presents the [getNativeBalance](/web3-data-api/evm/reference/get-native-balance) RPC method as the nearest equivalent to `eth_getBalance`. You can use it to obtain the native balance of an address which can be an important part in transaction management.


## Traditional vs. Modern: A Quick Comparison

Historically, developers have used Ethereum's `eth_call` RPC method to interact with contracts without modifying the blockchain state. Here is an example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ For a step-by-step tutorial on obtaining contract logs using the Moralis Events

## The Gateway to Ethereum Events with eth_getLogs

The `eth_getLogs` is a JSON-RPC method in Ethereum that returns event data as an array of all logs matching a specified filter object. It is a fundamental method for querying and retrieving event logs from the Ethereum blockchain.

The utilization of `eth_getLogs` plays a vital role in the blockchain industry as it empowers developers with a valuable tool to monitor and analyze events occurring on the Ethereum blockchain. Throughout this guide, we will delve into the functions and benefits of this tool and look at the advantages of using Moralis instead.

Also, transaction receipts serve as repositories for Ethereum event logs, capturing details such as gas consumption, transaction status, and more. Understanding storage dynamics allows us to efficiently retrieve this information using methods like `eth_getLogs` along with other alternatives.
Expand Down

1 comment on commit 64d841f

@vercel
Copy link

@vercel vercel bot commented on 64d841f Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.