This script fetches and processes NFTs from the XRP Ledger based on a specific issuer and taxon. It retrieves NFT metadata from IPFS and stores the relevant attributes in an SQLite database.
- Connects to multiple WebSocket servers to fetch NFTs from the XRP Ledger.
- Handles pagination using the
marker
parameter to retrieve all NFTs in a collection. - Retrieves metadata from IPFS, supporting multiple IPFS gateways with retries and exponential backoff.
- Stores NFT data, including specific attributes, in an SQLite database.
- Python 3.7+
- Required Python packages:
asyncio
websockets
requests
sqlite3
-
Clone the repository:
git clone https://github.com/yourusername/nft-metadata-fetcher.git cd nft-metadata-fetcher
-
Create and activate a virtual environment (optional but recommended):
python3 -m venv xrplenv source xrplenv/bin/activate # On Windows use `xrplenv\Scripts\activate`
-
Install the required packages:
pip install asyncio websockets requests
-
Run the script:
python fetcher.py
-
Configure the Script:
- Modify the
issuer_address
andtaxon
variables in the script to match the issuer and taxon of the NFTs you want to fetch. - The script will automatically handle pagination and process all NFTs in the specified collection.
- Replace the trait1, trait2, etc with the names of the traits for the collection you're fetching.
- Modify the
-
Database:
- The script uses an SQLite database (
nftdata.db
by default) to store the NFT data. It will create a table namednfts
if it doesn't exist. - Each NFT's attributes are stored in individual columns, allowing for easy querying and analysis.
- The script uses an SQLite database (
-
IPFS Gateways:
- The script supports multiple IPFS gateways. If one gateway fails or is slow, the script will automatically retry with another.
-
WebSocket Servers:
- The script rotates through a list of WebSocket servers (
wss://s1.ripple.com/
,wss://xrplcluster.com/
,wss://s2.ripple.com/
) to ensure reliable data retrieval from the XRP Ledger.
- The script rotates through a list of WebSocket servers (
- The script logs its operations at the
INFO
level by default. Detailed responses and errors are logged at theDEBUG
level. - You can modify the logging level in the script by adjusting the
logging.basicConfig(level=logging.INFO)
line.
-
Not fetching all NFTs?
- Ensure that the
limit
parameter is set correctly and that the script is handling themarker
parameter for pagination.
- Ensure that the
-
Connection Issues?
- If one of the WebSocket servers is down or not responding, the script will automatically try the next server in the list.
-
IPFS Issues?
- If IPFS metadata isn't being fetched, the script will retry using different gateways. Ensure you have a stable internet connection.
Contributions are welcome! Feel free to submit issues, feature requests, or pull requests.
This project is licensed under the MIT License. See the LICENSE
file for more details.