pub trait Signer: Send + Sync {
// Required methods
fn account_id(&self) -> &AccountId;
fn key(&self) -> SigningKey;
}Expand description
Trait for signing transactions.
A signer knows which account it signs for and provides keys for signing.
The key() method returns a SigningKey that bundles together the public
key and signing capability, ensuring atomic key claiming.
§Example Implementation
ⓘ
use near_kit::{Signer, SigningKey, AccountId, SecretKey};
struct MyCustomSigner {
account_id: AccountId,
secret_key: SecretKey,
}
impl Signer for MyCustomSigner {
fn account_id(&self) -> &AccountId {
&self.account_id
}
fn key(&self) -> SigningKey {
SigningKey::new(self.secret_key.clone())
}
}Required Methods§
Sourcefn account_id(&self) -> &AccountId
fn account_id(&self) -> &AccountId
The account this signer signs for.
Sourcefn key(&self) -> SigningKey
fn key(&self) -> SigningKey
Get a key for signing.
Returns a SigningKey that contains both the public key and the
capability to sign with the corresponding private key.
For single-key signers, this always returns the same key. For rotating signers, this atomically claims the next key in rotation.
Implementations on Foreign Types§
Source§impl Signer for Arc<dyn Signer>
Implement Signer for Arc<dyn Signer> for convenience.
impl Signer for Arc<dyn Signer>
Implement Signer for Arc<dyn Signer> for convenience.