> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arksat.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK 工具与 Provider 调用

> 检测插件、创建 Client，理解原始 Provider 的调用方式。

## getArksatProvider

`getArksatProvider(): ArksatProvider | undefined` 立即检查注入状态；SSR 环境返回 undefined，不主动连接或解锁。

## waitForArksatProvider

`waitForArksatProvider({ timeoutMs?, signal? }): Promise<ArksatProvider>` 等待注入，默认超时 5 秒，支持 AbortSignal。

```ts theme={null}
import { waitForArksatProvider, createArksatClient } from '@arksat/wallet-sdk'
const provider = await waitForArksatProvider({ timeoutMs: 5000 })
const client = createArksatClient(provider)
```

## createArksatClient

将 Provider 包装为对象参数与具名返回值接口。它不自动申请权限，也不自动重试资产操作。

| 操作 | Client | Provider |
| - | - | - |
| 连接 | connect(options?) 返回 accounts 对象 | connect(options?) 返回地址数组 |
| BTC 发送 | sendToAddress 对象参数，返回 txid 对象 | sendToAddress(address, amount)，返回字符串 |
| 代币发送 | sendAsset 对象参数，返回 txid 对象 | sendAsset(address, assets, bitcoinAmount?)，返回字符串 |
| 签名 | 返回 signature / psbtBase64 等具名字段 | 返回字符串或字符串数组 |

## request

Provider 支持类型化 RPC，params 为元组参数，顺序与原始 Provider 方法一致：

```ts theme={null}
const network = await provider.request({ method: 'getNetwork' })
const txid = await provider.request({
  method: 'sendToAddress',
  params: [address, 1000],
})
```

公开方法以 `ARKSAT_PROVIDER_METHODS` 与 `getCapabilities()` 为准。requestAccounts 是便捷别名，不是独立 RPC 方法。

## 金额工具

`decimalAmountToRaw`、`formatRawAssetAmount` 和 `toRawAmountString` 用于精确转换最小单位与显示数量。[金额精度与示例](https://docs.arksat.xyz/amounts.md)。

## 使用范围

当前 SDK 面向已安装浏览器扩展的网站，通过 `window.arksat` 接入。它不是 Web 钱包的远程 HTTP API。私钥导出、内部钱包管理和 settle 不属于公开 RPC。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.