daniel1234567All UDFs copy
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
⌄
⌄
⌄
⌄
-- forked from 0xtableau / All UDFs @ https://flipsidecrypto.xyz/0xtableau/q/2023-04-06-10-15-pm-jYCHYp
-- hex to int
select
livequery.utils.udf_hex_to_int ('1E240')::int as int1,
livequery.utils.udf_hex_to_int ('0x1E240')::int as int2,
livequery.utils.udf_hex_to_int ('hex','0x1E240')::int as int3;
-- S2C
select
livequery.utils.udf_hex_to_int ('s2c','FFFE1DC0')::int as int1,
livequery.utils.udf_hex_to_int ('s2c','0xFFFE1DC0')::int as int2;
-- hex to string
select
livequery.utils.udf_hex_to_string('466C69707369646520726F636B73') as text1;
-- create block number request
SELECT
livequery.utils.udf_json_rpc_call('eth_blockNumber',[]) AS rpc_request;
-- create ETH call, from inputs
WITH inputs AS (
-- input function_sig, token_address, wallet_address
-- format data for eth call, should be 64 chars long (32 bytes) + 10 chars for function sig (including 0x)
SELECT
LOWER('0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84') AS token_address,
-- stETH
LOWER('0x66B870dDf78c975af5Cd8EDC6De25eca81791DE1') AS wallet_address,
--a16Z
'0x70a08231' AS function_sig,
--balanceOf(address)
CONCAT(
function_sig,
LPAD(REPLACE(wallet_address, '0x', ''), 64, 0)
) AS DATA
) -- creates a formatted json rpc eth_call request that is ready to be sent to a node
SELECT
livequery.utils.udf_json_rpc_call(
Run a query to Download Data