pub struct Client { /* private fields */ }Expand description
The native Bittensor chain client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect(endpoint: impl Into<String>) -> Result<Self, CoreError>
pub fn connect(endpoint: impl Into<String>) -> Result<Self, CoreError>
Connect to a Substrate JSON-RPC endpoint. Websocket URLs are accepted for compatibility and are mapped to HTTP on the same host/port.
pub fn endpoint(&self) -> &str
Sourcepub fn read_catalog(&self) -> &'static [&'static str]
pub fn read_catalog(&self) -> &'static [&'static str]
Stable names of the typed read helpers supplied by the native SDK.
Generic Client::query, Client::query_map, and
Client::runtime_call remain available for the full live metadata
surface.
pub fn ss58_format(&self) -> u16
pub fn genesis_hash(&self) -> [u8; 32]
pub fn runtime(&self) -> Result<Arc<Runtime>, CoreError>
Sourcepub fn refresh_runtime(&self) -> Result<bool, CoreError>
pub fn refresh_runtime(&self) -> Result<bool, CoreError>
Refresh metadata after a runtime upgrade. Returns true when the cached runtime changed.
Sourcepub fn rpc_value(
&self,
method: &str,
params: JsonValue,
) -> Result<JsonValue, CoreError>
pub fn rpc_value( &self, method: &str, params: JsonValue, ) -> Result<JsonValue, CoreError>
Escape hatch for node RPCs not yet wrapped by the SDK.
pub fn block_hash(&self, block: Option<u64>) -> Result<String, CoreError>
pub fn finalized_head(&self) -> Result<String, CoreError>
pub fn header(&self, block_hash: Option<&str>) -> Result<BlockHeader, CoreError>
pub fn block_number(&self) -> Result<u64, CoreError>
pub fn block_time(&self) -> Result<Duration, CoreError>
Sourcepub fn blocks(&self, finalized: bool) -> BlockStream<'_> ⓘ
pub fn blocks(&self, finalized: bool) -> BlockStream<'_> ⓘ
Polling block stream. HTTP and websocket endpoints therefore expose the same API; callers do not need an async runtime merely to follow heads.
The poll interval adapts to the chain’s slot duration (a quarter of a slot, clamped to 50ms..3s): an idle mainnet follower costs the node about one cheap RPC call every 3 seconds, while fast-blocks local chains are still polled every ~62ms.
pub fn at(&self, block: Option<u64>) -> Result<Snapshot<'_>, CoreError>
pub fn compose_call( &self, pallet: &str, function: &str, params: &Value, ) -> Result<Vec<u8>, CoreError>
pub fn decode_call(&self, data: &[u8]) -> Result<Value, CoreError>
pub fn decode_scale( &self, type_name: &str, data: &[u8], ) -> Result<Value, CoreError>
pub fn constant(&self, pallet: &str, name: &str) -> Result<Value, CoreError>
pub fn query( &self, pallet: &str, storage: &str, params: &[Value], block_hash: Option<&str>, ) -> Result<Value, CoreError>
pub fn query_batch( &self, pallet: &str, storage: &str, param_sets: &[Vec<Value>], block_hash: Option<&str>, ) -> Result<Vec<Value>, CoreError>
pub fn query_map( &self, pallet: &str, storage: &str, fixed_params: &[Value], block_hash: Option<&str>, ) -> Result<Vec<(Value, Value)>, CoreError>
pub fn runtime_call( &self, api: &str, method: &str, params: &[Value], block_hash: Option<&str>, ) -> Result<Value, CoreError>
pub fn account_next_index(&self, address: &str) -> Result<u64, CoreError>
Sourcepub fn sign_extrinsic(
&self,
call_data: &[u8],
signer: &Keypair,
nonce: u64,
period: Option<u64>,
) -> Result<(Vec<u8>, String), CoreError>
pub fn sign_extrinsic( &self, call_data: &[u8], signer: &Keypair, nonce: u64, period: Option<u64>, ) -> Result<(Vec<u8>, String), CoreError>
Sign without submitting. Returns (encoded extrinsic, 0x hash).
Registered accounts require the current confirmed nonce and no pending
transaction. ML-DSA authority is selected from finalized state.
pub fn estimate_fee( &self, call_data: &[u8], signer: &Keypair, ) -> Result<u128, CoreError>
pub fn estimate_weight( &self, call_data: &[u8], signer: &Keypair, ) -> Result<Value, CoreError>
pub fn submit( &self, call_data: &[u8], signer: &Keypair, nonce: Option<u64>, period: Option<u64>, wait_for_finalization: bool, ) -> Result<TxOutcome, CoreError>
pub fn submit_encoded( &self, extrinsic: &[u8], expected_hash: String, wait_for_finalization: bool, ) -> Result<TxOutcome, CoreError>
Sourcepub fn submit_shielded(
&self,
call_data: &[u8],
signer: &Keypair,
wait_for_finalization: bool,
) -> Result<TxOutcome, CoreError>
pub fn submit_shielded( &self, call_data: &[u8], signer: &Keypair, wait_for_finalization: bool, ) -> Result<TxOutcome, CoreError>
Full MEV-shield pipeline: sign the inner call at nonce+1, seal it with
the current ML-KEM-768 key, then submit the carrier at nonce. The result
describes the decrypted call and sums both fees; data retains the
carrier hash and each reported fee separately.
pub fn balance_rao(&self, address: &str) -> Result<u128, CoreError>
pub fn existential_deposit_rao(&self) -> Result<u128, CoreError>
pub fn subnets( &self, block_hash: Option<&str>, ) -> Result<Vec<SubnetInfo>, CoreError>
pub fn metagraph( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Value, CoreError>
Sourcepub fn neurons(
&self,
netuid: u16,
block_hash: Option<&str>,
) -> Result<Vec<Value>, CoreError>
pub fn neurons( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Vec<Value>, CoreError>
Typed fast-path for the runtime’s lite-neuron collection.
pub fn subnet_hyperparameters( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Value, CoreError>
pub fn stake_rao( &self, coldkey: &str, hotkey: &str, netuid: u16, block_hash: Option<&str>, ) -> Result<u128, CoreError>
pub fn quote_stake( &self, netuid: u16, amount_rao: u128, block_hash: Option<&str>, ) -> Result<SwapQuote, CoreError>
pub fn tao(value: u128) -> Result<u128, CoreError>
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Forget for Client
impl Move for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreimpl<T> JsonSchemaMaybe for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.