pub struct NearClient { /* private fields */ }Expand description
Near RPC client
Implementations§
Source§impl NearClient
impl NearClient
Sourcepub async fn block(&self, finality: Finality) -> Result<CryptoHash, Error>
pub async fn block(&self, finality: Finality) -> Result<CryptoHash, Error>
Queries network and returns block for given height or hash
Sourcepub async fn view<'a, T: DeserializeOwned>(
&'a self,
contract_id: &'a AccountId,
finality: Finality,
method: &'static str,
args: Option<Value>,
) -> Result<ViewOutput<T>, Error>
pub async fn view<'a, T: DeserializeOwned>( &'a self, contract_id: &'a AccountId, finality: Finality, method: &'static str, args: Option<Value>, ) -> Result<ViewOutput<T>, Error>
Sourcepub async fn view_access_key(
&self,
account_id: &AccountId,
public_key: &Ed25519PublicKey,
finality: Finality,
) -> Result<AccessKeyView, Error>
pub async fn view_access_key( &self, account_id: &AccountId, public_key: &Ed25519PublicKey, finality: Finality, ) -> Result<AccessKeyView, Error>
Returns information about a single access key for given account
Arguments
- account_id - The user
AccountIdin a Near network - public_key - The user
Ed25519PublicKeyin a Near network
Sourcepub async fn view_access_key_list(
&self,
account_id: &AccountId,
finality: Finality,
) -> Result<AccessKeyListView, Error>
pub async fn view_access_key_list( &self, account_id: &AccountId, finality: Finality, ) -> Result<AccessKeyListView, Error>
Returns list of all access keys for the given account
Arguments
- account_id - The user
AccountIdin a Near network
Sourcepub async fn view_contract_state(
&self,
account_id: &AccountId,
) -> Result<ViewStateResult, Error>
pub async fn view_contract_state( &self, account_id: &AccountId, ) -> Result<ViewStateResult, Error>
Returns information regarding contract state in a key-value sequence representation
Arguments
- account_id - The contract
AccountIdin a Near network
Sourcepub async fn network_status(&self) -> Result<StatusResponse, Error>
pub async fn network_status(&self) -> Result<StatusResponse, Error>
Returns general status of a given node (sync status, nearcore node version, protocol version, etc), and the current set of validators.
Sourcepub async fn view_transaction<'a>(
&'a self,
transaction_id: &'a CryptoHash,
signer: &'a Signer,
) -> Result<Output, Error>
pub async fn view_transaction<'a>( &'a self, transaction_id: &'a CryptoHash, signer: &'a Signer, ) -> Result<Output, Error>
Queries status of a transaction by hash, returning the final transaction result and details of all receipts.
Arguments
- transaction_id - Transaction
CryptoHash - signer -
Signerthat contain information regarding userKeypair
Return
If a transaction still processing will be returned an error Error::ViewTransaction,
in this case can try to execute view_transaction one more time, or a several times.
If an error differs from Error::ViewTransaction that something goes totally wrong and
you should stop to try executing view_transaction with the same arguments/signer
Sourcepub fn add_access_key<'a>(
&'a self,
signer: &'a Signer,
account_id: &'a AccountId,
new_account_pk: Ed25519PublicKey,
permission: AccessKeyPermission,
) -> FunctionCall<'_>
pub fn add_access_key<'a>( &'a self, signer: &'a Signer, account_id: &'a AccountId, new_account_pk: Ed25519PublicKey, permission: AccessKeyPermission, ) -> FunctionCall<'_>
Creates new access key on the specified account
Arguments
- signer - Transaction
Signer - account_id - The user
AccountIdin a Near network - new_account_pk - The new
Ed25519PublicKey - permission - Granted permissions level for the new access key
Sourcepub fn delete_access_key<'a>(
&'a self,
signer: &'a Signer,
account_id: &'a AccountId,
public_key: Ed25519PublicKey,
) -> FunctionCall<'_>
pub fn delete_access_key<'a>( &'a self, signer: &'a Signer, account_id: &'a AccountId, public_key: Ed25519PublicKey, ) -> FunctionCall<'_>
Deletes an access key on the specified account
Arguments
- signer - Transaction
Signer - account_id - The user
AccountIdin a Near network - public_key - The
Ed25519PublicKeyto be deleted from users access keys
Sourcepub fn function_call<'a>(
&'a self,
signer: &'a Signer,
contract_id: &'a AccountId,
method: &'static str,
) -> FunctionCallBuilder<'_>
pub fn function_call<'a>( &'a self, signer: &'a Signer, contract_id: &'a AccountId, method: &'static str, ) -> FunctionCallBuilder<'_>
Sourcepub fn deploy_contract<'a>(
&'a self,
signer: &'a Signer,
contract_id: &'a AccountId,
wasm: Vec<u8>,
) -> FunctionCall<'_>
pub fn deploy_contract<'a>( &'a self, signer: &'a Signer, contract_id: &'a AccountId, wasm: Vec<u8>, ) -> FunctionCall<'_>
Sourcepub fn create_account<'a>(
&'a self,
signer: &'a Signer,
new_account_id: &'a AccountId,
new_account_pk: Ed25519PublicKey,
amount: Balance,
) -> FunctionCall<'_>
pub fn create_account<'a>( &'a self, signer: &'a Signer, new_account_id: &'a AccountId, new_account_pk: Ed25519PublicKey, amount: Balance, ) -> FunctionCall<'_>
Creates account
§Arguments
- signer - Transaction
Signer - new_account_id - The new
AccountId - new_account_pk - The new
Ed25519PublicKey - amount - Initial balance of that account, could be zero
Sourcepub fn delete_account<'a>(
&'a self,
signer: &'a Signer,
account_id: &'a AccountId,
beneficiary_acc_id: &'a AccountId,
) -> FunctionCall<'_>
pub fn delete_account<'a>( &'a self, signer: &'a Signer, account_id: &'a AccountId, beneficiary_acc_id: &'a AccountId, ) -> FunctionCall<'_>
Sourcepub fn send<'a>(
&'a self,
signer: &'a Signer,
receiver_id: &'a AccountId,
deposit: Balance,
) -> FunctionCall<'_>
pub fn send<'a>( &'a self, signer: &'a Signer, receiver_id: &'a AccountId, deposit: Balance, ) -> FunctionCall<'_>
Sends Near tokens from one account to another.
§Arguments
signer- The account ID of the sender and transactionSignerreceiver_id- The account ID of the receiver.deposit- The amount of Near tokens to send.
§Errors
Possible error conditions include insufficient funds, invalid account IDs, or other issues preventing the successful execution of the transaction.
Trait Implementations§
Source§impl Clone for NearClient
impl Clone for NearClient
Source§fn clone(&self) -> NearClient
fn clone(&self) -> NearClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NearClient
impl !RefUnwindSafe for NearClient
impl Send for NearClient
impl Sync for NearClient
impl Unpin for NearClient
impl !UnwindSafe for NearClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more