• Creates a transaction to wrap SOL into Wrapped SOL (wSOL).

    This function is used to generate a transaction that will wrap the specified amount of SOL into Wrapped SOL (wSOL). It first verifies if the associated token account exists and creates it if necessary, then transfers the SOL and synchronizes it as Wrapped SOL.

    Parameters

    Returns Promise<Transaction>

    • A Promise that resolves to the generated transaction to wrap SOL as wSOL.
    const connection = new Connection("https://api.devnet.solana.com");
    const solanaWallet = new PublicKey("your_solana_wallet_public_key");
    const amount = 1; // Amount of SOL to wrap
    const splToken: SPLToken = {
    address: "erc20_sol_address",
    address_spl: "address_spl_value",
    chainId: 245022926,
    decimals: 9,
    logoURI: "logo_url",
    name: "Solana SOL",
    symbol: "SOL",
    };

    createWrapSOLTransaction({ connection, solanaWallet, amount, splToken })
    .then((transaction) => {
    console.log("Wrap transaction created successfully:", transaction);
    })
    .catch((error) => {
    console.error("Failed to create wrap transaction:", error);
    });