Skip to content

Aleo SDK Node

Execute Aleo programs in Node.js. Simple and easy-to-use.

Quick Start

Install the package by running the following command in your terminal:

Terminal window
npm install aleo-sdk-node

To build an Aleo execution transaction, call loadProgramKeys to load the program keys, then build the execution transaction. Make sure you include main.aleo and program.json of your contract in the same directory.

await loadProgramKeys();
const execution = await buildExecutionTransaction({
privateKey: process.env.PRIVATE_KEY,
endpoint: "https://api.explorer.provable.com/v1",
functionName: "hello",
inputs: [
"5u32",
"5u32"
],
programId: "hello_hello.aleo",
priorityFee: BigInt(0),
baseFee: BigInt(11323),
});

Congratulations! You’ve ran your first Aleo program execution in Node.js. The return object can then be used to broadcast to the network.

fetch('https://api.explorer.provable.com/v1/testnet/transaction/broadcast', {
body: execution.transaction,
method: 'POST',
headers: {
"Content-Type": "application/json"
}
});