What is rpcX?
rpcX is a feature unique to Atlas that enables custom parsing of on-chain data. On Atlas, anyone can write an rpcX package that allows RPC nodes to return JSON responses instead of raw bytes when reading on-chain data.
The problem
The current experience of reading SVM data is painful. All RPC methods return bytes and deserialization into useful objects is left up to the user. If you're developing a protocol, you need to provide and maintain client code for parsing -- potentially in multiple languages. If you're integrating with a protocol, you're limited to using whatever clients the team provides or forced to write your own. This status quo creates unnecessary work for protocol developers and imposes unnecessary limitations on integrators.
How does rpcX fix this?
rpcX eliminates the need for client code when reading from the SVM. To understand rpcX, let's take a look at how we might fetch prices using a Pyth oracle.
Using only the Solana RPC, we are limited to fetching bytes:
curl "https://api.mainnet-beta.solana.com/" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":"1","method":"getAccountInfo","params":["7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE",{"encoding":"base64"}]}'
Expected output
{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.0.21",
"slot": 318240151
},
"value": {
"data": [
"IvEjY51+9M1gMUcENA3t3zcf1CRyFI8kjp0abRpesqw6zYt/1dayQwHvDYtv2izrpB2hXUCV0do5Kg0vjtDGx7wPTPrIwoC1bS2klNMEAAAAsyUXAQAAAAD4////Ae+gZwAAAAAA76BnAAAAAOQ/UrwEAAAA+Dw+AQAAAACX9fcSAAAAAAA=",
"base64"
],
"executable": false,
"lamports": 1825020,
"owner": "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ",
"rentEpoch": 18446744073709552000,
"space": 134
}
},
"id": "1"
}
If we wanted to actually see what the price is, we'd have to import and use one of the clients the Pyth team maintains.
Using rpcX, we can get the parsed object directly from the RPC
curl "https://testnet.atlas.xyz" -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":"1","method":"getParsedAccountData","params":["HBn33tsjnouB44tHnjbCTudVnwBbyp7n1LitvkjRGi8r"]}'
Expected output
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"context": {
"slot": 1282898
},
"value": {
"name": "PriceUpdateV3",
"owner": "7Xa5DmgXiYicFA6M528Gdu8LZ6PG9GSbSJfDUSK1n1yT",
"lamports": "480",
"executable": false,
"data": {
"posted_slot": "0",
"price_message": {
"conf": "0",
"exponent": -8,
"feed_id": [6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
"price": "21307518637",
"publish_time_ms": "1738690454400"
},
"verification_level": {
"name": "Partial",
"value": {
"num_signatures": 0
}
},
"write_authority": "6TqGq1RgiqA6NHuwdL7uBTUpKGefYdygsjbpiteFbNFd"
},
"space": 112,
"parseErr": null
}
}
}
How do rpcX packages work?
An rpcX package is just a small piece of code that parses on-chain data and adheres to a common interface. RPC nodes on Atlas have a set of RPC methods that use this off-chain code to transform raw bytes into JSON objects. rpcX methods are very similar to normal JSON RPC methods, just with different parameters. Since rpcX methods are available to everyone, consumers of on-chain data can easily fetch exactly what they need without relying on client-side code.
More specifically, the rpcX package responsible for parsing on-chain data is encapsulated within a WASM component. As long as the WASM component implements a specific interface, Atlas RPC nodes will be able to use the rpcX package to enrich and transform on-chain data. Certain interfaces correspond to certain rpcX methods, see the page on rpcX Interfaces for more details. RPC nodes are able to determine which rpcX package should be used by using an on-chain registry of components that is managed by the rpcX registry program.
rpcX packages are written in Rust. This makes it very easy for protocol developers to develop a package because they can import structs and functions directly from their program. Once a developer writes and deploys an rpcX package, anyone can read their parsed data using the out-of-the-box RPC.
What are some examples of things can I do with rpcX?
- Make token balances human readable
- Parse and enrich program logs
- Aggregate and transform on-chain data (e.g. viewing the top 10 tokens by volume on a DEX)
- And much more!
How can I build my own rpcX package?
For details on how to get started, see the rpcX tutorial.