npm package: @jejunetwork/contracts
Description: Jeju smart contract ABIs, types, and deployment addresses
Latest version: 0.1.0

# @jejunetwork/contracts

Smart contracts, ABIs, types, and deployment addresses for Jeju Network.

## Installation

```bash
# In your app package.json:
{
  "dependencies": {
    "@jejunetwork/contracts": "workspace:*"
  }
}

# Then run
bun install
```

## Usage

### Import Contract Addresses

```typescript
import { 
  getContractAddresses,
  getContractAddressesByNetwork,
  getIdentityRegistry,
  getBazaarMarketplace,
  getERC20Factory,
} from '@jejunetwork/contracts';

// Get all addresses for a specific chain
const addresses = getContractAddresses(1337);
console.log(addresses.identityRegistry);
console.log(addresses.marketplace);
console.log(addresses.poolManager);

// Or by network name
const testnetAddresses = getContractAddressesByNetwork('testnet');
```

### Import ABIs

```typescript
import {
  ERC20Abi,
  ERC20FactoryAbi,
  BazaarAbi,
  IdentityRegistryAbi,
} from '@jejunetwork/contracts';

// Use with viem
import { createPublicClient, http } from 'viem';

const client = createPublicClient({ transport: http() });
const balance = await client.readContract({
  address: tokenAddress,
  abi: ERC20Abi,
  functionName: 'balanceOf',
  args: [userAddress],
});
```

### Import Types

```typescript
import type {
  ChainId,
  NetworkName,
  ContractAddresses,
  UniswapV4Deployment,
  BazaarMarketplaceDeployment,
} from '@jejunetwork/contracts';

// Helper functions
import { isValidAddress, ZERO_ADDRESS, CHAIN_IDS } from '@jejunetwork/contracts';

if (isValidAddress(address)) {
  // address is typed as Address
}
```

### Direct JSON Imports

```typescript
// Import deployment files directly
import uniswapV4 from '@jejunetwork/contracts/deployments/uniswap-v4-1337.json';
import bazaar from '@jejunetwork/contracts/deployments/bazaar-marketplace-1337.json';

// Import ABIs directly  
import { abi } from '@jejunetwork/contracts/abis/IdentityRegistry.json';
```

## Exports

### ABIs (`@jejunetwork/contracts/abis`)

- `ERC20Abi` - Standard ERC20 token
- `ERC20FactoryAbi` - Token factory contract
- `BazaarAbi` - NFT marketplace
- `IdentityRegistryAbi` - ERC-8004 agent registry

### Deployment Helpers (`@jejunetwork/contracts/deployments`)

- `getContractAddresses(chainId)` - Get all addresses for a chain
- `getContractAddressesByNetwork(network)` - Get addresses by network name
- `getUniswapV4(chainId)` - Uniswap V4 addresses
- `getBazaarMarketplace(chainId)` - Marketplace address
- `getERC20Factory(chainId)` - Token factory address
- `getIdentityRegistry(chainId)` - Identity registry address

### Types

- `ChainId` - 1337 | 420690 | 420691 | 11155111 | 1
- `NetworkName` - 'localnet' | 'testnet' | 'mainnet'
- `ContractAddresses` - Full address interface
- `UniswapV4Deployment`, `BazaarMarketplaceDeployment`, etc.

### Constants

- `CHAIN_IDS` - Chain ID constants
- `ZERO_ADDRESS` - `0x0000...000`
- `isValidAddress(addr)` - Check if address is valid

---

## Solidity Development

### Setup

```bash
cd packages/contracts
forge install
```

### Build

```bash
forge build
```

### Test

```bash
# All tests
forge test

# Registry tests only
make test-registry

# Specific test
forge test --match-contract IdentityRegistryTest
```

### Deploy

```bash
# Localnet
make deploy-local

# Testnet
export NETWORK=testnet
export DEPLOYER_PRIVATE_KEY=0x...
forge script script/DeployLiquiditySystem.s.sol \
  --rpc-url https://testnet-rpc.jeju.network \
  --broadcast \
  --verify
```

Deployment addresses are saved to `deployments/{network}/`.

---

## Open Intents Framework (OIF)

Cross-chain intent contracts in `src/oif/`:

| Contract | Purpose |
|----------|---------|
| `InputSettler.sol` | User intent creation, fund locking, refunds |
| `OutputSettler.sol` | Solver fills, output delivery |
| `SolverRegistry.sol` | Solver registration, staking, slashing |
| `OracleAdapter.sol` | Cross-chain attestation (Simple, Hyperlane, Superchain) |
| `IOIF.sol` | ERC-7683 compatible interfaces |

### Deploy OIF

```bash
# Deploy to any chain
PRIVATE_KEY=$DEPLOYER_PRIVATE_KEY forge script script/DeployOIF.s.sol \
  --rpc-url $RPC_URL \
  --broadcast \
  --verify

# Configure oracle type (optional)
ORACLE_TYPE=hyperlane HYPERLANE_MAILBOX=0x... \
  forge script script/DeployOIF.s.sol ...
```

### Test OIF

```bash
# All OIF tests (70 tests)
forge test --match-path "test/OIF*.sol"

# Specific test file
forge test --match-path "test/OIF.t.sol"
forge test --match-path "test/OIF.edge.t.sol"
forge test --match-path "test/OIF.full.t.sol"
```

### Import OIF ABIs

```typescript
import { 
  InputSettlerAbi,
  OutputSettlerAbi,
  SolverRegistryAbi,
  OracleAdapterAbi,
} from '@jejunetwork/contracts';

// Use with viem
const result = await client.readContract({
  address: inputSettlerAddress,
  abi: InputSettlerAbi,
  functionName: 'getOrder',
  args: [orderId],
});
```

See `apps/intents/README.md` for full OIF documentation.