pub struct RpcClient { /* private fields */ }Expand description
Low-level JSON-RPC client for NEAR.
Implementations§
Source§impl RpcClient
impl RpcClient
Sourcepub fn with_retry_config(
url: impl Into<String>,
retry_config: RetryConfig,
) -> Self
pub fn with_retry_config( url: impl Into<String>, retry_config: RetryConfig, ) -> Self
Create a new RPC client with custom retry configuration.
Sourcepub async fn call<P: Serialize, R: DeserializeOwned>(
&self,
method: &str,
params: P,
) -> Result<R, RpcError>
pub async fn call<P: Serialize, R: DeserializeOwned>( &self, method: &str, params: P, ) -> Result<R, RpcError>
Make a raw RPC call with retries.
Sourcepub async fn view_account(
&self,
account_id: &AccountId,
block: BlockReference,
) -> Result<AccountView, RpcError>
pub async fn view_account( &self, account_id: &AccountId, block: BlockReference, ) -> Result<AccountView, RpcError>
View account information.
Sourcepub async fn view_access_key(
&self,
account_id: &AccountId,
public_key: &PublicKey,
block: BlockReference,
) -> Result<AccessKeyView, RpcError>
pub async fn view_access_key( &self, account_id: &AccountId, public_key: &PublicKey, block: BlockReference, ) -> Result<AccessKeyView, RpcError>
View access key information.
Sourcepub async fn view_access_key_list(
&self,
account_id: &AccountId,
block: BlockReference,
) -> Result<AccessKeyListView, RpcError>
pub async fn view_access_key_list( &self, account_id: &AccountId, block: BlockReference, ) -> Result<AccessKeyListView, RpcError>
View all access keys for an account.
Sourcepub async fn view_function(
&self,
account_id: &AccountId,
method_name: &str,
args: &[u8],
block: BlockReference,
) -> Result<ViewFunctionResult, RpcError>
pub async fn view_function( &self, account_id: &AccountId, method_name: &str, args: &[u8], block: BlockReference, ) -> Result<ViewFunctionResult, RpcError>
Call a view function on a contract.
Sourcepub async fn block(&self, block: BlockReference) -> Result<BlockView, RpcError>
pub async fn block(&self, block: BlockReference) -> Result<BlockView, RpcError>
Get block information.
Sourcepub async fn status(&self) -> Result<StatusResponse, RpcError>
pub async fn status(&self) -> Result<StatusResponse, RpcError>
Get node status.
Sourcepub async fn gas_price(
&self,
block_hash: Option<&CryptoHash>,
) -> Result<GasPrice, RpcError>
pub async fn gas_price( &self, block_hash: Option<&CryptoHash>, ) -> Result<GasPrice, RpcError>
Get current gas price.
Sourcepub async fn send_tx(
&self,
signed_tx: &SignedTransaction,
wait_until: TxExecutionStatus,
) -> Result<SendTxResponse, RpcError>
pub async fn send_tx( &self, signed_tx: &SignedTransaction, wait_until: TxExecutionStatus, ) -> Result<SendTxResponse, RpcError>
Send a signed transaction.
Sourcepub async fn tx_status(
&self,
tx_hash: &CryptoHash,
sender_id: &AccountId,
wait_until: TxExecutionStatus,
) -> Result<SendTxWithReceiptsResponse, RpcError>
pub async fn tx_status( &self, tx_hash: &CryptoHash, sender_id: &AccountId, wait_until: TxExecutionStatus, ) -> Result<SendTxWithReceiptsResponse, RpcError>
Get transaction status with full receipt details.
Uses EXPERIMENTAL_tx_status which returns complete receipt information.
Sourcepub async fn sandbox_patch_state(&self, records: Value) -> Result<(), RpcError>
pub async fn sandbox_patch_state(&self, records: Value) -> Result<(), RpcError>
Patch account state in sandbox.
This is a sandbox-only method that allows modifying account state directly, useful for testing scenarios that require specific account configurations (e.g., setting a high balance for staking tests).
§Arguments
records- State records to patch (Account, Data, Contract, AccessKey, etc.)
§Example
ⓘ
// Set account balance to 1M NEAR
rpc.sandbox_patch_state(serde_json::json!([
{
"Account": {
"account_id": "alice.sandbox",
"account": {
"amount": "1000000000000000000000000000000",
"locked": "0",
"code_hash": "11111111111111111111111111111111",
"storage_usage": 182
}
}
}
])).await?;Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RpcClient
impl !RefUnwindSafe for RpcClient
impl Send for RpcClient
impl Sync for RpcClient
impl Unpin for RpcClient
impl UnsafeUnpin for RpcClient
impl !UnwindSafe for RpcClient
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