> ## 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.

# Setup

> Basic setup and initialization for using @zkp2p/contracts-v2

This guide covers the basic setup for using the `@zkp2p/contracts-v2` package in your TypeScript/JavaScript project.

## Quick Start

Here's a complete example of setting up contract instances:

```typescript theme={null}
import { ethers } from 'ethers';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator, Escrow } from '@zkp2p/contracts-v2/abis/base';
import { USDC, INTENT_EXPIRATION_PERIOD } from '@zkp2p/contracts-v2/constants/base';

// Set up provider
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');

// Create contract instances
const orchestrator = new ethers.Contract(
  base.Orchestrator,
  Orchestrator,
  provider
);

const escrow = new ethers.Contract(
  base.Escrow,
  Escrow,
  provider
);

// Use protocol constants
console.log('USDC Address:', USDC);
console.log('Intent Expiration:', INTENT_EXPIRATION_PERIOD);
```

## Module Structure

The package uses subpath exports for clean, tree-shakeable imports:

```typescript theme={null}
// Network-specific imports
import { base, baseSepolia } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';
import { USDC } from '@zkp2p/contracts-v2/constants/base';
import { base as paymentMethods } from '@zkp2p/contracts-v2/paymentMethods';

// Utility imports
import { getKeccak256Hash, calculateIntentHash } from '@zkp2p/contracts-v2/utils/protocolUtils';

// Type imports
import type { Escrow, Orchestrator } from '@zkp2p/contracts-v2/types';
```

## TypeScript Configuration

For optimal TypeScript support, ensure your `tsconfig.json` includes:

```json tsconfig.json theme={null}
{
  "compilerOptions": {
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "strict": true
  }
}
```

## Working with Different Networks

The package supports multiple networks. Import network-specific modules:

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

  const orchestratorAddress = base.Orchestrator;
  const orchestratorABI = baseAbis.Orchestrator;
  ```

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

  const orchestratorAddress = baseSepolia.Orchestrator;
  const orchestratorABI = baseSepoliaAbis.Orchestrator;
  ```
</CodeGroup>

## ESM vs CommonJS

The package supports both ESM and CommonJS:

<CodeGroup>
  ```typescript ESM (import) theme={null}
  import { base } from '@zkp2p/contracts-v2/addresses';
  import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';
  ```

  ```javascript CommonJS (require) theme={null}
  const { base } = require('@zkp2p/contracts-v2/addresses');
  const { Orchestrator } = require('@zkp2p/contracts-v2/abis/base');
  ```
</CodeGroup>

## React Native Support

The package includes React Native-specific exports:

```typescript theme={null}
// These automatically resolve to the correct format for React Native
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Contract Addresses" icon="location-dot" href="/sdk/addresses">
    Learn how to access contract addresses
  </Card>

  <Card title="ABIs" icon="file-code" href="/sdk/abis">
    Work with contract ABIs
  </Card>

  <Card title="Constants" icon="hashtag" href="/sdk/constants">
    Use protocol constants
  </Card>

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