Skip to main content

Client

Struct Client 

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

The native Bittensor chain client.

Implementations§

Source§

impl Client

Source

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.

Source

pub fn endpoint(&self) -> &str

Source

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.

Source

pub fn ss58_format(&self) -> u16

Source

pub fn genesis_hash(&self) -> [u8; 32]

Source

pub fn runtime(&self) -> Result<Arc<Runtime>, CoreError>

Source

pub fn refresh_runtime(&self) -> Result<bool, CoreError>

Refresh metadata after a runtime upgrade. Returns true when the cached runtime changed.

Source

pub fn rpc_value( &self, method: &str, params: JsonValue, ) -> Result<JsonValue, CoreError>

Escape hatch for node RPCs not yet wrapped by the SDK.

Source

pub fn block_hash(&self, block: Option<u64>) -> Result<String, CoreError>

Source

pub fn finalized_head(&self) -> Result<String, CoreError>

Source

pub fn header(&self, block_hash: Option<&str>) -> Result<BlockHeader, CoreError>

Source

pub fn block_number(&self) -> Result<u64, CoreError>

Source

pub fn block_time(&self) -> Result<Duration, CoreError>

Source

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.

Source

pub fn at(&self, block: Option<u64>) -> Result<Snapshot<'_>, CoreError>

Source

pub fn compose_call( &self, pallet: &str, function: &str, params: &Value, ) -> Result<Vec<u8>, CoreError>

Source

pub fn decode_call(&self, data: &[u8]) -> Result<Value, CoreError>

Source

pub fn decode_scale( &self, type_name: &str, data: &[u8], ) -> Result<Value, CoreError>

Source

pub fn constant(&self, pallet: &str, name: &str) -> Result<Value, CoreError>

Source

pub fn query( &self, pallet: &str, storage: &str, params: &[Value], block_hash: Option<&str>, ) -> Result<Value, CoreError>

Source

pub fn query_batch( &self, pallet: &str, storage: &str, param_sets: &[Vec<Value>], block_hash: Option<&str>, ) -> Result<Vec<Value>, CoreError>

Source

pub fn query_map( &self, pallet: &str, storage: &str, fixed_params: &[Value], block_hash: Option<&str>, ) -> Result<Vec<(Value, Value)>, CoreError>

Source

pub fn runtime_call( &self, api: &str, method: &str, params: &[Value], block_hash: Option<&str>, ) -> Result<Value, CoreError>

Source

pub fn account_next_index(&self, address: &str) -> Result<u64, CoreError>

Source

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.

Source

pub fn estimate_fee( &self, call_data: &[u8], signer: &Keypair, ) -> Result<u128, CoreError>

Source

pub fn estimate_weight( &self, call_data: &[u8], signer: &Keypair, ) -> Result<Value, CoreError>

Source

pub fn submit( &self, call_data: &[u8], signer: &Keypair, nonce: Option<u64>, period: Option<u64>, wait_for_finalization: bool, ) -> Result<TxOutcome, CoreError>

Source

pub fn submit_encoded( &self, extrinsic: &[u8], expected_hash: String, wait_for_finalization: bool, ) -> Result<TxOutcome, CoreError>

Source

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.

Source

pub fn balance_rao(&self, address: &str) -> Result<u128, CoreError>

Source

pub fn existential_deposit_rao(&self) -> Result<u128, CoreError>

Source

pub fn subnets( &self, block_hash: Option<&str>, ) -> Result<Vec<SubnetInfo>, CoreError>

Source

pub fn metagraph( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Value, CoreError>

Source

pub fn neurons( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Vec<Value>, CoreError>

Typed fast-path for the runtime’s lite-neuron collection.

Source

pub fn subnet_hyperparameters( &self, netuid: u16, block_hash: Option<&str>, ) -> Result<Value, CoreError>

Source

pub fn stake_rao( &self, coldkey: &str, hotkey: &str, netuid: u16, block_hash: Option<&str>, ) -> Result<u128, CoreError>

Source

pub fn quote_stake( &self, netuid: u16, amount_rao: u128, block_hash: Option<&str>, ) -> Result<SwapQuote, CoreError>

Source

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

Source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
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