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

# Set Up the Client

> Initialize AltudeGasStation with an API key and API-scoped RPC configuration.

## Create the client

```typescript theme={null}
import { AltudeGasStation } from '@altude/gasstation'

const gasStation = new AltudeGasStation({
  apiKey: process.env.ALTUDE_API_KEY!,
  network: 'devnet',
})
```

Use `devnet` while testing. Move to `mainnet-beta` only after the API key is configured for production.

## Initialize runtime configuration

```typescript theme={null}
const config = await gasStation.init()

console.log(config.RpcEnvironment)
console.log(config.FeePayer)
console.log(config.TokenExpiration)
```

`init()` requests `GET /api/transaction/config` with your API key. The response supplies:

| Field             | Description                                   |
| ----------------- | --------------------------------------------- |
| `RpcUrl`          | RPC node selected for the API key             |
| `Token`           | Short-lived JWT used to authorize RPC calls   |
| `TokenExpiration` | JWT expiration time                           |
| `FeePayer`        | Altude account that sponsors transaction fees |
| `RpcEnvironment`  | Cluster selected for the API key              |

The SDK caches valid configuration and refreshes it near token expiration.

<Warning>
  The API response is authoritative. Do not replace `RpcUrl`, `Token`, or `FeePayer` with public endpoints or hard-coded values.
</Warning>

## Provide a signer

Transaction-building methods accept a `GaslessTransactionSigner`. The signer exposes its Solana address and signs transaction message bytes locally:

```typescript theme={null}
import type { GaslessTransactionSigner } from '@altude/gasstation'

const signer: GaslessTransactionSigner = {
  address: wallet.publicKey,
  async signTransactionMessage(messageBytes) {
    return wallet.signTransactionMessage(messageBytes)
  },
}
```

Adapt the method body to your wallet library. Private key material should never be sent to Altude.

## Custom API base URL

Use `baseUrl` only when Altude provides a non-default API environment:

```typescript theme={null}
const gasStation = new AltudeGasStation({
  apiKey: process.env.ALTUDE_API_KEY!,
  network: 'devnet',
  baseUrl: 'https://api.example.altude.so',
})
```

## Mock mode

Constructing the client without an API key enables local mock responses for selected HTTP methods. Live RPC operations require an API key and reject with `RPC_ERROR` when configuration cannot be resolved.
