💡General EVM Node Queries
Make any RPC call to an EVM Node using LiveQuery
In the following examples, we will use the available EVM primitives to make calls directly to an EVM blockchain node. We will use Ethereum Mainnet here, but the same queries will work on any LiveQuery supported chain and network because they use generic EVM RPC methods.
We will start small by getting the latest block for Ethereum Mainnet.
If you'd like to follow along in your own Flipside Studio Account please make sure you've added the QuickNode integration to your account. QuickNode instructions here.
Additionally, please see QuickNode for API credit usage per method. You are unlikely to run into credit issues using these functions, unless you are programmatically accessing the data frequently.
Latest Block
Using the udf_rpc
function, we can easily make a eth_blockNumber
call to our ethereum_mainnet
node. This method does not require parameters, so we will just pass a null variant as our parameters. This will return in hexadecimal format, so we will need to apply utils.udf_hex_to_int
to make it human-readable.
Transactions for a Block
In this example, we will pull the transaction details for a specific block. There are lots of available RPC methods, but here we will use eth_getBlockByNumber
. In order to return the details of the transactions within the block, we will also need to pass the transaction detail flag
parameter as true
alongside our hex block number.
This returns a large JSON Object, filled with arrays. This block contains 102 transactions, so we'd expect 102 items in our transactions array. We could also flatten this our to look at the details for each transaction. We won't do that here, but if you wanted to, you'd need to use lateral flatten
. Lets just look at the block details and count the transactions using array_size()
.
Logs for a Contract in a Range
Here we will use udf_rpc_eth_get_logs
to get the emitted event logs for a contract. We will use the USDC contract starting at block 17 million for 100 blocks. We'll have to flatten the result and pull out the relevant columns. This method uses eth_getLogs
which does have limitations on large ranges. The toBlock
parameter can also be latest, if you are interested in real-time logs.
Balances for an Address
LiveQuery provides a number of ways to pull balances for an address. In this example, we will use udf_rpc_eth_get_balance
and udf_get_token_balance
. Lets find the top 10 trades on Uniswapv3 this week, and look at the ETH balance and the token balance the wallet swapped for.
We could also look at their balance on block after the swap but giving the functions that block number in hex, like so.
Last updated