Last active
April 29, 2022 17:26
-
-
Save jaybuidl/a393cd5fb3303de86b9ebb50b146a865 to your computer and use it in GitHub Desktop.
Get information about an Ethereum contract address from Kleros Curate
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
#!/bin/bash | |
if [[ ! "$1" ]] | |
then | |
echo "Usage: $(basename $0) [address]" | |
exit 1 | |
fi | |
address=$1 | |
function getTokenMainnet() { | |
local address=$1 | |
curl -X POST -s -d '{ "query": "{ litems( where: {registry: \"0x6e31d83b0c696f7d57241d3dffd0f2b628d14c67\", status: Registered, keywords_contains: \"'$address'\"} ) { keywords data } }"}' https://api.thegraph.com/subgraphs/name/kleros/curate | jq -r .data.litems[].data | |
} | |
function getTagXdai() { | |
local address=$1 | |
curl -X POST -s -d '{ "query": "{ litems( where: {registry: \"0x76944a2678a0954a610096ee78e8ceb8d46d5922\", status: Registered, keywords_contains: \"'$address'\"} ) { keywords data } }"}' https://api.thegraph.com/subgraphs/name/eccentricexit/curate-xdai-ii | jq -r .data.litems[].data | |
} | |
output='{}' | |
ipfs=$(getTokenMainnet $address) | |
if [[ "$ipfs" != "" ]] | |
then | |
output="$output { \"tokenMainnet\": $(curl -s https://ipfs.kleros.io/$ipfs | jq .values) }" | |
fi | |
ipfs=$(getTagXdai $address) | |
if [[ "$ipfs" != "" ]] | |
then | |
output="$output { \"tagXdai\": $(curl -s https://ipfs.kleros.io/$ipfs | jq .values) }" | |
fi | |
echo "$output" | jq -s add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment