> For the complete documentation index, see [llms.txt](https://docs.ramper.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ramper.xyz/ramper-wallet/ramper-wallet-extension-integration/sei-dapp-integration.md).

# Sei Dapp Integration

Welcome to Ramper Wallet Extension Developer Guide. This documentation contains guides for developers to get started developing on Ramper Wallet Extension.‌

### To detect Ramper Wallet Extension with Cosmos Base Chain <a href="#to-detect-ramper-wallet-extension-with-cosmos-base-chain" id="to-detect-ramper-wallet-extension-with-cosmos-base-chain"></a>

To detect whether your browser is running Ramper Extension, please use:

```
if (window.ramper2) {
  console.log('Ramper Extension is installed!');
}
```

### To connect Ramper Wallet Extension <a href="#to-connect-ramper-wallet-extension" id="to-connect-ramper-wallet-extension"></a>

To connect Ramper Wallet Extension means to access the user's \[blockchain - like Cosmos] account(s).

```
// Connect only
window.ramper2.cosmos.enable(chainId: string);
// Connect & get accounts
window.ramper2.cosmos.getKey(chainId: string);
```

Currently, chains support: \['`atlantic-2`','`pacific-1`']

### To disconnect the Ramper Wallet Extension <a href="#to-disconnect-the-ramper-wallet-extension" id="to-disconnect-the-ramper-wallet-extension"></a>

To disconnect Ramper Extension, please use:

```
window.ramper2.cosmos.disconnect();
```

### To experience functions <a href="#to-experience-functions" id="to-experience-functions"></a>

Once your account is connected, let's start experiencing more functions.‌

#### Get Current Account <a href="#get-current-account" id="get-current-account"></a>

If the webpage has permission and Ramper wallet is unlocked, this function will return the address and public key in the following format:

```
interface Key {
  name: string;
  algo: string;
  pubKey: Uint8Array;
  address: Uint8Array;
  bech32Address: string;
  isNanoLedger: boolean;
}

window.ramper2.cosmos.getKey(chainId: string): Promise<Key>
```

&#x20;

### Sign Amino: <a href="#sign-amino" id="sign-amino"></a>

Like `signAmino` method of CosmJS OfflineDirectSigner, however, Ramper’s `signAmino` function takes the chain-id as a required parameter. Signs Proto-encoded StdSignDoc.

```
interface SignOptions {
 // If set to true the wallet will not override fees specified in the signDoc.
  preferNoSetFee: boolean
}  

window.ramper2.cosmos.signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: SignOptions)
```

&#x20;

### Sign Direct: <a href="#sign-direct" id="sign-direct"></a>

Like `signDirect` method of CosmJS OfflineDirectSigner, however, Ramper’s `signDirect` function takes the chain-id as a required parameter. Signs Proto-encoded StdSignDoc.

```
interface SignDoc {
  bodyBytes?: Uint8Array | null;
  authInfoBytes?: Uint8Array | null;
  chainId?: string | null;
  accountNumber?: Long | null;
} 

window.ramper2.cosmos.signDirect(chainId: string, signer: string, signDoc: SignDoc)
```

&#x20;

### Sign Arbitrary: <a href="#sign-arbitrary" id="sign-arbitrary"></a>

```
signArbitrary(
    chainId: string,
    signerAddress: string,
    data: string | Uint8Array
): Promise<StdSignature>;

 window.ramper2.cosmos.signArbitrary(chainId: string, signer: string, data: string)
```

&#x20;

### Delegate Transaction broadcasting: <a href="#delegate-transaction-broadcasting" id="delegate-transaction-broadcasting"></a>

```
enum BroadcastMode {
  Sync = 'sync',
  Async = 'async',
  Block = 'block'
}

 window.ramper2.cosmos.sendTx(chainId: string, tx: Uint8Array, mode: BroadcastMode)
```

### To handle events <a href="#to-handle-events" id="to-handle-events"></a>

#### List of events <a href="#list-of-events" id="list-of-events"></a>

Currently, we only support some action events from the wallet extension

```
connection.on('event_name', callback);
​//Example
window.ramper2.cosmos.on('cosmosChanged', () => window.location.reload());
window.ramper2.cosmos.on('accountsChanged', () => window.location.reload());
```

| Events          | Trigger                                          |
| --------------- | ------------------------------------------------ |
| accountsChanged | Receive when active account changed in Extension |
| cosmosChanged   | Receive when active chain changed in Extension   |

| Method | Description |
| ------ | ----------- |

| Method               | Description           |
| -------------------- | --------------------- |
| on(event, callback)  | Add event listener    |
| off(event, callback) | Remove event listener |
