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

# Contract ABIs

> Use contract ABIs from the package

The `@zkp2p/contracts-v2` package provides minimal, network-specific ABIs extracted from on-chain deployments.

## Import ABIs

Import ABIs for specific contracts on a network:

```typescript theme={null}
import { Orchestrator, Escrow, UnifiedPaymentVerifier } from '@zkp2p/contracts-v2/abis/base';

// Use with ethers or viem
const orchestratorABI = Orchestrator;
```

## Network-Specific ABIs

ABIs are organized by network to ensure compatibility:

<CodeGroup>
  ```typescript Base Mainnet theme={null}
  import { 
    Orchestrator, 
    Escrow, 
    UnifiedPaymentVerifier,
    AcrossBridgeHook 
  } from '@zkp2p/contracts-v2/abis/base';
  ```

  ```typescript Base Sepolia (Testnet) theme={null}
  import { 
    Orchestrator, 
    Escrow, 
    UnifiedPaymentVerifier 
  } from '@zkp2p/contracts-v2/abis/baseSepolia';
  ```

  ```typescript Base Staging theme={null}
  import { 
    Orchestrator, 
    Escrow, 
    UnifiedPaymentVerifier 
  } from '@zkp2p/contracts-v2/abis/baseStaging';
  ```
</CodeGroup>

## Available Contract ABIs

### Core Contracts

| Contract                 | Description                                     |
| ------------------------ | ----------------------------------------------- |
| `Orchestrator`           | Main protocol orchestrator for managing intents |
| `Escrow`                 | Handles deposit escrow and fund management      |
| `UnifiedPaymentVerifier` | Verifies ZK proofs for payment validation       |

### Hooks

| Contract           | Description                        | Networks          |
| ------------------ | ---------------------------------- | ----------------- |
| `AcrossBridgeHook` | Across Protocol bridge integration | Base mainnet only |

## Using with ethers.js

### Read Contract Data

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

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

const orchestrator = new ethers.Contract(
  base.Orchestrator,
  Orchestrator,
  provider
);

// Read contract state
const intentExpiration = await orchestrator.intentExpirationPeriod();
const takerFee = await orchestrator.takerFee();
const escrowAddress = await orchestrator.escrow();
```

### Write to Contracts

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

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

const orchestrator = new ethers.Contract(
  base.Orchestrator,
  Orchestrator,
  signer
);

// Signal intent
const tx = await orchestrator.signalIntent(
  depositId,
  amount,
  to,
  paymentMethodHash,
  currencyHash,
  priceLimit,
  paymentIdentifier,
  encryptedPaymentDetails
);

await tx.wait();
console.log('Intent signaled:', tx.hash);
```

## Using with viem

### Read Contract

```typescript theme={null}
import { createPublicClient, http } from 'viem';
import { base as baseChain } from 'viem/chains';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

const client = createPublicClient({
  chain: baseChain,
  transport: http(),
});

const intentExpiration = await client.readContract({
  address: base.Orchestrator,
  abi: Orchestrator,
  functionName: 'intentExpirationPeriod',
});
```

### Write Contract

```typescript theme={null}
import { createWalletClient, custom } from 'viem';
import { base as baseChain } from 'viem/chains';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

const client = createWalletClient({
  chain: baseChain,
  transport: custom(window.ethereum),
});

const hash = await client.writeContract({
  address: base.Orchestrator,
  abi: Orchestrator,
  functionName: 'signalIntent',
  args: [
    depositId,
    amount,
    to,
    paymentMethodHash,
    currencyHash,
    priceLimit,
    paymentIdentifier,
    encryptedPaymentDetails,
  ],
});
```

## Direct JSON Import

For bundle size optimization, import JSON files directly:

```typescript theme={null}
import OrchestratorABI from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';
import EscrowABI from '@zkp2p/contracts-v2/abis/base/Escrow.json';

const orchestrator = new ethers.Contract(
  address,
  OrchestratorABI,
  provider
);
```

## Import All ABIs for a Network

Import all ABIs as a single object:

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

console.log(baseAbis.Orchestrator);
console.log(baseAbis.Escrow);
console.log(baseAbis.UnifiedPaymentVerifier);
```

## TypeScript Types

For TypeScript contract types, use the types export:

```typescript theme={null}
import type { Orchestrator, Escrow } from '@zkp2p/contracts-v2/types';

// Use types for type-safe contract interactions
type OrchestratorContract = Orchestrator;
```

## ABI Structure

ABIs follow the standard Ethereum ABI format:

```typescript theme={null}
type ABI = Array<{
  type: 'function' | 'event' | 'error' | 'constructor';
  name?: string;
  inputs?: Array<{ name: string; type: string; internalType?: string }>;
  outputs?: Array<{ name: string; type: string; internalType?: string }>;
  stateMutability?: 'pure' | 'view' | 'nonpayable' | 'payable';
}>;
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Contract Addresses" icon="location-dot" href="/sdk/addresses">
    Access deployed contract addresses
  </Card>

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

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