OkLinkClient

Struct OkLinkClient 

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

OkLinkClient 是一个用于与 OkLink API 进行交互的客户端结构体。 它封装了 HTTP 请求逻辑,并提供了多种方法来查询链上数据。

Implementations§

Source§

impl OkLinkClient

Source

pub fn new( base_url: String, api_key: String, chain: String, chain_id: u64, ) -> Self

创建一个新的 OkLinkClient 实例。

§参数
  • base_url: OkLink API 的基础 URL。
  • api_key: 用户的 API 密钥,用于身份验证。
  • chain: 链名称(如 “BTC”)。
  • chain_id: 链 ID。
§返回值

返回一个 OkLinkClient 实例。

Source

pub async fn get_token_price_market_data(&self) -> Result<Value>

获取链上代币的价格和市场数据。

§返回值

返回一个 anyhow::Result<Value>,包含价格和市场数据的 JSON 响应。

获取地址的汇总信息。

§参数
  • address: 要查询的地址。
§返回值

返回一个 anyhow::Result<OkLinkResp<AddressSummary>>,包含地址的汇总信息。

获取地址的多币种余额信息。

§参数
  • address: 要查询的地址。
§返回值

返回一个 anyhow::Result<OkLinkResp<BalanceMulti>>,包含地址的多币种余额信息。

获取 BRC-20 代币的余额分页信息。

§参数
  • address: 要查询的地址。
  • page: 当前页码。
  • page_size: 每页的大小。
§返回值

返回一个 anyhow::Result<OkLinkResp<OkLinkBalancePage>>,包含 BRC-20 代币的余额分页信息。

获取 BRC-20 代币的详细余额信息。

§参数
  • address: 要查询的地址。
  • tick: 代币符号。
  • page: 当前页码。
  • page_size: 每页的大小。
§返回值

返回一个 anyhow::Result<OkLinkResp<OkLinkBalanceDetail>>,包含 BRC-20 代币的详细余额信息。

获取地址的铭文列表。

§参数
  • address: 要查询的地址。
  • page: 当前页码。
  • page_size: 每页的大小。
§返回值

返回一个 anyhow::Result<Value>,包含地址的铭文列表。

Source

pub async fn publish_tx(&self, signed_tx: &str) -> Result<PublishTxInfo>

发布交易。

§参数
  • signed_tx: 已签名的交易数据。
§返回值

返回一个 anyhow::Result<PublishTxInfo>,包含交易发布的结果信息。

获取地址的 UTXO 列表。

§参数
  • address: 要查询的地址。
  • cursor: 当前游标位置。
  • size: 每次请求的大小。
§返回值

返回一个 anyhow::Result<OkLinkResp<UtxoList>>,包含地址的 UTXO 列表。

根据铭文 ID 获取 UTXO 信息。

§参数
  • inscription_id: 铭文 ID。
  • inscription_number: 铭文编号。
§返回值

返回一个 anyhow::Result<OkLinkResp<InscriptionOk>>,包含铭文对应的 UTXO 信息。

Source

pub async fn get_chain_info(&self) -> Result<OkLinkResp<BlockChainInfo>>

Trait Implementations§

Source§

impl Debug for OkLinkClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T