Crates.io | wallet_standard_wallets |
lib.rs | wallet_standard_wallets |
version | |
source | src |
created_at | 2024-09-13 12:14:58.380182 |
updated_at | 2024-11-04 16:47:48.061906 |
description | A collection of solana wallet implementations primarily used for testing. |
homepage | https://github.com/ifiokjr/wasm_solana |
repository | https://github.com/ifiokjr/wasm_solana |
max_upload_size | |
id | 1373605 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
wallet_standard_wallets
A collection of solana wallet implementations primarily used for testing.
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
ssr
Enables the ssr
feature for the wallet_standard
crate.js
Enables the js
feature to unlock wasm support for the wallet_standard
crate.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::MemoryWallet;
use wallet_standard_wallets::prelude::*;
use wasm_client_solana::DEVNET;
use wasm_client_solana::SolanaRpcClient;
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(())
}