with main_table as (
select
t1.block_timestamp,
t1.tx_id,
t1.attribute_value as from_network,
t2.attribute_value as from_address,
t3.attribute_value as to_network,
t4.attribute_value as to_address
from axelar.core.fact_msg_attributes t1
join axelar.core.fact_msg_attributes t4
join axelar.core.fact_msg_attributes t2
join axelar.core.fact_msg_attributes t3
on t1.tx_id = t2.tx_id
and t1.tx_id = t3.tx_id
and t1.tx_id = t4.tx_id
where 1 = 1
and t1.attribute_key = 'sourceChain'
and t2.attribute_key = 'sender'
and t3.attribute_key = 'destinationChain'
and t4.attribute_key = 'destinationAddress'
and t1.tx_succeeded = 1
)
select
from_network "Network",
count(distinct tx_id) "Transaction CNT",
count(distinct from_address) "Unique From Addresses",
count(distinct to_address) "Unique To Address"
from main_table
where block_timestamp::date >= '{{ date }}'
group by 1