# 入门

## 安装

```typescript
npm i aftermath-ts-sdk
```

### 使用方法 <a href="#shi-yong-fang-fa" id="shi-yong-fang-fa"></a>

创建一个 Aftermath 实例，以便于调用我们的服务器，或创建一个 Aftermath API 实例，以便更精细地控制事务构建。

## Aftermath SDK <a href="#aftermath-sdk" id="aftermath-sdk"></a>

### 1.创建 Aftermath provider <a href="#id-1.-chuang-jian-aftermath-provider" id="id-1.-chuang-jian-aftermath-provider"></a>

```javascript
const afSdk = new Aftermath("MAINNET"); // "MAINNET" | "TESTNET" | "DEVNET"
await afSdk.init(); // initialize provider
```

### 2.创建 new protocol provider

```typescript
const router = afSdk.Router(); 
const pools = afSdk.Pools(); 
const staking = afSdk.Staking(); 
const farms = afSdk.Farms();
```

## Aftermath API <a href="#aftermath-api" id="aftermath-api"></a>

### 1.创建 Aftermath API provider <a href="#id-1.-chuang-jian-aftermath-api-provider" id="id-1.-chuang-jian-aftermath-api-provider"></a>

```typescript
const fullnodeEndpoint = "https://fullnode.mainnet.sui.io";
const addresses = {...};

const afApi = new AftermathApi(
    new SuiClient({
        transport: new SuiHTTPTransport({
            url: fullnodeEndpoint,
        }),
    }),
    addresses,
    new IndexerCaller("MAINNET"), // "MAINNET" | "TESTNET" | "DEVNET"
);
```

### 2.创建 new protocol provider

```typescript
const poolsApi = afApi.Pools(); 
const stakinApi = afApi.Staking(); 
const farmsApi = afApi.Farms();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ch-docs.aftermath.finance/kai-fa-ren-yuan/ru-men.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
