LightDAS is a lighter version of the Metaplex Digital Asset RPC API
It allows you to index specific Merkle Trees that you care about. This repository works as a listener and ingester for changes on the Merkle Trees you specify. It does the following:
- Listen on the Merkle Tree address via RPC websockets
- Parse a transaction and deserialize its data, events
- Upsert the Metaplex's DAS database
- LightDAS is started. It fetches trees to index from
ld_merkle_trees
table - It starts the backfiller which fetches, parses and stores past transactions for the tree
- It initiates a websocket subscription to listen for live transactions happening on the tree
- Live transactions are queued in a Rust channel since it is necessary to process transactions in order
- The backfiller parses transactions and updates the database
- After the backfilling is complete, processing of the live transactions is initiated. It fetches transactions from the channel from step 4
- It parses the transactions and updates the database
- Running a standard DAS API is expensive and complicated
- It gives you data off all of the NFTs on chain, but do you really need all of it?
- There are select DAS offerings thus creating a monopolistic environment
With LightDAS, you can have your own DAS API without the nft ingester or any other heavy lifting. The components you need to get your DAS running are:
- LightDAS ingester (us)
- DAS Backfiller (Metaplex)
- DAS API Handler (Metaplex)
- DAS Database (Metaplex)
- Graphite Monitoring (Metaplex)
Follow the steps mentioned below
- Clone the Metaplex Digital Asset RPC API repo
- You need the
api
,db
, andgraphite
containers - Run
docker compose up
. This'll take some time to build and start the containers. Depending on your machine, you can comment out services in thedocker-compose.yaml
if you want them built - After the build is successful, you can stop all other containers except the ones mentioned above
- Then configure and run LightDAS
- Clone the repo
- Add environment variables:
RPC_URL
: RPC needs to support websocket functions. We've built using QuicknodeWS_URL
: RPC websocket URLDATABASE_URL
: Default ispostgres://solana:solana@localhost:5432/solana
, use this unless you changed anything
- Execute
cargo run
- This will download and compile the code with all needed dependencies. Grab a coffee this takes a while
- The first run will fail and complain about no tree addresses being found to index, you need to add tree addresses to index in the database. See the
#trees config
section below - Once running, you'll see the logs of the tasks being performed
- Under heavy loads, we have faced RPC rate limits
- RPC Costs per NFT Mint:
- Quicknode:
logsSubscribe
: 50 creditsgetTransaction
: 50 credits
- Quicknode:
- Overall, each NFT mint will cost you 100 RPC credits
- The address of the trees to be indexed needs to be provided via the database
- LightDAS creates a table with the following schema
CREATE TABLE IF NOT EXISTS LD_MERKLE_TREES ( ADDRESS VARCHAR(255), TAG VARCHAR(255) NULL, CAPACITY INT NULL, MAX_DEPTH INT NULL, CANOPY_DEPTH INT NULL, MAX_BUFFER_SIZE INT NULL, SHOULD_INDEX BOOLEAN DEFAULT TRUE, CREATED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UPDATED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
- You need to add your addresses in the table
ld_merkle_trees
- To update tree addresses dynamically:
- Update the above table
- Send a SIGHUP signal to the LightDAS process
- LightDAS handles the signal and update it's indexing without disrupting existing tasks
Currently LightDAS supports only Compressed NFTs:
If the program is running without any errors then the database is populated with information on new NFT mints. You can query the RPC API locally. It runs on the default URL http://localhost:9090/
If you need any help, have any thoughts, or need to get in touch, DM Wilfred on Twitter/X or open an issue.
We have some open RFCs and need your thoughts
The following is our roadmap in decreasing order of priority:
- Test API responses correctness against standard DAS API responses
- Publish benchmarking results of testing with different RPC providers under various deployment environments
Our vision for LightDAS is to keep it an open-source public good for everyone. We aim to be a compliment to DAS, not to compete against it. Eventually, we would like to streamline the setup process to only need a single binary with minimal dependencies so it's easy for a project to setup a light DAS client to watch a tree and start serving requests. The future decisions for LightDAS will be based on community feedback and discussions.
To keep building LightDAS, we need your support and thoughts. It can be contributions, money/grants, hiring us, providing us with resources, etc. Get in touch.
All code is licensed under the GNU Affero General Public License v3.0 or later.