A library, server, and CLI tool for protecting NFTs. The following networks are currently supported:
- EVM (Ethereum, Base, Shape, Zora, etc)
- Tezos
- Rust toolchain (install from rustup.rs)
- Chain-specific RPC URLs
- IPFS pinning service (optional)
- PostgreSQL (server-specific; used for backup metadata storage)
Three configuration files are used:
config_chains.toml
: Contains RPC URLs for different chainsconfig_tokens.toml
: Contains the NFT tokens to back upconfig_ipfs.toml
: Contains info about connecting to multiple IPFS providers (optional; for IPFS pinning support)
Currently config_chains.toml
includes a few prepopulated RPCs. Alchemy RPCs are used for EVM chains with an API key that can be configured as ALCHEMY_API_KEY
inside an .env
file. You can also choose to use different RPCs altogether. For config_tokens.toml
, there is an example_config_tokens.toml
that you can update as needed with the tokens to backup.
If you already have a Gallery account and gallery, you can easily create a backup of it by following these steps:
- Note down the username and gallery id you want to back up. The gallery id is the last part of the URL when viewing a gallery, eg,
2RgusW2IT1qkSPKE15S2xTnArN4
fromhttps://gallery.so/michalis/galleries/2RgusW2IT1qkSPKE15S2xTnArN4
. - Run the following command to generate a config file:
GALLERY_ID=2RgusW2IT1qkSPKE15S2xTnArN4 \
USERNAME=michalis \
python3 scripts/extract_gallery_tokens.py > config_tokens.toml
The server supports authenticating JWT tokens using a TOML configuration file containing one or more credential sets, passed via the --jwt-config
flag.
Example config_jwt.toml
(multiple [[jwt]]
tables):
[[jwt]]
# Expected issuer (iss)
issuer = "https://issuer.example.com"
# Expected audience (aud)
audience = "my-audience"
# ES256 public key in PEM format (you may escape newlines as \n)
verification_key = "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----\n"
All credential sets in the file are considered valid and tried during authentication.
There is support for pinning IPFS content using multiple providers. Both the IPFS Pinning Service API and the Pinata API are currently supported.
Both the server and CLI can be configured to pin CIDs on IPFS via a TOML file passed with the --ipfs-config
flag. Example config_ipfs.toml
:
# Pin to Filebase (supports the IPFS Pinning Service API)
[[ipfs_pinning_provider]]
type = "pinning-service"
base_url = "https://api.filebase.io/v1/ipfs"
bearer_token_env = "FILEBASE_TOKEN"
# Pin to Pinata
[[ipfs_pinning_provider]]
type = "pinata"
base_url = "https://api.pinata.cloud"
bearer_token_env = "PINATA_TOKEN"
To run the CLI:
make run-cli
Postgres is a requirement in order to run the server. Deploy Postgres and run migrations by following these instructions:
cp .env.postgres.example .env.postgres
# Fill out .env.postgres with your own credentials, etc.
# ...
# Run the database
make start-db
# Run migrations
export DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}
sqlx migrate run
# This deploys Postgres, runs the migrations, and finally runs the server
# You should have already created `.env.postgres` for this to work end to end.
make run
# If you are already running Postgres, you can simply run the server with:
make run-server
The server includes interactive OpenAPI documentation available at /v1/swagger-ui
when running. This provides a complete API reference with example requests and responses for all endpoints. The OpenAPI specification JSON is available at /v1/api-docs/openapi.json
.
Example usage:
# Start the server
make run-server
# View the interactive API documentation
open http://localhost:8080/v1/swagger-ui
# Install the pre-commit hook to aid with development
# The hook runs formatting, clippy, and tests
cp .hooks/pre-commit .git/hooks/pre-commit
# Update the sqlx cache and commit any changes when necessary - this is needed when developing
# new or updating existing static queries in the server.
make sqlxprepare
# Run tests with coverage output in HTML
make cover
If you find this project helpful and would like to support its development, you can make a donation in the following addresses:
- Ethereum:
0xd2Be832911A252302bAc09e30Fc124A405E142DF
(michalis.eth) - Tezos:
tz1ioFzpKGdwtncBkGunkUD9Sk16NqB2vML6
(michalis.tez)