# Basic Setup

## Creating a Provider and Signer

First, you need to set up an Ethereum provider and (optionally) a signer:

```typescript
import { ethers } from 'ethers';

// Read-only provider
const provider = new ethers.JsonRpcProvider('https://polygon-rpc.com');

// For transactions, you need a signer
// Option 1: Using a private key (server-side)
const privateKey = 'YOUR_PRIVATE_KEY'; // Never hardcode this in production!
const signer = new ethers.Wallet(privateKey, provider);

// Option 2: Using a browser wallet like MetaMask (client-side)
// This assumes window.ethereum is available
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
```

### Creating an Azoth SDK Instance

Once you have a provider or signer, you can create an Azoth SDK instance:

```typescript
import { 
  AzothSDK, 
  RatePeriod, 
  formatInput, 
  formatOutput, 
  convertRateToPeriod 
} from '@azothpay/sdk';

// With a signer (for transactions)
const azoth = AzothSDK.create(signer, 'polygon', 'USDT');

// Or with just a provider (for read-only operations)
const readOnlyAzoth = AzothSDK.create(provider, 'polygon', 'USDT');
```

### Parameters

* provider or signer: An ethers.js Provider or Signer
* network: Blockchain network to use (default: 'polygon')
  * Available: 'polygon', 'bsc', 'avalanche', 'base', 'scroll', 'arbitrum', 'mainnet', 'sei', 'zksync'
* tokenSymbol: Stablecoin to use (default: 'USDT')
  * Available: 'USDT', 'USDC', 'PYUSD' (availability varies by network)
* contractVersion: Optional contract version (defaults to the latest for the selected network)


---

# 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://docs.azothpay.com/sdk/markdown/basic-setup.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.
