# Mobile Dapp Provider

Sender injects a global JavaScript API into websites visited by its users using the `window.sender.ton` provider object. This API allows websites to request users' Ton accounts, read data from blockchains the user is connected to, and suggest that the user sign messages and transactions.

### Properties <a href="#properties" id="properties"></a>

**deviceInfo**

Developer can get deviceInfo from `window.sender.ton` object.

```typescript
// Some code
export declare interface DeviceInfo {
  platform: 'iphone' | 'ipad' | 'android' | 'windows' | 'mac' | 'linux' | 'browser';
  appName: string;
  appVersion: string;
  maxProtocolVersion: number;
  features: Feature[];
}
```

**protocolVersion**

This is protocol version number, and current protocol version is `2`

**isWalletBrowser**

Check current Provider API if it's wallet browser, the default value is `true`

### Methods

**connect**

```typescript
// Connect method
interface TonAddressItem {
  name: 'ton_addr';
}

interface TonProofItem {
  name: 'ton_proof';
  payload: string;
}

type ConnectItem = TonAddressItem | TonProofItem;

interface ConnectEventError {
    event: 'connect_error';
    id: number;
    payload: {
        code: CONNECT_EVENT_ERROR_CODES;
        message: string;
    };
}

interface ConnectEventSuccess {
    event: 'connect';
    id: number;
    payload: {
        items: ConnectItemReply[];
        device: DeviceInfo;
    };
}

type ConnectEvent = ConnectEventSuccess | ConnectEventError;

export declare interface ConnectRequest {
  manifestUrl: string;
  items: ConnectItem[];
}

const protocolVersion = 2;

const request = {
  items: [{ name: 'ton_addr' }],
  manifestUrl: 'https://megaton.fi/tonconnect-manifest.json?v=1',
};

await window.sender.ton.connect(protocolVersion, request);
```

The third dapp can use `connect` method to connect Sender Wallet. And this method will respond a `ConnectEvent` object.&#x20;

**restoreConnection**

```typescript
// Example
await window.sender.ton.restoreConnection();
```

This method can restore app connection automatically if dapp is connected before, so that user don't need to connect dapp again. And this method will respond a `ConnectEvent` object.&#x20;

**disconnect**

```typescript
// Disconnect dapp
await window.sender.ton.disconnect();
```

**send**

```typescript
// Send transaction by wallet
interface SendTransactionRpcRequest {
  method: 'sendTransaction';
  params: [string];
  id: string;
}

interface SignDataRpcRequest {
  method: 'signData';
  params: [
    {
      schema_crc: number;
      cell: string;
    }
  ];
  id: string;
}

interface DisconnectRpcRequest {
  method: 'disconnect';
  params: [];
  id: string;
}

type RpcRequests = {
  sendTransaction: SendTransactionRpcRequest;
  signData: SignDataRpcRequest;
  disconnect: DisconnectRpcRequest;
};

type RpcMethod = 'disconnect' | 'sendTransaction' | 'signData';

const request = {
  sendTransaction: { ... },
  signData: { ... },
  disconnect: { ... },
}

await window.sender.ton.send(request);
```

This method can be used as `sendTransaction` or `signData` method, and dapp can use `send` method to send transaction or sign data.


---

# 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.senderwallet.io/api-reference/ton/mobile-dapp-provider.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.
