Skip to content

Instantly share code, notes, and snippets.

@hammeiam
Created August 14, 2022 03:05
Show Gist options
  • Save hammeiam/bc953563b280f85b3b6ad7f57c3b980c to your computer and use it in GitHub Desktop.
Save hammeiam/bc953563b280f85b3b6ad7f57c3b980c to your computer and use it in GitHub Desktop.
Running list of helpful JQ scripts

Merkle tree to address: amount map

Select the key containing merkle proofs and amounts. to_entries[] returns objects on new lines instead of in an array, so wrap the statement in [()] to make it an array again. For each entry, map the amount to the address key. Merge back in to one big object with add.

jq '.recipients | [(to_entries[] | {(.key): .value.amount})] | add' results.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment