{"_id":"@aleohq/aleo-nodejs","_rev":"3-6fdd60a202b69e0f32da35954bb5eb1b","name":"@aleohq/aleo-nodejs","dist-tags":{"latest":"0.4.4"},"versions":{"0.4.4":{"name":"@aleohq/aleo-nodejs","version":"0.4.4","keywords":["aleo","cryptography","blockchain","decentralized","zero-knowledge"],"license":"GPL-3.0","_id":"@aleohq/aleo-nodejs@0.4.4","maintainers":[{"name":"aleo-mike","email":"mturner@aleo.org"},{"name":"aleo-collin","email":"collin@aleo.org"}],"homepage":"https://aleo.org","bugs":{"url":"https://github.com/AleoHQ/sdk/issues"},"dist":{"shasum":"a4bf5237782fbdae50cb34634a8fa222d7ecf64c","tarball":"https://registry.npmjs.org/@aleohq/aleo-nodejs/-/aleo-nodejs-0.4.4.tgz","fileCount":6,"integrity":"sha512-vAg9CW3ivouO6ZtgiRlpm77MaBYUu2ke/SvbFcf5pvLxBM1lspIVLVL0wLpq9Gm9kxRb5/xo+tcDSxe8z99Saw==","signatures":[{"sig":"MEUCIC01Qe8RjhKlPPIqZ+oAoHJTtAOL7JPR1KSpJl9IK2YzAiEAh08YHGU08+LFScZeE6UvG9qfm1mhnZRd6OIwIic4mUg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1740701},"main":"aleo_wasm.js","types":"aleo_wasm.d.ts","gitHead":"6ccae895bbde9db62732dcea4ed0b7119a2f875d","_npmUser":{"name":"aleo-mike","email":"mturner@aleo.org"},"repository":{"url":"git+https://github.com/AleoHQ/sdk.git","type":"git"},"_npmVersion":"9.4.0","description":"NodeJS WebAssembly based toolkit for developing zero knowledge applications with Aleo","directories":{},"_nodeVersion":"19.6.0","collaborators":["The Aleo Team <hello@aleo.org>"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/aleo-nodejs_0.4.4_1687386207002_0.8110975637735687","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-06-21T22:23:26.937Z","modified":"2025-10-22T16:54:31.224Z","0.4.4":"2023-06-21T22:23:27.268Z"},"bugs":{"url":"https://github.com/AleoHQ/sdk/issues"},"license":"GPL-3.0","homepage":"https://aleo.org","keywords":["aleo","cryptography","blockchain","decentralized","zero-knowledge"],"repository":{"url":"git+https://github.com/AleoHQ/sdk.git","type":"git"},"description":"NodeJS WebAssembly based toolkit for developing zero knowledge applications with Aleo","maintainers":[{"email":"mturner@aleo.org","name":"aleo-mike"},{"email":"collin@provable.com","name":"aleo-collin"}],"readme":"[![Crates.io](https://img.shields.io/crates/v/aleo-wasm.svg?color=neon)](https://crates.io/crates/aleo-wasm)\n[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](https://aleo.org)\n[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)\n\n[![github]](https://github.com/AleoHQ/sdk)&ensp;[![crates-io]](https://crates.io/crates/aleo-wasm)&ensp;[![docs-rs]](https://docs.rs/aleo-wasm/latest/aleo-wasm/)\n\n[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github\n[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust\n[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs\n\n# Aleo Wasm\n\nAleo JavaScript and WebAssembly bindings for building zero-knowledge web applications.\n\n`Rust` compiles easily to `WebAssembly` but creating the glue code necessary to use compiled WebAssembly binaries \nfrom other languages such as JavaScript is a challenging task. `wasm-bindgen` is a tool that simplifies this process by \nauto-generating JavaScript bindings to Rust code that has been compiled into WebAssembly. \n\nThis crate uses `wasm-bindgen` to create JavaScript bindings to Aleo source code so that it can be used to create zero \nknowledge proofs directly within `web browsers` and `NodeJS`.\n\nFunctionality exposed by this crate includes:\n* Aleo account management objects\n* Aleo primitives such as `Records`, `Programs`, and `Transactions` and their associated helper methods\n* A `ProgramManager` object that contains methods for authoring, deploying, and interacting with Aleo programs\n\nMore information on these concepts can be found at the [Aleo Developer Hub](https://developer.aleo.org/concepts).\n\n## Usage\nThe [wasm-pack](https://crates.io/crates/wasm-pack) tool is used to compile the Rust code in this crate into JavaScript\nmodules which can be imported into other JavaScript projects.\n\n#### Install Wasm-Pack\n```bash\ncurl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh\n```\n\n### Build Instructions\nThe general syntax for compiling rust into WebAssembly based JavaScript modules with \n[wasm-pack](https://crates.io/crates/wasm-pack) is as follows:\n```bash\nwasm-pack build --target <target> --out-dir <out-dir> -- --features <crate-features>\n```\n\nInvoking this command will build a JavaScript module in the current directory with the default name `pkg` (which can \nbe changed as necessary using the `--out-dir` flag). This folder can then be imported directly as a JavaScript module\nby other JavaScript modules.\n\nThere are 3 possible JavaScript modules that [wasm-pack](https://crates.io/crates/wasm-pack) can be used to generate \nwhen run within this crate:\n1. **NodeJS module:** Used to build NodeJS applications.\n2. **Single-Threaded browser module:** Used to build browser-based web applications.\n3. **Multi-Threaded browser module:** Used to build browser-based web applications which use web-worker based \nmulti-threading to achieve significant performance increases.\n\nThese 3 modules and how to build them are explained in more detail below.\n\n### 1. NodeJS Module\n\nThis module has the features of the NodeJS environment built-in. It is single-threaded and unfortunately cannot yet be \nused to generate Aleo program executions or deployments due to current Aleo protocol limitations. It can however still\nbe used to perform Aleo account, record, and program management tasks.\n\n#### Build Instructions\n```bash\nwasm-pack build --release --target nodejs -- --features \"serial\" --no-default-features\n```\n\n### 2. Single-Threaded browser module\n\nThis module is very similar to the NodeJS module, however it is built to make use browser-based JavaScript environments \nand can be used for program execution and deployment. \n\nIf used for program execution or deployment, it suggested to do so on a web-worker as these operations are long-running\nand will cause a browser window to hang if run in the main thread.\n\n#### Build Instructions\n```bash\nwasm-pack build --release --target web\n```\n\nIf you are intending to use this for program execution or deployment, it is recommended to build\nwith maximum or close to maximum memory allocation (which is 4 gigabytes for wasm).\n\n```bash\nRUSTFLAGS='-C link-arg=--max-memory=4294967296' wasm-pack build --release --target web\n````\n\n### 3. Multi-Threaded browser module\n\nThis module is also built for browser-based JavaScript environments, however it is built to make use of Rust-native\nthreading via web-workers (using the approach outlined in the `rayon-wasm-bindgen` crate). It is the most complex to use,\nbut it will run significantly faster when performing Aleo program executions and deployments and should be the choice for\nperformance-critical applications.\n\nTo build with threading enabled, it is necessary to use `nightly Rust` and set certain `RUSTFLAGS` to enable the\nnecessary threading features. The `wasm-pack` build command is shown below.\n```bash\n# Set rustflags to enable atomics, \n# bulk-memory, and mutable-globals. \n# Also, set the maximum memory to \n# 4294967296 bytes (4GB).\nexport RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--max-memory=4294967296'\n\n# Use rustup to run the following commands \n# with the nightly version of Rust.\nrustup run nightly \\\n\n# Use wasm-pack to build the project. \n# Specify the 'parallel' feature for \n# multi-threading and the 'browser' \n# feature to enable program execution\n# and include necessary unstable options\n# using -Z\nwasm-pack build --release --target web --out-dir pkg-parallel \\\n-- --features \"parallel, browser\" --no-default-features -Z build-std=panic_abort,std\n```\n\n## Testing\n\nRun tests in NodeJS\n```bash\nwasm-pack test --node\n```\n\nRun tests in a browser\n```bash\nwasm-pack test --[firefox/chrome/safari]\n```\n\n## Building Web Apps\n\nFurther documentation and tutorials as to how to use the modules built from this crate to build web apps  will be built \nin the future. However - in the meantime, the [aleo.tools](https://aleo.tools) website is a good\nexample of how to use these modules to build a web app. Its source code can be found in the \n[Aleo SDK](https://github.com/AleoHQ/sdk) repo in the `website` folder.\n","readmeFilename":"README.md"}