Quickstart
Fragmetric SDK for Node.js and Browser
Fragmetric SDK is the official TypeScript/JavaScript client for interacting with Fragmetric Solana programs. It supports both browser apps and Node.js environments, and includes a CLI for operational workflows and hardware wallet support.
Installation
Use your package manager to install the @fragmetric-labs/sdk package. It is available in both ESM (for browsers) and CJS (for Node.js), with all type definitions included.
@fragmetric-labs/sdk@dev
is intended to test early features on devnet and may not work with programs deployed on mainnet.
Restaking Program
The RestakingProgram
is the main entry point for interacting with the Fragmetric Liquid Restaking Program.
It manages RPC configuration, global transaction settings, and more.
It also serves as the root of a hierarchical structure called the context graph, where each node—called a context—represents a specific part of the program and provides structured access to accounts and transaction templates. The entire SDK interface is exposed through this context graph.
1. Query fragSOL data
restaking.fragSOL
can resolve()
on-chain and off-chain aggregated data, as shown above, which includes:
- Token metadata such as APY, price, and more.
- A list of supported assets for deposit and withdrawal.
2. Query fragSOL user data
restaking.fragSOL.user(...)
instantiates a new user instance using a public key.
The user
can then call resolve()
to fetch its on-chain account data, including:
- fragSOL and wrapped fragSOL amounts.
- SOL balance and token balances for supported assets.
- Ongoing withdrawal requests.
- It will return
null
if the user is new.
3. Deposit
This SDK uses @solana/kit (aka. @solana/web3.js@2
),
so transaction-related interfaces are compatible with @solana/kit
.
Transaction templates like user.deposit
provide the following pipeline:
assemble
Assembles the full transaction message using instructions, fee payer, and lifetime strategy. This method does not perform signing, but returns a fully prepared transaction blueprint.
serialize
Serializes the message of the transaction blueprint into raw bytes (Uint8Array
).
Applies configured signers.
serializeToBase64
Serializes the entire transaction blueprint into a base64-encoded string. Applies signing before serialization.
For compatibility with @solana/web3.js@1
, you can use it like this:
simulate
Simulates the transaction. Returns the simulation result including logs, compute units, errors, etc.
send
Sends the serialized transaction to the network. Does not wait for confirmation or fetch any results. If any TransactionSendingSigner is configured, this method is only way to invoke the transaction.
sendAndConfirm
Sends the transaction and waits for confirmation. Does not parse logs or results. This method will return a signature instead of throwing an error when a skip-preflight request fails.
parse
Parses transaction result and events. Use this after confirming a transaction manually, if needed.
execute
Executes the full pipeline: assemble transaction, send and confirm, then fetch and parse the result including events.
executeChained
Executes the full pipeline for the initial transaction, then automatically executes any chained transactions in sequence. Execution stops if any transaction in the chain fails. This method is designed for operational workflows that require multiple successive transactions.
4. Request Withdrawal
Withdrawal requests can have one of the following states:
cancellable
: can be canceled by the userprocessing
: being processed by the protocolclaimable
: ready for final withdrawal
There is a MAX limit (4) for the number of ongoing withdrawal requests per user. Trying to create more than max active withdrawal requests will result in a program error or simulation failure.
5. Cancel Request Withdrawal
Users can cancel cancellable withdrawal requests like above.
6. Withdraw
Users can withdraw claimable withdrawal requests like above.
7. Others
In addition, users can wrap
, unwrap
and transfer
.