> For the complete documentation index, see [llms.txt](https://yuga.gitbook.io/zkyuga-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga.gitbook.io/zkyuga-whitepaper/developer-guide/erc20/mint.md).

# mint

The `mint` function is utilized to generate and allocate a specified quantity of tokens to a designated Ethereum address. This functionality is primarily associated with Mintable ERC20 tokens, where only specific roles, such as the owner or minter, possess the authority to execute this action within the token contract. The availability and functionality of this method depend on the unique implementation of the ERC20 token. Here, we assume the presence of the method within the `ERC20Instance` object, derived from the `getERC20Instance` function of `ZkyugaClient`.

### Function Signature

```javascript
async mint(to: string, amount: BigNumberish, signer: WalletSigner): Promise<TransactionResponse>
```

#### Parameters

| Parameter | Type         | Description                                                                                                                                                                                                                                                 |
| --------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| to        | string       | The Ethereum address designated to receive the newly minted tokens.                                                                                                                                                                                         |
| amount    | BigNumberish | The quantity of tokens to be created, specified in the smallest unit of the token (e.g., Wei for Ether). This value can be provided as a number, string, or BigNumber.                                                                                      |
| signer    | WalletSigner | The wallet signer instance responsible for endorsing the minting transaction. Typically, this signer represents an address with minting authorizations in the token contract, often instantiated using the `createWalletSigner` function of `ZkyugaClient`. |

#### Returns

* A `Promise` resolving to a `TransactionResponse` object, providing details of the minting transaction, including its status and transaction hash.

### Usage Example

Begin by obtaining an instance of the desired ERC20 token contract:

```javascript
const erc20 = zkyugaClient.getERC20Instance("0x742d35Cc6634C0532925a3b844Bc454e4438f44e");
```

Then, utilize the `mint` function to create new tokens:

```javascript
const recipientAddress = "0xa3ACa2a43F8E1C9b7bDBb1908A0cfBF16fE8B3E1";
const mintAmount = "2000000000000000000"; // Symbolizing 2 tokens, given 18 decimals are in play
const signer = zkyugaClient.createWalletSigner("private key imbued with minting rights");

const transactionResponse = await erc20.mint(recipientAddress, mintAmount, signer);
console.log(`Transaction Hash: ${transactionResponse.hash}`);
```

### Considerations

* Ensure that the signer's address possesses the necessary permissions within the token contract to initiate the minting process.
* The `minting` amount must be specified in the token's smallest divisible unit. Always verify the accuracy of conversions before determining the minting quantity.
* Exercise caution when managing your private keys. Safeguard the signer to prevent the exposure of private keys in insecure environments.

***
