Last active
June 1, 2020 12:58
-
-
Save rhlsthrm/264c487670f4752ffa3875c4b62ed902 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- GET NODE FREE BALANCE ACROSS ALL CHANNELS FOR TOKEN | |
SELECT ("latestState" #> '{balances}' -> ( | |
SELECT array_position( | |
array( | |
SELECT jsonb_array_elements_text("latestState" #> '{tokenAddresses}')), | |
'0xEcFcaB0A285d3380E488A39B4BB21e777f8A4EaC' -- TOKEN ADDRESS | |
)::integer - 1 | |
) #> '{0,amount,_hex}') | |
FROM channel INNER JOIN app_instance | |
ON app_instance."channelMultisigAddress" = channel."multisigAddress" | |
WHERE app_instance.type = 'FREE_BALANCE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment