# API Reference

## Constructor

```javascript
const wallet = new SaturnWallet();
```

Creates a new instance of the Saturn Wallet SDK. Automatically checks for existing connections and validates them.

## Methods

### **`getCurrentAddress()`**

Returns the currently connected wallet address with validation.

```javascript
try {
  const address = await wallet.getCurrentAddress();
  console.log(`Current address: ${address}`);
} catch (error) {
  console.error("Error getting address:", error.message);
}
```

**Returns:** `Promise<string>` - The wallet address

**Throws:** Error if wallet not connected or validation fails

### &#x20;**`connect(message)`**

Connects to the wallet by requesting a message signature with ownership proof.

```javascript
try {
  const connection = await wallet.connect("Sign this message to connect");
  // Returns: { address: string, signature: string, publicKey: string }
} catch (error) {
  console.error("Connection error:", error.message);
}
```

#### **Parameters:**

* `message` (string, required): Message to be signed for connection

#### **Returns:** `Promise<Object>` - Connection object with address, signature, and publicKey

**Throws:** Error if connection fails, message is invalid, or validation fails

### **`sendTransaction(params)`**

Sends a transaction with the specified parameters and comprehensive validation.

```javascript
try {
  const txResult = await wallet.sendTransaction({
    asset: "CIRX", // Asset symbol (required)
    amount: "1.5", // Amount to send (required)
    toAddress: "0x...", // Recipient address (required)
  });
  // Returns: { hash: string, block: string, status: string }
} catch (error) {
  console.error("Transaction error:", error.message);
}
```

**Parameters:**

* `params` (object, required): Transaction parameters
  * `asset` (string): Asset symbol (e.g., "CIRX")
  * `amount` (string): Amount to send (must be positive number)
  * `toAddress` (string): Recipient address

**Returns:** `Promise<Object>` - Transaction result with hash, block, and status

**Throws:** Error if wallet not connected, invalid parameters, or transaction fails

### **`disconnect()`**

Disconnects the wallet from the current dApp and clears local state.

```javascript
try {
  const success = await wallet.disconnect();
  console.log(`Disconnected: ${success}`);
} catch (error) {
  console.error("Disconnect error:", error.message);
  // Note: Local state is cleared even if disconnect call fails
}
```

**Returns:** `Promise<boolean>` - True if disconnected successfully

**Throws:** Error if disconnect operation fails (local state still cleared)

### **`isConnected()`**

Checks if the wallet is currently connected with full validation.

```javascript
try {
  const connected = wallet.isConnected();
  console.log(`Connected: ${connected}`);
} catch (error) {
  console.error("Validation error:", error.message);
  // Connection state has been cleared due to validation failure
}
```

**Returns:** `boolean` - True if wallet is connected and validated

**Throws:** Error if connection validation fails (clears invalid connection state)


---

# 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://circular-protocol.gitbook.io/saturn-wallet-user-guide/saturn-wallet-sdk/api-reference.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.
