pub struct InMemorySigner { /* private fields */ }Expand description
A signer with a single key stored in memory.
This is the simplest signer implementation, suitable for scripts, bots, and testing.
§Example
use near_kit::InMemorySigner;
let signer = InMemorySigner::new(
"alice.testnet",
"ed25519:3D4YudUahN1nawWogh8pAKSj92sUNMdbZGjn7kERKzYoTy8tnFQuwoGUC51DowKqorvkr2pytJSnwuSbsNVfqygr"
).unwrap();Implementations§
Source§impl InMemorySigner
impl InMemorySigner
Sourcepub fn new(
account_id: impl AsRef<str>,
secret_key: impl AsRef<str>,
) -> Result<Self, Error>
pub fn new( account_id: impl AsRef<str>, secret_key: impl AsRef<str>, ) -> Result<Self, Error>
Sourcepub fn from_secret_key(account_id: AccountId, secret_key: SecretKey) -> Self
pub fn from_secret_key(account_id: AccountId, secret_key: SecretKey) -> Self
Create a signer from a SecretKey directly.
Sourcepub fn from_seed_phrase(
account_id: impl AsRef<str>,
phrase: impl AsRef<str>,
) -> Result<Self, Error>
pub fn from_seed_phrase( account_id: impl AsRef<str>, phrase: impl AsRef<str>, ) -> Result<Self, Error>
Create a signer from a BIP-39 seed phrase.
Uses SLIP-10 derivation with the default NEAR HD path (m/44'/397'/0').
§Arguments
account_id- The NEAR account ID (e.g., “alice.testnet”)phrase- BIP-39 mnemonic phrase (12, 15, 18, 21, or 24 words)
§Example
use near_kit::InMemorySigner;
let signer = InMemorySigner::from_seed_phrase(
"alice.testnet",
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
).unwrap();Sourcepub fn from_seed_phrase_with_path(
account_id: impl AsRef<str>,
phrase: impl AsRef<str>,
hd_path: impl AsRef<str>,
) -> Result<Self, Error>
pub fn from_seed_phrase_with_path( account_id: impl AsRef<str>, phrase: impl AsRef<str>, hd_path: impl AsRef<str>, ) -> Result<Self, Error>
Create a signer from a BIP-39 seed phrase with custom HD path.
§Arguments
account_id- The NEAR account IDphrase- BIP-39 mnemonic phrasehd_path- BIP-32 derivation path (e.g.,"m/44'/397'/0'")
§Example
use near_kit::InMemorySigner;
let signer = InMemorySigner::from_seed_phrase_with_path(
"alice.testnet",
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"m/44'/397'/1'"
).unwrap();Sourcepub fn public_key(&self) -> &PublicKey
pub fn public_key(&self) -> &PublicKey
Get the public key.
Trait Implementations§
Source§impl Clone for InMemorySigner
impl Clone for InMemorySigner
Source§fn clone(&self) -> InMemorySigner
fn clone(&self) -> InMemorySigner
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemorySigner
impl Debug for InMemorySigner
Source§impl Signer for InMemorySigner
impl Signer for InMemorySigner
Source§fn account_id(&self) -> &AccountId
fn account_id(&self) -> &AccountId
The account this signer signs for.
Source§fn key(&self) -> SigningKey
fn key(&self) -> SigningKey
Get a key for signing. Read more
Auto Trait Implementations§
impl Freeze for InMemorySigner
impl RefUnwindSafe for InMemorySigner
impl Send for InMemorySigner
impl Sync for InMemorySigner
impl Unpin for InMemorySigner
impl UnsafeUnpin for InMemorySigner
impl UnwindSafe for InMemorySigner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more