# การสร้าง Wallet

![](/files/-MiGDWqSfNZZhpQ7MncO)

ก่อนใช้งาน iWallet&#x20;

เราจะต้องสร้าง Wallet (Address + Private Key) เพื่อเอาไว้ใช้สำหรับเก็บ/เข้าถึง Token บน Blockchain ขึ้นมาก่อน โดยให้ Create Directory เปล่า ๆ ขึ้นมาดังนี้

```bash
$ mkdir iwallet
$ cd iwallet
```

จากนั้นให้ Run Command `wallet-gen` เพื่อสร้าง Wallet File + Configuration File ดังต่อไปนี้

```bash
$ docker run --rm -v $PWD:/iwallet ghcr.io/jittagornp/iwallet wallet-gen -p <YOUR_WALLET_PASSWORD> -n <NETWORK>
```

**หมายเหตุ**

* เวอร์ชัน Free เปลี่ยน Repository จาก  `ghcr.io/jittagornp/iwallet` เป็น `jittagornp/iwallet`

## คำอธิบาย

* `-p`  \<YOUR\_WALLET\_PASSWORD>  คือ  รหัสผ่านที่ใช้สำหรับเข้าถึง Wallet นี้ (อย่าลืมตั้งให้ปลอดภัย)
* `-n` \<NETWORK> คือ Blockchain Network ที่เราจะใช้กับ Wallet นี้&#x20;

`-n` ตอนนี้ระบบรองรับ 3 Networks ได้แก่

* **BSC\_MAINNET** (Default) - Binance Smart Chain
* **POLYGON\_ MAINNET** - Polygon (PoS) Chain
* **BITKUB\_ MAINNET** - Bitkub Chain

## ตัวอย่าง

> แบบไม่กำหนด Network (Default Network  เป็น BSC)

```bash
$ docker run --rm -v $PWD:/iwallet ghcr.io/jittagornp/iwallet wallet-gen -p 123456

Generating wallet and config...
Output wallet file "0x144625b77d8e2d09a11c8a4729acc9bab5c89dc9.wallet.json"
Output config file "0x144625b77d8e2d09a11c8a4729acc9bab5c89dc9.config.json"

$ ls -l
-rw-------  1 root  root  626 Jul 26 15:19 0x144625b77d8e2d09a11c8a4729acc9bab5c89dc9.config.json
-r--------  1 root  root  491 Jul 26 15:19 0x144625b77d8e2d09a11c8a4729acc9bab5c89dc9.wallet.json

$ cat 0x144625b77d8e2d09a11c8a4729acc9bab5c89dc9.config.json
{
  "walletFile" : "0x779fba7799adf15c8476bdbf4dac3770945a2cd4.wallet.json",
  "walletPassword" : "123456",
  "network" : "BSC_MAINNET", 
  "tokenA" : "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c", //BTCB
  "tokenB" : "0xe9e7cea3dedca5984780bafc599bd69add087d56", //BUSD
  "minimumGasBalance" : 0.005,
  "fillGasTokenBAmount" : 3,
  "swapRouter" : "0x10ED43C718714eb63d5aA57B78B54704E256024E", //PancakeSwap Router 
  "gasSwapRouter" : "0x10ED43C718714eb63d5aA57B78B54704E256024E", //PancakeSwap Router 
  "defaultSwapSlippage" : 0.5,
  "defaultSwapDeadlineMinutes" : 10,
  "tokenAutoApproveMultiplier" : 3.0,
  "differenceAtLeastPercent" : 9.0,
  "swapPercent" : 50.0,
  "swapAtLeastValue" : 1,
  "recipientWhitelist" : []
}
```

> แบบกำหนด Network

```bash
$ docker run --rm -v $PWD:/iwallet ghcr.io/jittagornp/iwallet wallet-gen -p 123456 -n POLYGON_MAINNET

Generating wallet and config...
Output wallet file "0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.wallet.json"
Output config file "0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json"

$ cat 0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json
{
  "walletFile" : "0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.wallet.json",
  "walletPassword" : "123456",
  "network" : "POLYGON_MAINNET",
  "tokenA" : "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", //WMATIC
  "tokenB" : "0x2791bca1f2de4661ed88a30c99a7a9449aa84174", //USDC
  "minimumGasBalance" : 0.005,
  "fillGasTokenBAmount" : 3,
  "swapRouter" : "0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff", //Quickswap Router
  "gasSwapRouter" : "0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff", //Quickswap Router
  "defaultSwapSlippage" : 0.5,
  "defaultSwapDeadlineMinutes" : 10,
  "tokenAutoApproveMultiplier" : 3.0,
  "differenceAtLeastPercent" : 9.0,
  "swapPercent" : 50.0,
  "swapAtLeastValue" : 1,
  "recipientWhitelist" : []
}
```

ระบบจะสร้างไฟล์ขึ้นมาได้ 2 ไฟล์ ได้แก่

* Wallet File (.wallet.json) และ
* Configuration File (.config.json) ใช้คู่กันกับ Wallet File

## คำแนะนำ

1. อย่าลืม Backup Wallet File (.wallet.json) และ Configuration File (.config.json) ก่อนเริ่มใช้งานจริง
2. สำหรับ Configuration File (.config.json) เพื่อให้จำได้ง่าย อาจจะเปลี่ยนชื่อไฟล์จาก

> 0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json&#x20;

ไปเป็นคู่ Token ที่จะใช้ก็ได้ เช่น

> WMATIC\_USDC\_0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json&#x20;

โดยใช้คำสั่ง

```bash
$ mv 0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json WMATIC_USDC_0x7fe5999fd513deae43d19dd0ab3cce8491ed6440.config.json
```

เป็นต้น&#x20;

Configuration File อื่น ๆ ก็เช่นกัน


---

# 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://iwallet.jittagornp.me/installation/generate-wallet.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.
