The Solana blockchain connection object used to interact with the network.
The public key of the user's Solana wallet.
The SPL token object that contains details of the Wrapped SOL.
const connection = new Connection("https://api.devnet.solana.com");
const solanaWallet = new PublicKey("your_solana_wallet_public_key");
const splToken: SPLToken = {
address: "erc20_wsol_address",
address_spl: "address_spl_value",
chainId: 245022926,
decimals: 9,
logoURI: "logo_url",
name: "Wrapped SOL",
symbol: "wSOL",
};
createUnwrapSOLTransaction(connection, solanaWallet, splToken)
.then((transaction) => {
console.log("Unwrap transaction created successfully:", transaction);
})
.catch((error) => {
console.error("Failed to create unwrap transaction:", error);
});
Creates a transaction to unwrap a Wrapped SOL (wSOL) account.
This function is used to generate a transaction that will close an associated token account, which contains Wrapped SOL (wSOL), effectively unwrapping it back to SOL. It first verifies if the associated token account exists before attempting to close it.