sendAndConfirm.
Pari is live on Solana and built to run on more chains. The SDK works on devnet only today.
Install
The SDK is not on npm yet, so this command fails today.@solana/web3.js, so keep your project on it. The SDK is an ES module, so use import.
Read data
apiClient reads the REST API. It is the best way to read many tokens or wallets. It takes no key, and it cannot sign or send.
all walks every page for you:
ApiRequestError. A 429 waits for Retry-After and retries twice first.
stream reads the live feed. It reconnects when the connection drops and gives you each event once.
On-chain reads
PariClient reads straight from the chain through an RPC node. Use it when you need the latest state.
connectionFor returns a promise, so await it. It checks that the RPC node is on the right cluster. It uses PARI_RPC_URL when set, or the public devnet RPC.
readTokenFromApi, readStakePositionFromApi, readHolderRewardsOutlookFromApi and readProtocolStatusFromApi return the same types from the API. You can swap the source without changing the code that uses them.
Build unsigned transactions
EveryPariClient write method returns unsigned work. Nothing is sent. You sign with your own wallet.
amountIn is in base units of the pair for a buy, and in base units of the token for a sell. Tokens have 6 decimals.
This example builds a buy and simulates it. It needs no key and spends nothing. The wallet here is empty, so result.ok is false.
trade throws when the fee is over maxFeeBps (default 500). The error has the name FeeTooHighError and a feeBps field. Wait and quote again. See Fees.
To send, call sendAndConfirm(connection, tx, [signer]), or pass the transaction to a wallet.
Launch
client.launch builds the launch transaction. You generate the mint key yourself.
The mint key has already signed the result. The creator signs last.
PARI_KEYPAIR is the path to a keypair file. Never put a key in your code.
A Solana transaction holds at most 1232 bytes, and the launch carries the name, ticker and URI. Keep the URI short. launch throws if the transaction is too large.
Check a name first
A name can be locked by another token.getNameLock tells you before you launch.
Upload an image and metadata
Registered integrators can use the hosted upload service. It needsPARI_API_KEY. Without a key, host your own metadata and pass its URL as uri.
Launch with a stock pair
A launch can be paired with a tokenized stock instead of SOL. Pass its symbol aspair. devBuyLamports is then in base units of the stock, and the creator must already hold it. Fees of that token are in the stock.
Tokenized stocks are not offered to US persons.
Other exports
PRESETS: the values of each preset.normalize: the name normalization the protocol uses.@pariprotocol/sdk/low-level: the raw instruction builders.