# Hyperlane Starknet Core

The Hyperlane Starknet Core package provides TypeScript tooling for interacting with Hyperlane's Cairo contracts on Starknet. It includes TypeScript artifacts autogenerated from Cairo contracts developed in collaboration with Astraly Labs.

## Features

- Pre-compiled Cairo contract ABI artifacts
- TypeScript bindings for Starknet contracts

## Installation

```bash
# Install with NPM
npm install @hyperlane-xyz/starknet-core

# Or with pnpm
pnpm add @hyperlane-xyz/starknet-core
```

## Requirements

- Node.js 18 or newer
- For development: `curl`, `jq`, and `unzip` utilities

## Usage

```typescript
import {
  ContractType,
  getCompiledContract,
} from '@hyperlane-xyz/starknet-core';

// Get the Hyperlane mailbox contract
const mailboxContract = getCompiledContract('mailbox');

// Get token contracts
const tokenContract = getCompiledContract('erc20', ContractType.TOKEN);

// Get mock contracts
const mockContract = getCompiledContract('mock_validator', ContractType.MOCK);
```

## Contract Categories

Contracts are organized into three categories:

- `contracts`: Core Hyperlane protocol contracts
- `tokens`: Token implementation contracts
- `mocks`: Test and mock contracts

## Development

### Setup

1. Clone the repository
2. Install dependencies: `pnpm install`

### Build Process

The build process combines multiple steps in a specific order:

```bash
pnpm build
```

This command runs:

1. TypeScript compilation (`tsc`)
2. Fetching contract artifacts from GitHub (`fetch-contracts`)
3. Generating TypeScript ABI artifacts from Cairo contracts (`generate-artifacts`)

All build output is placed in the `dist` directory.

### Individual Build Steps

You can also run the individual build steps separately:

#### Fetching Contract Artifacts

```bash
pnpm fetch-contracts
```

This downloads the contract artifacts from the [Hyperlane Starknet repository](https://github.com/hyperlane-xyz/hyperlane_starknet).

#### Generating TypeScript Artifacts

```bash
pnpm generate-artifacts
```

This creates JavaScript and TypeScript declaration files in the `dist/artifacts` directory.

## License

Apache 2.0
