# Solflare Wallet SDK

If your dApp does not use the [Solana Wallet Adapter](https://docs.solflare.com/solflare/technical/integrate-solflare/using-the-solana-wallet-adapter), you can integrate Solflare directly using the Solflare Wallet SDK.

First, install the package:

```sh
npm install @solflare-wallet/sdk@latest
```

Initialize the SDK:

```typescript
import Solflare from '@solflare-wallet/sdk';

const wallet = new Solflare();

wallet.on('connect', () => {
    console.log('connected', wallet.publicKey.toString());
});
wallet.on('disconnect', () => {
    console.log('disconnected');
});
```

Connect to the wallet - this will trigger either the extension, web or mobile connection. The returned promise will resolve when the user accepted or rejected the connection.

```typescript
await wallet.connect();
```

Send a Solana transaction:

```typescript
const transaction = new Transaction();
// add instructions

const txSignature: string = await wallet.signAndSendTransaction(transaction);
```

If you only want to sign one or multiple transactions:

```typescript
const signedTransaction: Transaction = await wallet.signTransaction(transaction);

const signedTransactions: Transaction[] = await wallet.signAllTransactions([
    transaction1,
    transaction2
]);
```

Sign a test message:

```typescript
const message = 'To verify your wallet on https://example.com, with this message';

const messageBytes = new TextEncoder().encode(message);

const signature: Uint8Array = await wallet.signMessage(messageBytes, 'utf8');
```
