Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Jsonrpc client, Only to one chain

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

Create a client for CITA

Source

pub fn set_uri(self, url: &str) -> Self

§Set url

When the url address is invalid, panic

Source

pub fn uri(&self) -> &Uri

Get url

Source

pub fn set_chain_id(&mut self, chain_id: U256) -> &mut Self

Set chain id

Source

pub fn set_private_key(&mut self, private_key: &PrivateKey) -> &mut Self

Set private key

Source

pub fn private_key(&self) -> Option<&PrivateKey>

Get private key

Source

pub fn debug(&self) -> bool

Get debug

Source

pub fn set_debug(self, mode: bool) -> Self

Set debug mode

Source

pub fn send_requests<T: Iterator<Item = JsonRpcParams>>( &self, params: T, ) -> Vec<Result<JsonRpcResponse, ToolError>>

Send requests

Source

pub fn send_request( &self, param: JsonRpcParams, ) -> Result<JsonRpcResponse, ToolError>

Send request

Source

pub fn send_request_with_multiple_url<T: Iterator<Item = Uri>>( &self, url: T, params: JsonRpcParams, ) -> Vec<Result<JsonRpcResponse, ToolError>>

Send multiple params to one node

Source

pub fn generate_transaction( &mut self, transaction_options: TransactionOptions<'_>, ) -> Result<Transaction, ToolError>

Constructing a Transaction

Source

pub fn generate_sign_transaction( &self, tx: &Transaction, ) -> Result<String, ToolError>

Constructing a UnverifiedTransaction hex string

Source

pub fn send_signed_transaction( &mut self, param: &str, ) -> Result<JsonRpcResponse, ToolError>

Send a signed transaction

Source

pub fn send_transaction( &mut self, param: &str, ) -> Result<JsonRpcResponse, ToolError>

Send unsigned transactions

Source

pub fn get_chain_id(&mut self) -> Result<u32, ToolError>

Get chain id

Source

pub fn get_chain_id_v1(&mut self) -> Result<U256, ToolError>

Get chain id v1

Source

pub fn get_current_height(&self) -> Result<u64, ToolError>

Get block height

Source

pub fn get_version(&self) -> Result<u32, ToolError>

Get version

Trait Implementations§

Source§

impl AmendExt<JsonRpcResponse, ToolError> for Client

Source§

fn amend_code( &mut self, address: &str, content: &str, quota: Option<u64>, ) -> Result<T, E>

Amend contract code
Source§

fn amend_abi( &mut self, address: &str, content: String, quota: Option<u64>, ) -> Result<T, E>

Amend contract ABI
Source§

fn amend_h256kv( &mut self, address: &str, h256_kv: &str, quota: Option<u64>, ) -> Result<T, E>

Amend H256KV
Source§

fn amend_balance( &mut self, address: &str, balance: U256, quota: Option<u64>, ) -> Result<T, E>

Amend account balance
Source§

impl ClientExt<JsonRpcResponse, ToolError> for Client

Source§

fn get_peer_count(&self) -> Result<JsonRpcResponse, ToolError>

peerCount: Get network peer count
Source§

fn get_peers_info(&self, extra: bool) -> Result<JsonRpcResponse, ToolError>

peersInfo: Get all peers information
Source§

fn get_license_info(&self) -> Result<JsonRpcResponse, ToolError>

licenseInfo: Get CITA license information
Source§

fn get_block_number(&self) -> Result<JsonRpcResponse, ToolError>

blockNumber: Get current height
Source§

fn send_raw_transaction( &mut self, transaction_option: TransactionOptions<'_>, ) -> Result<JsonRpcResponse, ToolError>

sendTransaction: Send a transaction and return transaction hash
Source§

fn get_block_by_hash( &self, hash: &str, transaction_info: bool, ) -> Result<JsonRpcResponse, ToolError>

getBlockByHash: Get block by hash
Source§

fn get_block_by_number( &self, height: &str, transaction_info: bool, ) -> Result<JsonRpcResponse, ToolError>

getBlockByNumber: Get block by number
Source§

fn get_transaction_receipt( &self, hash: &str, ) -> Result<JsonRpcResponse, ToolError>

getTransactionReceipt: Get transaction receipt
Source§

fn get_logs( &self, topic: Option<Vec<&str>>, address: Option<Vec<&str>>, from: Option<&str>, to: Option<&str>, ) -> Result<JsonRpcResponse, ToolError>

getLogs: Get logs
Source§

fn call( &self, from: Option<&str>, to: &str, data: Option<&str>, height: &str, extra: bool, ) -> Result<JsonRpcResponse, ToolError>

call: (readonly, will not save state change)
Source§

fn get_transaction( &self, hash: &str, in_pool: bool, ) -> Result<JsonRpcResponse, ToolError>

getTransaction: Get transaction by hash
Source§

fn get_transaction_count( &self, address: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getTransactionCount: Get transaction count of an account
Source§

fn get_code( &self, address: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getCode: Get the code of a contract
Source§

fn get_abi( &self, address: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getAbi: Get the ABI of a contract
Source§

fn get_balance( &self, address: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getBalance: Get the balance of a contract (TODO: return U256)
Source§

fn new_filter( &self, topic: Option<Vec<&str>>, address: Option<Vec<&str>>, from: Option<&str>, to: Option<&str>, ) -> Result<JsonRpcResponse, ToolError>

newFilter:
Source§

fn new_block_filter(&self) -> Result<JsonRpcResponse, ToolError>

newBlockFilter:
Source§

fn uninstall_filter( &self, filter_id: &str, ) -> Result<JsonRpcResponse, ToolError>

uninstallFilter: Uninstall a filter by its id
Source§

fn get_filter_changes( &self, filter_id: &str, ) -> Result<JsonRpcResponse, ToolError>

getFilterChanges: Get filter changes
Source§

fn get_filter_logs(&self, filter_id: &str) -> Result<JsonRpcResponse, ToolError>

getFilterLogs: Get filter logs
Source§

fn get_transaction_proof( &self, hash: &str, ) -> Result<JsonRpcResponse, ToolError>

getTransactionProof: Get proof of a transaction
Source§

fn get_metadata(&self, height: &str) -> Result<JsonRpcResponse, ToolError>

getMetaData: Get metadata
Source§

fn get_block_header(&self, height: &str) -> Result<JsonRpcResponse, ToolError>

getBlockHeader: Get block headers based on block height
Source§

fn get_state_proof( &self, address: &str, key: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getStateProof: Get the proof of the variable at the specified height
Source§

fn get_storage_at( &self, address: &str, key: &str, height: &str, ) -> Result<JsonRpcResponse, ToolError>

getStorageAt: Get the value of the key at the specified height
Source§

fn get_version(&self) -> Result<JsonRpcResponse, ToolError>

getVersion: Get release version info of all modules
Source§

fn estimate_quota( &self, from: Option<&str>, to: &str, data: Option<&str>, height: &str, ) -> Result<JsonRpcResponse, ToolError>

estimateQuota: Estimate a transaction’s quota used
Source§

fn get_pool_tx_num(&self) -> Result<JsonRpcResponse, ToolError>

get tx number in pool
Source§

fn operate_censored_address( &self, action: CensorAction, censor_addr: &str, ) -> Result<JsonRpcResponse, ToolError>

operate censorship address list
Source§

fn get_censored_addr(&self) -> Result<JsonRpcResponse, ToolError>

get censorship address list
Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StoreExt<JsonRpcResponse, ToolError> for Client

Source§

fn store_data(&mut self, content: &str, quota: Option<u64>) -> Result<T, E>

Store data to chain, data can be get back by getTransaction rpc call
Source§

fn store_abi( &mut self, address: &str, content: String, quota: Option<u64>, ) -> Result<T, E>

Store contract ABI to chain, ABI can be get back by getAbi rpc call
Source§

impl Transfer<JsonRpcResponse, ToolError> for Client

Source§

fn transfer( &mut self, value: U256, address: &str, quota: Option<u64>, ) -> Result<T, E>

Account transfer, only applies to charge mode

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more