> For the complete documentation index, see [llms.txt](https://docs.kubchain.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kubchain.com/quickstart/launching-a-token-on-kub/launch-a-kap-token.md).

# Launch a KAP Token

Use this guide to launch a KAP standard token on KUB with the published [@kub-chain/contracts](https://www.npmjs.com/package/@kub-chain/contracts) package. It helps you choose the right KAP token standard, prepare the required KUB network inputs, and import the official KAP implementations into your project. Use the table below to map each KAP standard to its package path before you build or deploy.

| Standard | Package Path                                     |
| -------- | ------------------------------------------------ |
| KAP-20   | `@kub-chain/contracts/contracts/token/KAP-20/`   |
| KAP-22   | `@kub-chain/contracts/contracts/token/KAP-22/`   |
| KAP-721  | `@kub-chain/contracts/contracts/token/KAP-721/`  |
| KAP-1155 | `@kub-chain/contracts/contracts/token/KAP-1155/` |

{% hint style="info" %}
Deploy to KUB Testnet first. Move to KUB Mainnet only after you validate deployment, transfers, access control, and admin behavior.
{% endhint %}

## Prerequisites

Prepare these before you deploy:

* A wallet with `tKUB` for KUB Testnet from the [KUB Faucet](/tools/testnet-faucet.md) (or `KUB` for KUB Mainnet)
* Node.js and a package manager such as `npm`, `pnpm`, or `yarn`
* A development environment such as [Hardhat](https://hardhat.org/), [Foundry](https://www.getfoundry.sh/), or [Remix IDE](https://remix.ethereum.org/)
* KAP contracts from [@kub-chain/contracts](https://www.npmjs.com/package/@kub-chain/contracts)
* [KAP infrastructure contract addresses](#kap-infrastructure-contract-addresses)
* KUB network details from [Connect to KUB](/about-kub/connect-to-kub.md)

### KAP Infrastructure Contract Addresses

Use these values when preparing deployment inputs.

{% tabs %}
{% tab title="KUB Mainnet" %}

| Property             | Value                                        |
| -------------------- | -------------------------------------------- |
| `projectName`        | `kap20-token`                                |
| `kyc`                | `0x409CF41ee862Df7024f289E9F2Ea2F5d0D7f3eb4` |
| `adminProjectRouter` | `0x15122c945763da4435b45E082234108361B64eBA` |
| `committee`          | `0x5106ffca7cC44E6cFfEE9bD016A0934130b0322f` |
| `transferRouter`     | `0xFbf5b70ef07AE6F64D3796f8a0fE83A3579FAb6f` |
| `acceptedKYCLevel`   | `4`                                          |
| {% endtab %}         |                                              |

{% tab title="KUB Testnet" %}

| Property             | Value                                        |
| -------------------- | -------------------------------------------- |
| `projectName`        | `kap20-token`                                |
| `kyc`                | `0x988bC9c05f0e0fBC198a5DB0Bd62ca90DC3e1b05` |
| `adminProjectRouter` | `0x6F0f1CAfE5560d9658833490eE999fa731708346` |
| `committee`          | `Your Developer Address`                     |
| `transferRouter`     | `0x4d61aFc68520E0f0Ccbd1A599dd0dC97E2B3B04B` |
| `acceptedKYCLevel`   | `4`                                          |
| {% endtab %}         |                                              |
| {% endtabs %}        |                                              |

## Example: Deploying KAP-20 Token

This example provides step-by-step instructions for deploying a KAP-20 token. For other token standards, you may follow the same deployment pattern. Make sure to review the [KAP token interfaces](/quickstart/launching-a-token-on-kub/kap-token-interfaces.md) before deploying your token.

### Step-by-Step Deployment for KUB Testnet

#### Step 1: Configure the network

**Example Hardhat Network Configuration**

```javascript
module.exports = {
  solidity: "0.8.20",
  networks: {
    kubTestnet: {
      url: "https://rpc-testnet.kubchain.io",
      chainId: 25925,
      accounts: [process.env.PRIVATE_KEY]
    },
    kubMainnet: {
      url: "https://rpc.kubchain.io",
      chainId: 96,
      accounts: [process.env.PRIVATE_KEY]
    }
  }
};
```

**Example Foundry RPC Configuration**

```toml
[rpc_endpoints]
kub_testnet = "https://rpc-testnet.kubchain.io"
kub_mainnet = "https://rpc.kubchain.io"
```

If you use the [Remix IDE](https://remix.ethereum.org/), switch the environment to **Injected Provider - MetaMask** and connect to the KUB Testnet as described in this [guide](/about-kub/connect-to-kub.md).

#### Step 2: Install the package

Install the published contracts package in your project.

{% tabs %}
{% tab title="npm" %}

```bash
npm install @kub-chain/contracts
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm add @kub-chain/contracts
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn add @kub-chain/contracts
```

{% endtab %}
{% endtabs %}

Import the KAP-20 base contract into your token contract.

```solidity
import "@kub-chain/contracts/contracts/token/KAP-20/KAP20.sol";
```

If you build with Foundry, add a remapping by creating or editing `remappings.txt` at the project root.

```
@kub-chain/contracts/=node_modules/@kub-chain/contracts/
```

Then use the same import path in your Solidity files.

{% hint style="info" %}
Run your package manager install before `forge build`, so Foundry can resolve `node_modules`.
{% endhint %}

If you use Remix IDE, work from a local project that already has `@kub-chain/contracts` installed, then compile the same import path there.

#### Step 3: Compile the contract

Compile using the Solidity version required by the KAP contract you imported.

**Example Hardhat Command**

```bash
npx hardhat compile
```

**Example Foundry Command**

```bash
forge build
```

In Remix IDE, open the **Solidity Compiler** tab, set the version to `0.8.20` and compile.

{% hint style="warning" %}
Set the Solidity version to ^0.8.0 (e.g., 0.8.20). A version mismatch results in a compilation failure.
{% endhint %}

#### Step 4: Set the constructor and mint inputs

Prepare these values before deployment. Review the token interface definitions in the [KAP Token Interfaces](/quickstart/launching-a-token-on-kub/kap-token-interfaces.md) section.

* `name`
* `symbol`
* `decimals`
* `initialSupply`
* `projectName`
* `kyc`
* `adminProjectRouter`
* `committee`
* `transferRouter`
* `acceptedKYCLevel`

#### Step 5: Deploy to KUB Testnet

**Example Hardhat Deployment Call**

```bash
npx hardhat run scripts/deploy.js --network kubTestnet
```

**Example Hardhat Deployment Script**

```javascript
async function main() {
  const Token = await ethers.getContractFactory("MyKAP20Token");
  const token = await Token.deploy(
    "0x988bC9c05f0e0fBC198a5DB0Bd62ca90DC3e1b05",
    "0x6F0f1CAfE5560d9658833490eE999fa731708346",
    "0xYourDeveloperAddress",
    "0x4d61aFc68520E0f0Ccbd1A599dd0dC97E2B3B04B"
  );
  await token.waitForDeployment();
  console.log(await token.getAddress());
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

**Example Foundry Deployment Call**

```bash
forge create src/MyKAP20Token.sol:MyKAP20Token \
  --rpc-url kub_testnet \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --constructor-args \
  0x988bC9c05f0e0fBC198a5DB0Bd62ca90DC3e1b05 \
  0x6F0f1CAfE5560d9658833490eE999fa731708346 \
  0xYourDeveloperAddress \
  0x4d61aFc68520E0f0Ccbd1A599dd0dC97E2B3B04B
```

**For Remix IDE**

1. Open **Deploy & Run Transactions**.
2. Set **Environment** to **Injected Provider - MetaMask**.
3. Select your compiled token contract.
4. Enter the constructor arguments for KUB Testnet.
5. Confirm that MetaMask is connected to **KUB Testnet**.
6. Click **Deploy**, then confirm the transaction in your wallet.
7. Copy the deployed contract address from **Deployed Contracts** or the Remix terminal.
8. Save the deployment transaction hash for later verification.

#### Step 6: Validate on KUB Testnet

Check the deployed token before deploying to the KUB Mainnet.

```solidity
token.name()
token.symbol()
token.decimals()
token.totalSupply()
token.balanceOf(deployer)
```

Then test the following:

* `transfer`
* `approve`
* `transferFrom`
* `adminTransfer`

If your contract integrates KYC-gated flows, also test

* `internalTransfer`
* `externalTransfer`

Keep the deployed address and constructor values. You will need them again for verification.

#### Step 7: Deploy to KUB Mainnet

After testnet validation, update your deployment inputs for KUB Mainnet and redeploy.

**Example Hardhat Command**

```bash
npx hardhat run scripts/deploy.js --network kubMainnet
```

**Example Foundry Command**

```bash
forge create src/MyKAP20Token.sol:MyKAP20Token \
  --rpc-url kub_mainnet \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --constructor-args \
  0x409CF41ee862Df7024f289E9F2Ea2F5d0D7f3eb4 \
  0x15122c945763da4435b45E082234108361B64eBA \
  0x5106ffca7cC44E6cFfEE9bD016A0934130b0322f \
  0xFbf5b70ef07AE6F64D3796f8a0fE83A3579FAb6f
```

**For Remix IDE**

1. Switch MetaMask to **KUB Mainnet**.
2. Update the constructor arguments to the KUB Mainnet values.
3. Open **Deploy & Run Transactions** and confirm the **Environment** is still **Injected Provider - MetaMask**.
4. Select the same compiled contract used on testnet.
5. Deploy again from **Deploy & Run Transactions**.
6. Confirm the transaction in MetaMask.
7. Save the new contract address from the Remix terminal, **Deployed Contracts**, or MetaMask activity.

#### Step 8: Verify on KUB Scan

Verify the deployed contract on KUB Scan after deployment. If you deployed with Remix IDE, use the same compiler version and optimization settings that you used in the **Solidity Compiler** tab. KUB Scan supports viewing, verifying, and interacting with contract source code. See [Block Explorer](/tools/block-explorer.md) for more information.

**Explorers:**

* [KUB Mainnet](https://kubscan.com/)
* [KUB Testnet](https://testnet.kubscan.com/)

**Keep these values ready:**

* Contract Address
* Compiler Version
* Exact Source Files
* Constructor Arguments

### Post-Deployment

After deployment and verification, it is essential to confirm the token metadata in the block explorer. Be sure to record important details such as the contract address, deployment transaction hash, ABI, and source version. Once these details are documented, import the token into your wallet for testing purposes. It is crucial to test user-facing transfers and allowances to ensure everything functions correctly. Additionally, monitoring relevant `Transfer` and `Approval` events will help ensure that the token operates as intended.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.kubchain.com/quickstart/launching-a-token-on-kub/launch-a-kap-token.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
