# sanctum-solana-serde Collection of newtypes for common solana types to implement serde on for easy use in web applications. ## Examples ### Using [`B64VersionedTx`](crate::b64_versioned_tx::B64VersionedTx) with Jupiter Swap API Let's say you're building an application that calls [Jupiter Swap API](https://docs.jup.ag/docs/APIs/swap-api)'s [/swap endpoint](https://docs.jup.ag/api-v6/post-swap). You can use [`B64VersionedTx`](crate::b64_versioned_tx::B64VersionedTx) to handle deserialization of the API response for you: ```rust use sanctum_solana_serde::b64_versioned_tx::B64VersionedTx; use serde::Deserialize; #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct JupSwapResp { pub swap_transaction: B64VersionedTx, pub last_valid_block_height: u64, // note: jup API serializes this as a json number, not a string } ``` ```rust ignore use reqwest::Client; use solana_sdk::transaction::VersionedTransaction; async fn get_swap_tx_from_jup( client: &Client, post_params: serde_json::Value ) -> VersionedTransaction { let JupSwapResp { swap_transaction, .. } = client.post("https://quote-api.jup.ag/v6/swap") .json(post_params) .send() .await .unwrap() .json() .await .unwrap(); swap_transaction.0 } ``` ## Features All individual newtypes are behind their own individual feature flag. All of them are enabled by default. ### `utoipa` The non-default `utoipa` feature implements [utoipa::ToSchema](https://docs.rs/utoipa/latest/utoipa/trait.ToSchema.html) for all the newtypes, allowing you to document them in openAPI/Swagger docs generated by `utoipa`.