|
| 1 | +# Hyperlane Starknet Core |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Pre-compiled Cairo contract ABI artifacts |
| 8 | +- TypeScript bindings for Starknet contracts |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +```bash |
| 13 | +# Install with NPM |
| 14 | +npm install @hyperlane-xyz/starknet-core |
| 15 | + |
| 16 | +# Or with Yarn |
| 17 | +yarn add @hyperlane-xyz/starknet-core |
| 18 | +``` |
| 19 | + |
| 20 | +## Requirements |
| 21 | + |
| 22 | +- Node.js 18 or newer |
| 23 | +- For development: `curl`, `jq`, and `unzip` utilities |
| 24 | + |
| 25 | +## Usage |
| 26 | + |
| 27 | +```typescript |
| 28 | +import { |
| 29 | + ContractType, |
| 30 | + getCompiledContract, |
| 31 | +} from '@hyperlane-xyz/starknet-core'; |
| 32 | + |
| 33 | +// Get the Hyperlane mailbox contract |
| 34 | +const mailboxContract = getCompiledContract('mailbox'); |
| 35 | + |
| 36 | +// Get token contracts |
| 37 | +const tokenContract = getCompiledContract('erc20', ContractType.TOKEN); |
| 38 | + |
| 39 | +// Get mock contracts |
| 40 | +const mockContract = getCompiledContract('mock_validator', ContractType.MOCK); |
| 41 | +``` |
| 42 | + |
| 43 | +## Contract Categories |
| 44 | + |
| 45 | +Contracts are organized into three categories: |
| 46 | + |
| 47 | +- `contracts`: Core Hyperlane protocol contracts |
| 48 | +- `tokens`: Token implementation contracts |
| 49 | +- `mocks`: Test and mock contracts |
| 50 | + |
| 51 | +## Development |
| 52 | + |
| 53 | +### Setup |
| 54 | + |
| 55 | +1. Clone the repository |
| 56 | +2. Install dependencies: `yarn install` |
| 57 | + |
| 58 | +### Build Process |
| 59 | + |
| 60 | +The build process combines multiple steps in a specific order: |
| 61 | + |
| 62 | +```bash |
| 63 | +yarn build |
| 64 | +``` |
| 65 | + |
| 66 | +This command runs: |
| 67 | + |
| 68 | +1. TypeScript compilation (`tsc`) |
| 69 | +2. Fetching contract artifacts from GitHub (`fetch-contracts`) |
| 70 | +3. Generating TypeScript ABI artifacts from Cairo contracts (`generate-artifacts`) |
| 71 | + |
| 72 | +All build output is placed in the `dist` directory. |
| 73 | + |
| 74 | +### Individual Build Steps |
| 75 | + |
| 76 | +You can also run the individual build steps separately: |
| 77 | + |
| 78 | +#### Fetching Contract Artifacts |
| 79 | + |
| 80 | +```bash |
| 81 | +yarn fetch-contracts |
| 82 | +``` |
| 83 | + |
| 84 | +This downloads the contract artifacts from the [Hyperlane Starknet repository](https://github.com/hyperlane-xyz/hyperlane_starknet). |
| 85 | + |
| 86 | +#### Generating TypeScript Artifacts |
| 87 | + |
| 88 | +```bash |
| 89 | +yarn generate-artifacts |
| 90 | +``` |
| 91 | + |
| 92 | +This creates JavaScript and TypeScript declaration files in the `dist/artifacts` directory. |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +Apache 2.0 |
0 commit comments