#wallet #solana #collection #standard #testing #ssr #js

wallet_standard_wallets

A collection of solana wallet implementations primarily used for testing

17 releases

0.1.16 Dec 12, 2024
0.1.15 Dec 12, 2024
0.1.14 Nov 4, 2024
0.1.13 Oct 20, 2024
0.1.5 Sep 28, 2024

#47 in #ssr

Download history 331/week @ 2024-09-11 261/week @ 2024-09-18 182/week @ 2024-09-25 407/week @ 2024-10-02 792/week @ 2024-10-09 170/week @ 2024-10-16 24/week @ 2024-10-23 104/week @ 2024-10-30 30/week @ 2024-11-06 1/week @ 2024-11-13 3/week @ 2024-11-20 10/week @ 2024-12-04 322/week @ 2024-12-11 6/week @ 2024-12-18

338 downloads per month

Unlicense and LGPL-3.0+

1MB
23K SLoC

wallet_standard_wallets


A collection of solana wallet implementations primarily used for testing.


Crate Docs Status Unlicense codecov

Installation

To install you can used the following command:

cargo add wallet_standard_wallets

Or directly add the following to your Cargo.toml:

[dependencies]
wallet_standard_wallets = "0.1" # replace with the latest version

Features

  • ssr Enables the ssr feature for the wallet_standard crate.
  • js Enables the js feature to unlock wasm support for the wallet_standard crate.

Usage

The memory wallet is a simple wallet that stores all accounts in memory and conforms to the WalletStandard trait.

use anyhow::Result;
use solana_sdk::native_token::sol_to_lamports;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signature;
use solana_sdk::system_instruction;
use solana_sdk::transaction::VersionedTransaction;
use wallet_standard::SolanaSignTransactionProps;
use wallet_standard_wallets::prelude::*;
use wallet_standard_wallets::MemoryWallet;
use wasm_client_solana::SolanaRpcClient;
use wasm_client_solana::DEVNET;

async fn run() -> Result<()> {
	let keypair = Keypair::new();
	let pubkey = keypair.pubkey();
	let target_pubkey = Pubkey::new_unique();
	let instruction = system_instruction::transfer(&pubkey, &target_pubkey, sol_to_lamports(0.5));
	let rpc = SolanaRpcClient::new(DEVNET);
	let blockhash = rpc.get_latest_blockhash().await?;
	let transaction =
		VersionedTransaction::new_unsigned_v0(&pubkey, &[instruction], &[], blockhash)?;
	let mut memory_wallet = MemoryWallet::new(rpc, &[keypair]);

	// connect the first account in the memory wallet accounts list
	memory_wallet.connect().await?;

	let props = SolanaSignTransactionProps::builder()
		.transaction(transaction)
		.build();
	let signed_transaction: VersionedTransaction = memory_wallet.sign_transaction(props).await?;

	Ok(())
}

Dependencies

~31–45MB
~686K SLoC