# Permissioned Minting Contract

This repository contains a permissioned minting contract implementation. The flow involves deploying contracts, granting roles, and minting tokens based on permissions.

## Configuration and Flow:

Follow these steps to configure and interact with the permissioned minting contract.

### 1. **Deploy Permissioned Manager Contract**

Deploy the **JiritsuERC20PermissionedMintingManagerV2** contract which will manage minting credits.

```sh
node ./scripts/JiritsuERC20PermissionedMintingManagerV2/deploy.js
```

### 2. **Add Minting Credits**

Add minting credits to the manager contract. Replace `100` with the number of credits you want to add.

```sh
node ./scripts/JiritsuERC20PermissionedMintingManagerV2/addMintingCredits.js --amount 100
```

### 3. **Grant Credit Reporter Role**

Grant the **CREDIT_REPORTER_ROLE** to a specific address. Replace the address with the appropriate one.

```sh
node ./scripts/JiritsuERC20PermissionedMintingManagerV2/grantRole.js --role CREDIT_REPORTER_ROLE --address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
```

### 4. **Deploy Permissioned Minting ERC20 Contract**

Deploy the **JiritsuPermissionedMintingERC20** contract to manage ERC20 minting.

```sh
node ./scripts/JiritsuPermissionedMintingERC20/deploy.js
```

### 5. **Grant Minting Role**

Grant the **MINTING_ROLE** to a specific address so it can mint tokens. Replace the address with the appropriate one.

```sh
node ./scripts/JiritsuPermissionedMintingERC20/grantRole.js --role MINTING_ROLE --address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
```

### 6. **Mint Tokens**

Mint ERC20 tokens to a specific address. Replace `20` with the number of tokens you want to mint, and the address with the recipient’s address.

```sh
node ./scripts/JiritsuPermissionedMintingERC20/mint.js --amount 20 --address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
```

### 7. **Set Permissioned Minting Manager**

Set the **JiritsuERC20PermissionedMintingManagerV2** contract address in the **JiritsuPermissionedMintingERC20** contract to manage minting permissions. Replace `"JiritsuERC20PermissionedMintingManagerV2 address"` with the actual deployed contract address.

```sh
node ./scripts/JiritsuPermissionedMintingERC20/setPermissionedMintingManager.js --address "JiritsuERC20PermissionedMintingManagerV2 address"
```

---

For verifying the contracts on the BSC chain, run:

```sh
npx hardhat run ./scripts/JiritsuPermissionedMintingERC20/verify.js --network bsc
npx hardhat run ./scripts/JiritsuERC20PermissionedMintingManagerV2/verify.js --network bsc
```

### Notes:

- Replace the sample address `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` with the correct address as needed.
- Ensure all contract addresses are properly recorded after deployment for future interactions.
