> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hamilton.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Mint and redeem from code

> How Mint Users and approved routes create and redeem USDh directly on the contract.

**Minting and redeeming happen on the contract itself, one for one, in a single transaction.** Only wallets Hamilton has approved can call these functions. To become one, see [How it works](https://docs.hamilton.xyz/using-hamilton/minting-and-redeeming-primary-users.md) or email [partners@hamilton.xyz](mailto:partners@hamilton.xyz).

## Who can call what

* **Approval is per calling address.** Minting and redeeming are approved separately. Check them with `mintWhitelist(address)` and `redeemWhitelist(address)`.
* **The contract checks the caller, not the receiver.** An approved route can mint USDh straight to its user's wallet.
* **Accepted stablecoins** are listed by `supportedStables()`. Today that is USDC only.

## Mint

**1. Approve the stablecoin**

Approve the USDh contract to take the stablecoin amount from your wallet.

**2. Call mintWithStable**

The contract takes the stablecoin and sends the same amount of USDh to `to`, in the same transaction.

```typescript mint.ts theme={null}
import { parseUnits } from "viem";

const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const USDH = "0xbcFC42391e55484129191eDfcC766a2c6F9eb503";
const amount = parseUnits("100000", 6); // 100,000 USDC

await walletClient.writeContract({
  address: USDC, abi: erc20Abi, functionName: "approve", args: [USDH, amount],
});

await walletClient.writeContract({
  address: USDH, abi: usdhAbi, functionName: "mintWithStable",
  args: [USDC, amount, recipient], // recipient receives 100,000 USDh
});
```

There is no daily cap when minting with a stablecoin. The daily cap only applies to USDh created against bank wires.

## Redeem

Call `redeemForStable(stable, usdhAmount, to)`. The USDh is burned from the caller, and the same amount of the stablecoin is sent to `to`.

```typescript redeem.ts theme={null}
await walletClient.writeContract({
  address: USDH, abi: usdhAbi, functionName: "redeemForStable",
  args: [USDC, parseUnits("50000", 6), recipient], // recipient receives 50,000 USDC
});
```

## The redemption limit

Each address has its own limit in each 7-day window.

| | |
| - | - |
| Default limit | Half the USDh balance of the address at the moment USDh was last minted to it |
| Window | Opens with the first redemption, resets 7 days later |
| Check it | `effectiveRedeemCap(address)` returns the limit. `redeemedInWindow(address)` returns what is used |
| Higher or no limit | Can be agreed with Hamilton for an address |

> [!WARNING]
>
> If your contract mints to your users instead of to itself, your own address never receives a balance, so its default limit stays at zero. Redemptions then fail with `redeem cap not set`. Ask Hamilton to set a limit for your address before you go live.

## Minimal interface

```solidity IUSDh.sol theme={null}
interface IUSDh {
    function mintWithStable(address stable, uint256 stableAmount, address to) external;
    function redeemForStable(address stable, uint256 usdhAmount, address to) external;
    function supportedStables() external view returns (address[] memory);
    function mintWhitelist(address user) external view returns (bool);
    function redeemWhitelist(address user) external view returns (bool);
    function effectiveRedeemCap(address user) external view returns (uint256);
    function redeemedInWindow(address user) external view returns (uint256);
    function frozen(address account) external view returns (bool);
    function paused() external view returns (bool);
}
```

## Go-live checklist

1. Hamilton has confirmed which of your addresses can mint and which can redeem.
2. You have tested a small mint and a small redemption.
3. Your redemption limit is set, if your contract mints to your users.
4. Your sanctions screening matches what your agreement with Hamilton requires.

*Last updated: 17 November 2026*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.