-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BigQuery AutoFormatter
committed
Feb 11, 2021
1 parent
7dc65c7
commit 92bbeb5
Showing
2 changed files
with
48 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
select t.*, b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data | ||
from ethereum.transactions t | ||
join ethereum.blocks b | ||
on t.block_hash = b.hash | ||
where t.gas_price = 0 | ||
and t.block_time >= '2021-01-01' | ||
SELECT | ||
t.*, | ||
b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data | ||
FROM | ||
ethereum.transactions AS t | ||
JOIN | ||
ethereum.blocks AS b | ||
ON t.block_hash = b.`hash` | ||
WHERE | ||
t.gas_price = 0 AND t.block_time >= '2021-01-01'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
SELECT address, time, sum(amount/ 1e18) over(order by time) | ||
FROM ( | ||
|
||
-- outbound transfers | ||
SELECT "from" AS address, -tr.value AS amount , date_trunc('day', block_time) as time | ||
FROM ethereum.traces tr | ||
WHERE "from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' | ||
AND success | ||
AND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null) | ||
AND block_time > '2021-01-04'AND block_time < '2021-02-07' | ||
|
||
|
||
UNION ALL | ||
|
||
-- inbound transfers | ||
SELECT "to" AS address, value AS amount ,date_trunc('day', block_time) as time | ||
FROM ethereum.traces | ||
WHERE "to" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' | ||
AND success | ||
AND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null) | ||
AND block_time > '2021-01-04' AND block_time < '2021-02-07' | ||
|
||
UNION ALL | ||
|
||
-- gas costs | ||
SELECT "from" AS address, -gas_used * gas_price AS amount, date_trunc('day', block_time) as time | ||
FROM ethereum.transactions | ||
WHERE "from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' | ||
AND block_time > '2021-01-04'AND block_time < '2021-02-07' | ||
|
||
) as t | ||
SELECT | ||
address, | ||
time, | ||
sum(amount / 1e18) OVER ( | ||
ORDER BY time) | ||
FROM | ||
-- outbound transfers | ||
( | ||
SELECT | ||
"from" AS address, | ||
- tr.value AS amount, | ||
date_trunc('day', block_time) AS time | ||
FROM | ||
ethereum.traces AS tr | ||
WHERE | ||
"from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND success AND (call_type NOT IN ('delegatecall', | ||
'callcode', 'staticcall') OR call_type IS null) AND block_time > '2021-01-04' AND block_time < '2021-02-07' | ||
UNION ALL -- inbound transfers | ||
SELECT | ||
"to" AS address, | ||
value AS amount, | ||
date_trunc('day', block_time) AS time | ||
FROM | ||
ethereum.traces | ||
WHERE | ||
"to" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND success AND (call_type NOT IN ('delegatecall', | ||
'callcode', 'staticcall') OR call_type IS null) AND block_time > '2021-01-04' AND block_time < '2021-02-07' | ||
UNION ALL -- gas costs | ||
SELECT | ||
"from" AS address, | ||
- gas_used * gas_price AS amount, | ||
date_trunc('day', block_time) AS time | ||
FROM | ||
ethereum.transactions | ||
WHERE | ||
"from" = '\x713E11c146911B2cBa7df18b89BFfaa64F2c9D24' AND block_time > '2021-01-04' AND block_time < | ||
'2021-02-07' | ||
) AS t; |