Skip to main content

StandardWallet

Struct StandardWallet 

Source
pub struct StandardWallet { /* private fields */ }
Expand description

A standard Ethereum wallet with a single private key.

This wallet type generates a random private key directly, without using a mnemonic or HD derivation.

§Example

use kobe_eth::StandardWallet;

let wallet = StandardWallet::generate().unwrap();
println!("Address: {}", wallet.address_string());
println!("Private Key: 0x{}", wallet.private_key_hex().as_str());

Implementations§

Source§

impl StandardWallet

Source

pub fn from_bytes(bytes: &[u8; 32]) -> Result<Self, Error>

Create a wallet from raw 32-byte secret key.

§Errors

Returns an error if the secret key is invalid.

Source

pub fn from_hex(hex_str: &str) -> Result<Self, Error>

Import a wallet from a hex-encoded secret key.

§Errors

Returns an error if the hex string is invalid or the secret key is invalid.

Source

pub fn secret_bytes(&self) -> Zeroizing<[u8; 32]>

Get the secret key as raw bytes (zeroized on drop).

Source

pub fn secret_hex(&self) -> Zeroizing<String>

Get the secret key in hex format without 0x prefix (zeroized on drop).

Source

pub fn pubkey_hex(&self) -> String

Get the public key in uncompressed hex format without 0x prefix.

Source

pub fn address(&self) -> String

Get the checksummed Ethereum address string.

Trait Implementations§

Source§

impl Debug for StandardWallet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.