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.
$ npm i starknet-devnet
This library is compatible with stable Devnet versions in the inclusive range: v0.1.1
-v0.1.2
.
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
}
Assuming there is an L1 provider running (e.g. anvil), use the postman
property of DevnetProvider
to achieve L1-L2 communication.
See the test
directory for usage examples.