wasi-sol 0.0.6

🔒 A Solana Wallet adapter for WASM frameworks.
Documentation

🦀 Wasi Sol

wasi-sol-logo

made-with-rust Netlify Status Netlify Status Netlify Status Rust Maintenance Crates.io Crates.io Downloads docs License

Open in GitHub Codespaces

GigaDAO Discord

Framework Demo
Yew yew-demo
Dioxus dioxus-demo
Leptos leptos-demo

A Solana Wallet adapter for WASM frameworks.

🔒 Wallets Support

Wallet Supported Features
Phantom All
Solflare All
Backpack All

🌐 Wasm Frameworks Support

Framework Supported
Yew
Dioxus
Leptos

⚙️ Features

Method Supported Tested
connect
disconnect
send_transaction
sign_in
sign_message
sign_transaction
sign_all_transactions

⬛: TODO

🚀 Examples

Framework Example
Yew Github
Dioxus Github
Leptos Github

🎧 Event Listener

Event Emitter Pattern

This crate implements a handy event listener pattern with a built-in emitter object that you can use to subscribe to particular events. This functionality allows you to set state in the UI, perform actions on wallet connect, and more.

// Yew Component
// ...snip...

#[function_component]
pub fn LoginPage() -> Html {
    let wallet_context = use_wallet();
    let connected = use_state(|| false);
    let wallet_adapter = use_state(|| wallet_context);

    let connect_wallet = {
        // ...snip...

        Callback::from(move |_| {
            // ...snip...

            spawn_local(async move {
                let mut wallet_info = (*wallet_adapter).clone();

                wallet_info.emitter.on("connect", move |public_key: Pubkey| {
                    log::info!("Event Listener: Got pubkey {}", public_key);
                    wallet_adapter.set(wallet_info);
                    connected.set(true);
                });

                match wallet_info.connect().await {
                    Ok(_) => {
                    }
                    Err(err) => {
                        log::error!("Failed to connect wallet: {}", err);
                    }
                }
            });
        })
    };

    // ...snip...

    html! {
        <>
        </>
    }
}

event emitter demo

👥 Contributing

Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on GitHub. Your contributions help improve this library for the community.

📝 License

This project is licensed under the MIT License.