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

# Saros Super App

## Solana DApps Integration <a href="#solana-dapps-integration" id="solana-dapps-integration"></a>

Saros Wallet 개발자 가이드에 오신 것을 환영합니다. 이 문서는 Saros Wallet에서 개발을 시작하는 개발자들을 위한 가이드를 포함하고 있습니다.

### Saros Wallet을 감지하는 가장 쉬운 방법:

&#x20;`window.saros`가 제공자인지 확인하세요. 만약 아니라면, Saros Wallet 전용 제공자인 `window.saros`로 대체해 주세요.

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

```
function getProvider() {
  const provider = window.saros;
  if (!provider) {
    return window.open('');
  }
  return provider;
}
```

***

### Saros 확장 지갑 연결하기 (To connect Saros Extension Wallet)

Saros Extension을 연결한다는 것은 사용자의 계정(들)에 접근한다는 것을 의미합니다.

```
// Connect & get accounts
window.saros.request({method: 'sol_accounts'});

// Alias for connection
window.saros.request({method: 'sol_requestAccounts'});​

//Check if dapp connected
window.saros.isConnected();
```

### Saros 확장 지갑 연결 해제하기 (To disconnect Saros Extension Wallet)

Saros Extension을 연결 해제하려면, 아래를 사용하세요:

```
window.saros.disconnect()
```

### 기능을 체험하기 (To experience functions)

계정을 연결한 후, 더 많은 기능을 체험할 수 있습니다.

#### **현재 계정 가져오기 (Get Current Account)**

반환값 `Promise<Array[String]>`

* 지갑을 찾을 수 없는 경우, `throw Error`를 발생시키지 않고 `[]` 을 반환합니다.

```
window.saros.request({ method: 'sol_accounts' }).then(accounts => {
  if (accounts[0]) {
    // Do something with accounts
  } else {
    // Wallet not found
  }
})
```

#### **지갑 존재 여부 확인하기 (Check wallet whether exists or not)** <a href="#check-wallet-whether-exists-or-not" id="check-wallet-whether-exists-or-not"></a>

반환값 `Promise<{data: Boolean}>`

```
window.saros.request({ method: 'has_wallet', params: ['solana'] })
// Example
window.saros.request({ method: 'has_wallet', params: ['solana'] }).then(() => {
  // Wallet Exists
}).catch(e => { 
  // Wallet not found
})
```

#### **트랜잭션 서명 (Sign Transaction)**

사용자가 서명할 메시지를 보내려면 웹 애플리케이션은:

Uint8Array 형식으로 된 hex 또는 UTF-8 인코딩 문자열을 제공해야 합니다.

반환값: \`Promise<({signature: base58, publicKey: PublicKey})>

```
// Example Sign Transaction
const signature = window.saros.request({
    method: 'sol_sign',
    params: [<Transaction>]
}).then(({publicKey, signature}) => {
	//Do something with publicKey and signature
});
```

#### 여러 트랜잭션 서명 및 전송 (Signing and Sending Multiple Transactions)

```
const solSignAllTransaction = async () => {
  try {
    const pubKey = new PublicKey(solanaAccount)
    const txs = new Transaction().add(SystemProgram.transfer({
      fromPubkey: pubKey,
      toPubkey: pubKey,
      lamports: LAMPORTS_PER_SOL / 100
    }))

    txs.recentBlockhash = (await cnn.getLatestBlockhash()).blockhash
    txs.feePayer = pubKey

    const transactions = [txs, txs, txs]

    const result = await window.saros.request({
      method: 'sol_signAllTransactions',
      params: [transactions]
    })
    return result
  } catch (err) {
    console.log({ err })
  }
}
```

#### 서명 검증 (Verify Signature)

반환값 `Promise<boolean>`

```
window.saros.request({
  method: 'sol_verify',
  params: [signature, msg]
})
```

***

### 이벤트 처리하기 (To handle events)

#### 이벤트 목록 (List of events) 현재 지갑 확장에서 일부 동작 이벤트만 지원합니다.

```
window.saros.on('event_name', callback);
​//Example
window.saros.on('close', () => window.location.reload());
window.saros.on('accountsChanged', () => window.location.reload());
```

| Events     | Trigger                                |
| ---------- | -------------------------------------- |
| disconnect | Receive when disconnect from Extension |

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