Skip to main content

Development Client

Overview

Kind: global class

new DevelopmentClient(baseURL)

Creates a new DevelopmentClient to interact with an Aleo Development Server.

ParamTypeDescription
baseURLstring

The URL of the Aleo Development Server

developmentClient.deployProgram(program, fee, privateKey, password, feeRecord) ⇒ string | Error

Deploys a program on the Aleo Network via an Aleo development server. It requires an Aleo Development Server to be running remotely or locally. If one is not running, this function will throw an error.

Information on how to run an Aleo Development Server can be found here: https://github.com/AleoHQ/sdk/rust/develop/README.md

Kind: instance method of DevelopmentClient
Returns: string | Error -

The transaction_id of the deployment transaction if successful

ParamTypeDescription
programstring

Text representation of the program to be deployed

feenumber

Fee to be paid for the program deployment (REQUIRED)

privateKeystring | undefined

Optional private key of the user who is deploying the program

passwordstring | undefined

If the development server is started with an encrypted private key, the password is required

feeRecordstring | undefined

Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the fee.

Example

const Program = 'program yourprogram.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n';
const client = new DevelopmentClient("http://0.0.0.0:4040");
const transaction_id = await client.deployProgram(Program, 6000000, privateKeyString);

developmentClient.executeProgram(programId, programFunction, fee, inputs, privateKey, password, feeRecord) ⇒ string | Error

Executes a program on the Aleo Network via an Aleo development server. It requires an Aleo Development Server to be running remotely or locally. If one is not running, this function will throw an error.

Information on how to run an Aleo Development Server can be found here: https://github.com/AleoHQ/sdk/rust/develop/README.md

Kind: instance method of DevelopmentClient
Returns: string | Error -

The transaction_id of the execution transaction if successful

ParamTypeDescription
programIdstring

The program_id of the program to be executed (e.g. hello.aleo)

programFunctionstring

The function to execute within the program (e.g. hello)

feenumber

Optional Fee to be paid for the execution transaction, specify 0 for no fee

inputsArray.<string>

Array of inputs to be passed to the program

privateKeystring | undefined

Optional private key of the user who is executing the program

passwordstring | undefined

If the development server is started with an encrypted private key, the password is required

feeRecordstring | undefined

Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the fee.

Example

const privateKey = "your private key";
const client = new DevelopmentClient("http://0.0.0.0:4040");
const transaction_id = await client.executeProgram("hello.aleo", "hello", 0, ["5u32", "5u32"], privateKeyString);

developmentClient.transfer(amount, fee, recipient, transfer_type, privateKey, password, feeRecord, amountRecord) ⇒ string | Error

Sends an amount in credits to a specified recipient on the Aleo Network via an Aleo development server. It requires an Aleo Development Server to be running remotely or locally. If one is not running, this function will throw an error.

Information on how to run an Aleo Development Server can be found here: https://github.com/AleoHQ/sdk/rust/develop/README.md

Kind: instance method of DevelopmentClient
Returns: string | Error -

The transaction_id of the execution transaction if successful

ParamTypeDescription
amountstring

The amount of credits to be sent (e.g. 1.5)

feenumber

Optional Fee to be paid for the transfer, specify 0 for no fee

recipientstring

The recipient of the transfer

transfer_typestring

The type of the transfer (possible values are "private", "public", "private_to_public", "public_to_private")

privateKeystring | undefined

Optional private key of the user who is sending the transfer

passwordstring | undefined

If the development server is started with an encrypted private key, the password is required

feeRecordstring | undefined

Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the fee.

amountRecordstring | undefined

Optional record in text format to be used to fund the transfer. If not provided, the server will search the network for a suitable record to fund the amount.

Example

const privateKey = "your private key";
const recipient = "recipient's address";
const client = new DevelopmentClient("http://0.0.0.0:4040");
const transaction_id = await client.transfer(1.5, 0, recipient, privateKey);