> ## Documentation Index
> Fetch the complete documentation index at: https://frenglish.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ウォレット設定

> Sequence ウォレットの設定には、しきい値と署名者リスト（各署名者の重み付き）が含まれます。

すべての Sequence ウォレットには、しきい値と署名者ごとの重みで定義された設定があります。

## 設定レイアウト

| 名前   | Type       | 範囲             | Description                    |
| ---- | ---------- | -------------- | ------------------------------ |
| しきい値 | `uint16`   | 1 - 65535      | 署名が有効とみなされるために必要な署名者の合計「重み」です。 |
| 署名者  | `signer[]` | 無制限（ガスによる制約あり） | 署名者とその「重み」のリストです。              |

### 署名者レイアウト

| 名前     | Type        | 範囲      | Description                                                 |
| ------ | ----------- | ------- | ----------------------------------------------------------- |
| 「重み」   | `uint8`     | 0 - 255 | 各署名者の署名ごとの「重み」です。                                           |
| 「アドレス」 | `"address"` | --      | 署名者の「アドレス」。EOA または EIP-1271 対応の他のスマートコントラクトウォレットである場合があります。 |

#### 例

```json theme={null}
{
  "threshold": 5,
  "signers": [
    {
      "address": "0x4fbf69aa2a75f9942a768dc8da7804ec965f7bea",
      "weight": 2
    },
    {
      "address": "0x596af90cecdbf9a768886e771178fd5561dd27ab",
      "weight": 3
    },
    {
      "address": "0x6192e0fdcd868b3de01c7fbc0ad98baebd7330c1",
      "weight": 2
    },
    {
      "address": "0xec9a7204a43d3f4a82c84fde92d25bfc9110981e",
      "weight": 1
    }
  ]
}
```

この例では、しきい値が5、署名者が4人です。

#### 有効な署名者の組み合わせは以下の通りです：

```
- 0x4fbf69aa2a75f9942a768dc8da7804ec965f7bea & 0x596af90cecdbf9a768886e771178fd5561dd27ab - combined weight of 2 + 3 = 5
- 0x6192e0fdcd868b3de01c7fbc0ad98baebd7330c1 & 0x596af90cecdbf9a768886e771178fd5561dd27ab - combined weight of 2 + 3 = 5
- 0x4fbf69aa2a75f9942a768dc8da7804ec965f7bea, 0x6192e0fdcd868b3de01c7fbc0ad98baebd7330c1 & 0xec9a7204a43d3f4a82c84fde92d25bfc9110981e - combined weight of 2 + 2 + 1 = 5
```

しきい値未満の合計重みの署名者の組み合わせは無効とみなされ、しきい値を超える追加署名者は無視されます。

### 設定ハッシュ - ImageHash

設定はコントラクト上に直接保存されることはなく、ハッシュ化されて署名検証時に毎回チェックされます。これにより、ウォレットコントラクトはストレージの使用とガスコストを削減できます。

一度も更新されていないウォレットは `imageHash` を直接保存せず、`imageHash` がコントラクト作成時の `salt` として使われ、署名はウォレットアドレスに対して検証されます。

#### image hash の計算

<CodeGroup>
  ```solidity twoslash solidity theme={null}
    keccak256(abi.encode( uint8 weight_1, address signer_1,
    keccak256(abi.encode( uint8 weight_2, address signer_2,
    keccak256(abi.encode( uint8 weight_3, address signer_3,
    keccak256(abi.encode( uint256 threshold )) )) )) )) 
  ```

  ```js twoslash TypeScript theme={null}
    let tmp = ethers.solidityPackedKeccak256(['uint256'], [configuration.threshold])

    for (const signer of configuration.signers) {
      tmp = ethers.solidityPackedKeccak256(
        AbiCoder.defaultAbiCoder().encode(
          ['bytes32', 'uint8', 'address'],
          [tmp, signer.weight, signer.address]
        )
      )
    }

    const imageHash = tmp
  ```
</CodeGroup>

## 初期ウォレット設定

初期のウォレット設定がウォレットのアドレスを決定し、その後の更新ではアドレスは変わりません。

ウォレットアドレスは、`imageHash`、`factory`、`mainModule` を使って計算できます。

#### ウォレットアドレスの計算方法

```js theme={null}
// The code of the wallet proxy contract
const WalletProxyBytecode =
"0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3";

// These values are defined by the wallet context
// they must be known in order to validate the counter-factual wallet imageHash
const factory = "0xf9D09D634Fb818b05149329C1dcCFAeA53639d96";
const mainModule = "0xd01F11855bCcb95f88D7A48492F66410d4637313";

// Append the `mainModule` to the `WalletProxyBytecode`
// this completed the creation code of the proxy contract
// used for computing the wallet address as defined by the CREATE2 opcode
const codeHash = ethers.solidityPackedKeccak256(
ethers.solidityPackedKeccak256(
["bytes", "bytes32"],
[WalletContractBytecode, ethers.hexZeroPad(mainModule, 32)]
)
);

// Compute the wallet address
const hash = ethers.solidityPackedKeccak256(
ethers.solidityPackedKeccak256(
["bytes1", "address", "bytes32", "bytes32"],
["0xff", factory, salt, codeHash]
)
);

const address = ethers.getAddress(ethers.dataSlice(hash, 12));
```
