> For the complete documentation index, see [llms.txt](https://killswitchofficial.gitbook.io/rei-chain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://killswitchofficial.gitbook.io/rei-chain/developer/deploying-your-contracts.md).

# Deploying your contracts

### Prerequisite

Please follow Hardhat guide [here](https://hardhat.org/getting-started/#installation)

#### Example: To create a Fixed-cap Asset

{% code title="contracts/Token.sol" %}

```solidity
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";

contract MyToken is ERC20Capped {
    constructor(uint256 _cap) ERC20("MyToken", "XXX") ERC20Capped(_cap) {
        ERC20._mint(msg.sender, _cap);
    }
}

```

{% endcode %}

Add network following network config to `hardhat.config.ts`

```
const config: HardhatUserConfig = {
    ...
    networks: {
        rei: {
            url: 'https://rei-rpc.moonrhythm.io',
            chainId: 55555,
        },
        reitest: {
            url: 'https://rei-testnet-rpc.moonrhythm.io',
            chainId: 55556,
        },
    ...
    solidity: {
        compilers: [
            {
                version: '0.8.9',
                settings: {
                    optimizer: {
                        enabled: true,
                        runs: 1000000,
                    },
                },
            },
        ],
    },
    ...
}
```

#### Compile your code using

```
npx hardhat compile
```

#### Deploy script

{% code title="scripts/deploy.ts" %}

```typescript
import { ethers } from 'hardhat'

async function main() {
    let [owner] = await ethers.getSigners()

    const factory = await ethers.getContractFactory(
        'contracts/Token.sol'
    )
    const contract = await factory.deploy('100000000000') // capped
    await contract.deployed()
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error)
        process.exit(1)
    })

```

{% endcode %}

#### Deploy to testnet

```
npx hardhat run --network reitest -- scritps/deploy.ts
```

#### Deploy to mainnet

```
npx hardhat run --network rei -- scritps/deploy.ts
```

### Verify Contract

Now you will find your deployed contract on rei scan

* Mainnet: <https://reiscan.com/>
* Testnet: [ ](https://testnet.reiscan.com/)<https://testnet.reiscan.com/>

1. Go to `code` tab and select `Verify and Publish`

![](/files/0PcCYHvi7qEbAVh0PBno)

2\. Select `Via flattened source code`

![](/files/IBak2I1nw5WiiOhv6894)

3\. Fill in the following

![](/files/BbVl7ut6sZQlnz2bHtDi)

#### To get flattened code

```
npx hardhat flatten
```

{% hint style="info" %}
Make sure that you do not have duplicate licenses.

Remove duplicate licenses and leave the one on top

Ex. // SPDX-License-Identifier: MIT
{% endhint %}
