> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zkp2p/zkp2p-contracts/llms.txt
> Use this file to discover all available pages before exploring further.

# Protocol Constants

> Access protocol constants and configuration values

The `@zkp2p/contracts-v2/constants` module provides network-specific protocol parameters and configuration values.

## Import Constants

Import constants for a specific network:

```typescript theme={null}
import { 
  USDC,
  INTENT_EXPIRATION_PERIOD,
  MAX_INTENTS_PER_DEPOSIT,
  PROTOCOL_TAKER_FEE,
  ESCROW_DUST_THRESHOLD
} from '@zkp2p/contracts-v2/constants/base';

console.log('USDC Address:', USDC);
console.log('Intent Expiration:', INTENT_EXPIRATION_PERIOD, 'seconds');
```

## Network-Specific Constants

Constants vary by network:

<CodeGroup>
  ```typescript Base Mainnet theme={null}
  import * as baseConstants from '@zkp2p/contracts-v2/constants/base';

  console.log('USDC:', baseConstants.USDC);
  console.log('Intent Expiration:', baseConstants.INTENT_EXPIRATION_PERIOD);
  console.log('Taker Fee:', baseConstants.PROTOCOL_TAKER_FEE);
  ```

  ```typescript Base Sepolia (Testnet) theme={null}
  import * as baseSepoliaConstants from '@zkp2p/contracts-v2/constants/baseSepolia';

  console.log('USDC:', baseSepoliaConstants.USDC);
  console.log('Intent Expiration:', baseSepoliaConstants.INTENT_EXPIRATION_PERIOD);
  ```
</CodeGroup>

## Available Constants

### Token Addresses

<ParamField path="USDC" type="string">
  Address of the USDC token contract on the network

  ```typescript theme={null}
  import { USDC } from '@zkp2p/contracts-v2/constants/base';
  // "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  ```
</ParamField>

### Protocol Parameters

<ParamField path="INTENT_EXPIRATION_PERIOD" type="string">
  Time in seconds before an intent expires

  ```typescript theme={null}
  import { INTENT_EXPIRATION_PERIOD } from '@zkp2p/contracts-v2/constants/base';
  // "3600" (1 hour)
  ```
</ParamField>

<ParamField path="MAX_INTENTS_PER_DEPOSIT" type="number">
  Maximum number of intents allowed per deposit

  ```typescript theme={null}
  import { MAX_INTENTS_PER_DEPOSIT } from '@zkp2p/contracts-v2/constants/base';
  // 5
  ```
</ParamField>

<ParamField path="PROTOCOL_TAKER_FEE" type="string">
  Protocol fee charged to takers (in basis points)

  ```typescript theme={null}
  import { PROTOCOL_TAKER_FEE } from '@zkp2p/constants/base';
  // "50" (0.5%)
  ```
</ParamField>

<ParamField path="ESCROW_DUST_THRESHOLD" type="string">
  Minimum amount threshold for escrow dust collection

  ```typescript theme={null}
  import { ESCROW_DUST_THRESHOLD } from '@zkp2p/contracts-v2/constants/base';
  // "1000000" (1 USDC, 6 decimals)
  ```
</ParamField>

### Admin Addresses

<ParamField path="MULTI_SIG" type="string">
  Address of the protocol multisig wallet

  ```typescript theme={null}
  import { MULTI_SIG } from '@zkp2p/contracts-v2/constants/base';
  ```
</ParamField>

<ParamField path="PROTOCOL_TAKER_FEE_RECIPIENT" type="string">
  Address that receives protocol taker fees

  ```typescript theme={null}
  import { PROTOCOL_TAKER_FEE_RECIPIENT } from '@zkp2p/contracts-v2/constants/base';
  ```
</ParamField>

<ParamField path="ESCROW_DUST_RECIPIENT" type="string">
  Address that receives dust from escrow contract

  ```typescript theme={null}
  import { ESCROW_DUST_RECIPIENT } from '@zkp2p/contracts-v2/constants/base';
  ```
</ParamField>

### Verifier Addresses

<ParamField path="WITNESS_ADDRESS" type="string">
  Address of the witness service for off-chain verification

  ```typescript theme={null}
  import { WITNESS_ADDRESS } from '@zkp2p/contracts-v2/constants/base';
  ```
</ParamField>

<ParamField path="ZKTLS_ATTESTOR_ADDRESS" type="string">
  Address of the zkTLS attestor service

  ```typescript theme={null}
  import { ZKTLS_ATTESTOR_ADDRESS } from '@zkp2p/contracts-v2/constants/base';
  ```
</ParamField>

## Using Constants in Your Code

### Calculate Fees

```typescript theme={null}
import { ethers } from 'ethers';
import { PROTOCOL_TAKER_FEE } from '@zkp2p/contracts-v2/constants/base';

function calculateTakerFee(amount: bigint): bigint {
  const feeBps = BigInt(PROTOCOL_TAKER_FEE);
  return (amount * feeBps) / 10000n;
}

const orderAmount = ethers.utils.parseUnits('100', 6); // 100 USDC
const fee = calculateTakerFee(BigInt(orderAmount.toString()));

console.log('Fee:', ethers.utils.formatUnits(fee, 6), 'USDC');
// Fee: 0.5 USDC
```

### Check Intent Expiration

```typescript theme={null}
import { INTENT_EXPIRATION_PERIOD } from '@zkp2p/contracts-v2/constants/base';

function isIntentExpired(intentTimestamp: number): boolean {
  const expirationPeriod = parseInt(INTENT_EXPIRATION_PERIOD);
  const now = Math.floor(Date.now() / 1000);
  return now > intentTimestamp + expirationPeriod;
}

const intentCreatedAt = 1709568000; // Unix timestamp
const expired = isIntentExpired(intentCreatedAt);
```

### Validate Deposit Intent Count

```typescript theme={null}
import { MAX_INTENTS_PER_DEPOSIT } from '@zkp2p/contracts-v2/constants/base';

function canAddIntent(currentIntentCount: number): boolean {
  return currentIntentCount < MAX_INTENTS_PER_DEPOSIT;
}

const currentIntents = 3;
if (canAddIntent(currentIntents)) {
  console.log('Can signal another intent');
}
```

## Import All Constants

Import all constants as a single object:

```typescript theme={null}
import * as constants from '@zkp2p/contracts-v2/constants/base';

console.log('All constants:', constants);

// Access individual constants
const usdcAddress = constants.USDC;
const intentExpiration = constants.INTENT_EXPIRATION_PERIOD;
```

## Direct JSON Import

For bundle size optimization:

```typescript theme={null}
import baseConstants from '@zkp2p/contracts-v2/constants/base.json';

console.log(baseConstants.USDC);
console.log(baseConstants.INTENT_EXPIRATION_PERIOD);
```

## Type Definitions

Constants are strongly typed:

```typescript theme={null}
interface Constants {
  USDC?: `0x${string}`;
  INTENT_EXPIRATION_PERIOD?: string;
  MAX_INTENTS_PER_DEPOSIT?: number;
  PROTOCOL_TAKER_FEE?: string;
  PROTOCOL_TAKER_FEE_RECIPIENT?: string;
  ESCROW_DUST_RECIPIENT?: string;
  ESCROW_DUST_THRESHOLD?: string;
  MULTI_SIG?: string;
  WITNESS_ADDRESS?: string;
  ZKTLS_ATTESTOR_ADDRESS?: string;
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Payment Methods" icon="credit-card" href="/sdk/payment-methods">
    Work with payment method configurations
  </Card>

  <Card title="Utilities" icon="wrench" href="/sdk/utilities">
    Use protocol utility functions
  </Card>
</CardGroup>
