pub struct EnvSigner { /* private fields */ }Expand description
A signer that loads credentials from environment variables.
By default, reads from:
NEAR_ACCOUNT_ID- The account IDNEAR_PRIVATE_KEY- The private key
§Example
use near_kit::EnvSigner;
// With NEAR_ACCOUNT_ID and NEAR_PRIVATE_KEY set:
let signer = EnvSigner::new().unwrap();Implementations§
Source§impl EnvSigner
impl EnvSigner
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Load from NEAR_ACCOUNT_ID and NEAR_PRIVATE_KEY environment variables.
§Errors
Returns an error if:
- Either environment variable is not set
- The values cannot be parsed
Sourcepub fn from_env_vars(account_var: &str, key_var: &str) -> Result<Self, Error>
pub fn from_env_vars(account_var: &str, key_var: &str) -> Result<Self, Error>
Load from custom environment variable names.
§Arguments
account_var- Name of the environment variable containing the account IDkey_var- Name of the environment variable containing the private key
Sourcepub fn public_key(&self) -> &PublicKey
pub fn public_key(&self) -> &PublicKey
Get the public key.
Sourcepub fn into_inner(self) -> InMemorySigner
pub fn into_inner(self) -> InMemorySigner
Unwrap into the underlying InMemorySigner.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnvSigner
impl RefUnwindSafe for EnvSigner
impl Send for EnvSigner
impl Sync for EnvSigner
impl Unpin for EnvSigner
impl UnsafeUnpin for EnvSigner
impl UnwindSafe for EnvSigner
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