Skip to content

Instantly share code, notes, and snippets.

@crimeminister
Last active November 30, 2023 05:41
Show Gist options
  • Save crimeminister/5e8004b923deef1fdcc0de7a814a190d to your computer and use it in GitHub Desktop.
Save crimeminister/5e8004b923deef1fdcc0de7a814a190d to your computer and use it in GitHub Desktop.
Fetch and pin Pokemon data via IPFS (using estuary.tech)
{
"Pinning": {
"RemoteServices": {
"pinata": {
"API": {
"Endpoint": "https://api.pinata.cloud/psa",
"Key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiJlNGY4ZTI0NS04ZDU2LTQ2NjktYTliNC05MjIwOGQzYzc3MWEiLCJlbWFpbCI6InJvYmVydEBjcmltZW1pbmlzdGVyLm9yZyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJwaW5fcG9saWN5Ijp7InJlZ2lvbnMiOlt7ImlkIjoiTllDMSIsImRlc2lyZWRSZXBsaWNhdGlvbkNvdW50IjoxfV0sInZlcnNpb24iOjF9LCJtZmFfZW5hYmxlZCI6ZmFsc2V9LCJhdXRoZW50aWNhdGlvblR5cGUiOiJzY29wZWRLZXkiLCJzY29wZWRLZXlLZXkiOiI5NDc5ODU1YWYxYTAwMjJjNGMwMyIsInNjb3BlZEtleVNlY3JldCI6Ijk5MTIxN2Y1MjEyZWM1YjgzNmI2MmI0YjhiMWQ0ZjJhMTI2NTk5ZWQwMTM2NTdiZjNkMzZlNjQ2MTA4OWE2MDMiLCJpYXQiOjE2MzExMzIzODh9.BLNp06PT7kt7V6uBfc4gi_1cK4aJ4LRnnvduYHrpfHo"
},
"Policies": {
"MFS": {
"Enable": false,
"PinName": "",
"RepinInterval": ""
}
}
}
}
}
}
{
"Peering": {
"Peers": [
{
"ID": "12D3KooWN8vAoGd6eurUSidcpLYguQiGZwt4eVgDvbgaS7kiGTup",
"Addrs": [
"/ip4/3.134.223.177/udp/6746/quic"
]
},
{
"ID": "12D3KooWGBWx9gyUFTVQcKMTenQMSyE2ad9m7c9fpjS4NMjoDien",
"Addrs": [
"/ip4/147.75.49.71/udp/6746/quic",
"/ip4/147.75.49.71/tcp/6745"
]
},
{
"ID": "12D3KooWFrnuj5o3tx4fGD2ZVJRyDqTdzGnU3XYXmBbWbc8Hs8Nd",
"Addrs": [
"/ip4/147.75.86.255/udp/6746/quic",
"/ip4/147.75.86.255/tcp/6745"
]
},
{
"ID": "12D3KooWNNuTcH39tagS4MyddgQP7jBNSHJn4cVuTKuY4bjNZ6cw",
"Addrs": [
"/ip4/212.6.53.9/udp/6746/quic",
"/ip4/212.6.53.9/tcp/6745"
]
}
]
}
}
#!/bin/bash
# TODO automate the retrieval of peer IDs for remote pinning services:
# - estuary.tech
# - web3.storage
# - pinata
swarm_connect () {
peer_id="$1"
# We call the "findpeer" command as this appears to cache the result,
# making a subsequent "swarm connect" succeed when it otherwise might
# not.
peers=$(ipfs dht findpeer "${peer_id}")
multiaddrs=($(echo "$peers" | tr " " "\n"))
# Connect with each of the peers represented by the peer ID.
for multiaddr in "${multiaddrs[@]}"; do
address="${multiaddr}/p2p/${peer_id}"
ipfs swarm connect "${address}"
done
}
# Connect estuary.tech peer IDs to swarm:
swarm_connect 12D3KooWN8vAoGd6eurUSidcpLYguQiGZwt4eVgDvbgaS7kiGTup
swarm_connect 12D3KooWGBWx9gyUFTVQcKMTenQMSyE2ad9m7c9fpjS4NMjoDien
swarm_connect 12D3KooWFrnuj5o3tx4fGD2ZVJRyDqTdzGnU3XYXmBbWbc8Hs8Nd
swarm_connect 12D3KooWNNuTcH39tagS4MyddgQP7jBNSHJn4cVuTKuY4bjNZ6cw
## POKEMON
bulbasaur=bafyreiaviiu3yvocagg4osn43gghl5ovil2ovpsdtvwvlw6rwbaofrj25i
squirtle=bafyreifg2xav2nwqozjyjg7nxkm247bpza4b4lnojhpsfbcokzif6dt7ti
pikachu=bafyreiexq5kltsx5fc64n6zhshgsckdvn4wyaa4tjvpd7kxm423jb2t5za
charmander=bafyreib5hgqk25hugafpwcunjbuxoxgkvzxbjzqry26dwldudmsnlzdppi
mewtwo=bafyreifjj27yqvcbvvechtu2llk2pjw67opizqitdk4stxg47x74ec3cwq
pokemon_get () {
ipfs pin add "${1}"
ipfs dag get "/ipfs/${1}"
}
pokemon_get $bulbasaur
pokemon_get $squirtle
pokemon_get $pikachu
pokemon_get $charmander
pokemon_get $mewtwo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment