{"id":50291488,"url":"https://github.com/starknet-io/starknet-devnet-js","last_synced_at":"2026-06-08T10:00:31.488Z","repository":{"id":246072933,"uuid":"818335221","full_name":"starknet-io/starknet-devnet-js","owner":"starknet-io","description":"JS wrapper of starknet-devnet-rs","archived":false,"fork":false,"pushed_at":"2026-06-08T08:01:53.000Z","size":321,"stargazers_count":10,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-08T08:15:32.169Z","etag":null,"topics":["devnet","json-rpc","l1-l2","l1-l2-conversation","l2","starknet","starkware"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starknet-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-21T16:06:15.000Z","updated_at":"2026-06-08T07:56:49.000Z","dependencies_parsed_at":"2024-06-25T18:25:33.824Z","dependency_job_id":"bcfe4104-e644-402d-86d0-bf8b981b0771","html_url":"https://github.com/starknet-io/starknet-devnet-js","commit_stats":null,"previous_names":["0xspaceshard/starknet-devnet-js","starknet-io/starknet-devnet-js"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/starknet-io/starknet-devnet-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-io%2Fstarknet-devnet-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-io%2Fstarknet-devnet-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-io%2Fstarknet-devnet-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-io%2Fstarknet-devnet-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starknet-io","download_url":"https://codeload.github.com/starknet-io/starknet-devnet-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starknet-io%2Fstarknet-devnet-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34057158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devnet","json-rpc","l1-l2","l1-l2-conversation","l2","starknet","starkware"],"created_at":"2026-05-28T06:10:50.822Z","updated_at":"2026-06-08T10:00:31.482Z","avatar_url":"https://github.com/starknet-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm package](https://img.shields.io/npm/v/starknet-devnet?color=blue)](https://www.npmjs.com/package/starknet-devnet)\n\n# Introduction\n\nUsing this JavaScript/TypeScript library, you can spawn [Starknet Devnet](https://github.com/starknet-io/starknet-devnet/) without installing and running it in a separate terminal. You can interact with it via its specific [Devnet API](https://starknet-io.github.io/starknet-devnet/docs/api#devnet-api). To interact with any Starknet node or network (including Starknet Devnet) via the [Starknet JSON-RPC API](https://starknet-io.github.io/starknet-devnet/docs/api#starknet-api), see [starknet.js](https://www.starknetjs.com/).\n\n# Installation\n\n```\nnpm i starknet-devnet\n```\n\n# Compatibility\n\n## Devnet compatibility\n\nThis library version is compatible with Devnet `v0.8.2`.\n\n[Devnet's balance checking functionality](https://starknet-io.github.io/starknet-devnet/docs/balance#check-balance) is not provided in this library because it is simply replaceable using starknet.js, as witnessed by the [getAccountBalance](./test/util.ts#L61) function.\n\n## Environment compatibility\n\nThis library is intended for use with Node.js, not in a browser environment. In browsers, you can only use [`DevnetProvider`](#connect-to-a-running-instance) for connecting to an already running Devnet instance, but you cannot [spawn a new Devnet](#spawn-a-new-devnet), because that relies on modules not present in the browser engine.\n\nTo enable the use of `DevnetProvider` in browser, you need to configure sources for modules otherwise reported as not found. See [this issue](https://github.com/starknet-io/starknet-devnet-js/issues/26) and [this SO answer](https://stackoverflow.com/a/51669301) for more info, but generally, if using webpack, it should be enough to populate a config file with the desired polyfill implementations or with `false` values.\n\n# Usage\n\n## Spawn a new Devnet\n\nThis library allows you to spawn a Devnet instance inside your program, without a separate terminal. It finds a random free port, and releases all used resources on exit. You can specify a port of your choice via `args: [\"--port\", ...]`.\n\n### Spawn a version without manual installation\n\nAssuming your machine has a supported OS (macOS or Linux) and supported architecture (arm64/aarch64 or x64/x86_64), using `Devnet.spawnVersion` will quickly install and spawn a new Devnet.\n\n```typescript\nimport { Devnet } from \"starknet-devnet\";\n\nasync function main() {\n    // Specify anything from https://github.com/starknet-io/starknet-devnet/releases\n    // Be sure to include the 'v' if it's in the version name.\n    const devnet = await Devnet.spawnVersion(\"v0.6.1\");\n    console.log(await devnet.provider.isAlive()); // true\n}\n```\n\nTo use the latest compatible version:\n\n```typescript\nconst devnet = await Devnet.spawnVersion(\"latest\");\n```\n\n### Spawn an already installed Devnet\n\nAssuming you have already installed Devnet and it is present in your environment's `PATH`, simply run:\n\n```typescript\nconst devnet = await Devnet.spawnInstalled();\n```\n\n### Specify Devnet arguments\n\nYou can use the same CLI arguments you would pass to a Devnet running in a terminal:\n\n```typescript\nconst devnet = await Devnet.spawnInstalled({ args: [\"--predeployed-accounts\", \"3\"] });\n```\n\n### Devnet output\n\nBy default, the spawned Devnet inherits the output streams of the main program in which it is invoked. If you invoke your program in a terminal without any stream redirections, it will print Devnet logs in that same terminal together with your program output. This can be overriden:\n\n```typescript\nconst outputStream = fs.createWriteStream(\"devnet-out.txt\");\nawait events.once(outputStream, \"open\"); // necessary if specifying a --port, otherwise omissible\nconst devnet = await Devnet.spawnInstalled({\n    stdout: outputStream,\n    stderr: /* what you will, could be the same as stdout */,\n});\n// do stuff with devnet and then close the stream\noutputStream.end();\n```\n\nTo track the output in a separate terminal, open a new terminal and run:\n\n```\ntail -f devnet-out.txt\n```\n\nTo ignore the output completely, specify `{ stdout: \"ignore\", stderr: \"ignore\" }`.\n\n### Spawn a custom build\n\nIf you have a custom build of Devnet or have multiple custom versions present locally:\n\n```typescript\n// provide the command\nconst devnet = await Devnet.spawnCommand(\"my-devnet-command\", { ... });\n// or specify the path\nconst devnet = await Devnet.spawnCommand(\"/path/to/my-devnet-command\", { ... });\n```\n\n### Killing\n\nBy default, the Devnet subprocess automatically exits and releases the used resources on program end, but you can send it a signal if needed:\n\n```typescript\nconst devnet = await Devnet.spawnInstalled();\ndevnet.kill(...); // defaults to SIGTERM\n```\n\n### Keeping alive\n\nTo keep the spawned Devnet alive after your program exits, set the `keepAlive` flag:\n\n```typescript\nconst devnet = await Devnet.spawnInstalled({ keepAlive: true });\n```\n\nIn that case, you must take care of the spawned process after the program exits. To kill it, you need to:\n\n1. Know the port it is using. It is logged on Devnet startup and is also a part of `devnet.provider.url`.\n2. Kill the process using the port, which you can do:\n\n    a. In JS, by relying on the [cross-port-killer library](https://www.npmjs.com/package/cross-port-killer).\n\n    b. From shell, by executing `lsof -i :\u003cPORT\u003e | awk 'NR==2{print $2}' | xargs kill` (substitute `\u003cPORT\u003e` with yours).\n\n## Connect to a running instance\n\nIf there already is a running Devnet instance (e.g. in another terminal or in another JS/TS program), you can simply connect to it by importing `DevnetProvider`. [Read more](https://starknet-io.github.io/starknet-devnet/docs/category/running) about different ways of running Devnet.\n\n```typescript\nimport { DevnetProvider } from \"starknet-devnet\";\nconst devnet = new DevnetProvider(); // accepts an optional configuration object\nconsole.log(await devnet.isAlive()); // true\n```\n\n## Enabling Starknet API support\n\nSince this library only supports the [Devnet-specific API](https://starknet-io.github.io/starknet-devnet/docs/api#devnet-api), to interact via [Starknet JSON-RPC API](https://starknet-io.github.io/starknet-devnet/docs/api#starknet-api), use [starknet.js](https://www.starknetjs.com/).\n\nE.g. to get the latest block after spawning Devnet, you would need to do:\n\n```typescript\nimport { Devnet } from \"starknet-devnet\";\nimport * as starknet from \"starknet\";\n\nconst devnet = await Devnet.spawnInstalled();\nconst starknetProvider = new starknet.RpcProvider({ nodeUrl: devnet.provider.url });\n\nconst block = await starknetProvider.getBlock(\"latest\");\n```\n\n## L1-L2 communication\n\nAssuming there is an L1 provider running (e.g. [anvil](https://github.com/foundry-rs/foundry/tree/master/crates/anvil)), use the `postman` property of `DevnetProvider` to achieve [L1-L2 communication](https://starknet-io.github.io/starknet-devnet/docs/postman). See [this example](https://github.com/starknet-io/starknet-devnet-js/blob/master/test/l1-l2-postman.test.ts) for more info.\n\n## Transaction Proofs\n\nUse the `proofs` property of `DevnetProvider` to prove INVOKE v3 transactions. This is useful for testing proof-aware flows in your application. See the [Devnet proofs documentation](https://starknet-io.github.io/starknet-devnet/docs/proofs) for more details on proof modes.\n\n**Note:** Before calling `proveTransaction`, Devnet requires at least 10 blocks to exist. Start Devnet with `--proof-mode devnet` to enable this feature.\n\n```typescript\nimport { Devnet } from \"starknet-devnet\";\nimport * as starknet from \"starknet\";\n\nconst devnet = await Devnet.spawnInstalled({ args: [\"--proof-mode\", \"devnet\"] });\n\n// ... ensure at least 10 blocks exist (e.g. via devnet.provider.createBlock()) ...\n\n// Build an INVOKE v3 transaction payload\nconst invokeTx = {\n    type: \"INVOKE\" as const,\n    version: \"0x3\" as const,\n    sender_address: account.address,\n    calldata: [\"0x1\", \"0x2\"],\n    signature: [\"0x...\", \"0x...\"],\n    nonce: \"0x0\",\n    resource_bounds: {\n        l1_gas: { max_amount: \"0x100\", max_price_per_unit: \"0x100\" },\n        l1_data_gas: { max_amount: \"0x100\", max_price_per_unit: \"0x100\" },\n        l2_gas: { max_amount: \"0x100\", max_price_per_unit: \"0x100\" },\n    },\n    tip: \"0x0\",\n    paymaster_data: [],\n    account_deployment_data: [],\n    nonce_data_availability_mode: \"L1\" as const,\n    fee_data_availability_mode: \"L1\" as const,\n};\n\n// Prove the transaction\nconst proofResult = await devnet.provider.proofs.proveTransaction(\"latest\", invokeTx);\n\nconsole.log(proofResult.proof); // Base64-encoded mock proof\nconsole.log(proofResult.proof_facts); // Array of 9 hex strings\nconsole.log(proofResult.l2_to_l1_messages); // L2 to L1 messages from simulation\n```\n\nSee [this example](https://github.com/starknet-io/starknet-devnet-js/blob/master/test/proofs.test.ts) for a complete test with transaction building and signing.\n\n## Configuration modification and retrieval\n\nDevnet's configuration can be modified, other than [on startup (as already described)](#specify-devnet-arguments), via `setGasPrice`. It can be retrieved via `getConfig`.\n\n```typescript\nconst devnet = await Devnet.spawnInstalled({ args: [\"--l2-gas-price-fri\", ...] });\nconst modification = await devnet.provider.setGasPrice({ l2GasPrice: ... });\nconsole.log(await devnet.provider.getConfig().l2_gas_price_fri);\n```\n\n## Examples\n\nSee the [`test` directory](https://github.com/starknet-io/starknet-devnet-js/tree/master/test) for more usage examples.\n\n## Contribute\n\nIf you spot a problem or room for improvement, check if an issue for it [already exists](https://github.com/starknet-io/starknet-devnet-js/issues). If not, [create a new one](https://github.com/starknet-io/starknet-devnet-js/issues/new). You are welcome to open a PR yourself to close the issue. Once you open a PR, you will see a template with a list of steps - please follow them.\n\n### Test\n\nBefore running the tests with `npm test`, follow the steps defined in the [CI/CD config file](.circleci/config.yml). If your new test relies on environment variables, load them with `getEnvVar`. Conversely, to find all environment variables that need to be set before running existing tests, search the repo for `getEnvVar`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarknet-io%2Fstarknet-devnet-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarknet-io%2Fstarknet-devnet-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarknet-io%2Fstarknet-devnet-js/lists"}