0xSpaceShard / starknet-devnet-js

Starknet Devnet provider
MIT License
7 stars 1 forks source link
devnet json-rpc l1-l2 l1-l2-conversation l2 starknet starkware

npm package

Introduction

Using this JavaScript/TypeScript library, you can interact with Starknet Devnet via its specific Devnet API. To interact with any Starknet node or network (including Starknet Devnet) via the Starknet JSON-RPC API, see starknet.js.

Installation

$ npm i starknet-devnet

Compatibility

This library is compatible with stable Devnet versions in the inclusive range: v0.1.1-v0.1.2.

Usage

The main export of this package is DevnetProvider. Assuming you have a running Devnet, simply import DevnetProvider in your JS/TS program and interact with the Devnet instance:

import { DevnetProvider } from "starknet-devnet";

async function helloDevnet() {
    const devnet = new DevnetProvider(); // accepts an optional configuration object
    console.log(await devnet.isAlive()); // true
}

L1-L2 communication

Assuming there is an L1 provider running (e.g. anvil), use the postman property of DevnetProvider to achieve L1-L2 communication.

Examples

See the test directory for usage examples.