> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://docs.prividium.com/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

The guides in this section will show you how to:

1. Deploy an [ERC20 token](https://ethereum.org/developers/docs/standards/tokens/erc-20/) contract on Prividium.
2. Programmatically configure contract permissions through the permission API.
3. Interact with your contract in a script.
4. Build a frontend to interact with the contract.

This guide assumes you already have either a local instance of Prividium running on your machine or contract deployment
permissions for a live Prividium network.

## Authentication options

We recommend using the `prividium proxy` command to deploy and interact with contracts. This proxy handles all the
authentication required for you to deploy and interact with contracts.

Alternatively, you may handle authentication yourself inside a custom script. You will see how both options work in this
guide.

## Project setup

Create a new project folder and move into the folder in your terminal.

```bash
mkdir hardhat-prividium-example
cd hardhat-prividium-example
```

Initialize a new Hardhat 3 project with `Node Test Runner` with `viem`. Select `y` to install the dependencies.

```bash
npx hardhat --init
```

Next, install the OpenZeppelin contracts package.

:::code-group
```bash [npm]
npm install -D @openzeppelin/contracts
```

```bash [pnpm]
pnpm add -D @openzeppelin/contracts
```

```bash [yarn]
yarn add -D @openzeppelin/contracts
```

```bash [bun]
bun add -D @openzeppelin/contracts
```
:::

## Configuring the network

Add the Prividium network you will use to the `hardhat.config.ts` file and configure the ignition required
confirmations.

**hardhat.config.ts**

```typescript
    ignition: {
        requiredConfirmations: 1
    },
    networks: {
        localPrividium: {
            type: 'http',
            chainType: 'generic',
            // npx prividium proxy url, signed in via local prividium
            // use npx prividium proxy -u http://localhost:3001 -r http://localhost:8000/rpc
            url: 'http://127.0.0.1:24101/rpc',
            // local prividium account
            // WARNING: never save your private key for a mainnet/testnet wallet here
            accounts: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80']
        },
        testnetPrividium: {
            type: 'http',
            chainType: 'generic',
            // npx prividium proxy url, signed in via testnet
            // use npx prividium proxy -u <USER_PANEL_URL> -r <RPC_URL>
            url: 'http://127.0.0.1:24101/rpc',
            // https://hardhat.org/docs/guides/configuration-variables
            accounts: [configVariable('PRIVIDIUM_PRIVATE_KEY')]
        },
        localL1: {
            type: 'http',
            chainType: 'l1',
            url: 'http://localhost:5010',
            // local prividium account
            // WARNING: never save your private key for a mainnet/testnet wallet here
            accounts: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80']
        }
    }
```

The `localPrividium` network is configured to use the default admin private key for a local network started with
`local-prividium`. Otherwise if you are planning to use a live deployed network, make sure to configure the
`PRIVIDIUM_PRIVATE_KEY` with [Hardhat keystore](https://hardhat.org/docs/plugins/hardhat-keystore).

## Create the token contract

Create a new file in the `contracts` folder called `QuickstartToken.sol`.

```bash
touch contracts/QuickstartToken.sol
```

Copy and paste the `QuickstartToken` contract below into the `QuickstartToken.sol` file.

**QuickstartToken.sol**

```sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

contract QuickstartToken is ERC20, Ownable, ERC20Burnable {
    constructor(string memory name, string memory symbol) ERC20(name, symbol) Ownable(msg.sender) {
        _mint(msg.sender, 100 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
```

This contract:

* Imports helper contracts from `@openzeppelin/contracts` so that our contract is a standard ERC-20 contract, has an
  owner, and allows tokens to be burned
* Sets the token name and symbol using the constructor arguments
* Sets the deployer wallet as the owner
* Mints an initial supply of tokens to the deployer
* Only allows the owner to mint additional tokens using the `mint` function

:::note[This is an example contract for demo purposes]
The ERC20 token code is provided “as is” without any express or implied warranties. Regulations governing digital
assets are still unclear in many jurisdictions. ERC20 tokens may possess unique legal, tax, and market risks, so it is
up to you to determine which, if any, laws apply to your deployment of ERC20 tokens. The developers and publishers of
this software disclaim any liability for any legal issues that may arise from its use.
:::

## Create the deploy script

Create a new file in the `ignition/modules` folder called `QuickstartToken.ts`. This file will be used to deploy the
token contract.

```bash
touch ignition/modules/QuickstartToken.ts
```

Copy and paste the ignition module below into `QuickstartToken.ts`. This will be used to deploy the contract.

**QuickstartToken.ts**

```typescript
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules';

export default buildModule('QuickstartToken', (m) => {
    const quickstartToken = m.contract('QuickstartToken', ['Quickstart Token', 'QKT']);

    return { quickstartToken };
});
```

## Setting up the proxy

Log in to the user panel with an admin account or an account with contract deploy permissions. For a local Prividium, go
to [`http://localhost:3001`](http://localhost:3001) and use the Keycloak login `admin@local.dev` with the password
`password`.

Start the local proxy and keep it running.

Local prividium:

```bash
npx prividium proxy -u http://localhost:3001 -r http://localhost:8000/rpc
```

Testnet prividium:

```bash
npx prividium proxy -u <USER_PANEL_URL> -r <RPC_URL>
```

## Deploy the contract

Compile and deploy the contract. Your contract address will be logged in the output.

```bash
npx hardhat compile
```

Deploy to either `localPrividium` or `testnetPrividium`:

```bash
npx hardhat ignition deploy ignition/modules/QuickstartToken.ts --network localPrividium
```

```bash
npx hardhat ignition deploy ignition/modules/QuickstartToken.ts --network testnetPrividium
```

You should see the contract address logged in your console. Now the contract is deployed on your Prividium network! In
the next section, you will learn how to configure the contract permissions.
