Skip to main content

NodeJS + Browser (Single-Thread)

Classes

Address
ExecutionResponse

Webassembly Representation of an Aleo function execution response

This object is returned by the execution of an Aleo function off-chain. It provides methods for retrieving the outputs of the function execution.

KeyPair
PrivateKey
PrivateKeyCiphertext

Private Key in ciphertext form

Program

Webassembly Representation of an Aleo program

This object is required to create an Execution or Deployment transaction. It includes several convenience methods for enumerating available functions and each functions' inputs in a javascript object for usage in creation of web forms for input capture.

ProvingKey
RecordCiphertext

Encrypted Aleo record

RecordPlaintext

Aleo record plaintext

Signature
Transaction

Webassembly Representation of an Aleo transaction

This object is created when generating an on-chain function deployment or execution and is the object that should be submitted to the Aleo Network in order to deploy or execute a function.

VerifyingKey
ViewKey

Address

Kind: global class

address.to_string() ⇒ string

Kind: instance method of Address

address.verify(message, signature) ⇒ boolean

Kind: instance method of Address

ParamType
messageUint8Array
signatureSignature

Address.from_private_key(private_key) ⇒ Address

Kind: static method of Address

ParamType
private_keyPrivateKey

Address.from_view_key(view_key) ⇒ Address

Kind: static method of Address

ParamType
view_keyViewKey

Address.from_string(address) ⇒ Address

Kind: static method of Address

ParamType
addressstring

ExecutionResponse

Webassembly Representation of an Aleo function execution response

This object is returned by the execution of an Aleo function off-chain. It provides methods for retrieving the outputs of the function execution.

Kind: global class

executionResponse.getOutputs() ⇒ Array.<any>

Get the outputs of the executed function

Kind: instance method of ExecutionResponse

KeyPair

Kind: global class

new KeyPair(proving_key, verifying_key)

Create new key pair from proving and verifying keys

ParamType
proving_keyProvingKey
verifying_keyVerifyingKey

keyPair.provingKey() ⇒ ProvingKey

Get the proving key

Kind: instance method of KeyPair

keyPair.verifyingKey() ⇒ VerifyingKey

Get the verifying key

Kind: instance method of KeyPair

PrivateKey

Kind: global class

new PrivateKey()

Generate a new private key

privateKey.to_string() ⇒ string

Get a string representation of the private key

This function should be used very carefully as it exposes the private key plaintext

Kind: instance method of PrivateKey

privateKey.to_view_key() ⇒ ViewKey

Get the view key corresponding to the private key

Kind: instance method of PrivateKey

privateKey.to_address() ⇒ Address

Get the address corresponding to the private key

Kind: instance method of PrivateKey

privateKey.sign(message) ⇒ Signature

Sign a message with the private key

Kind: instance method of PrivateKey

ParamType
messageUint8Array

privateKey.toCiphertext(secret) ⇒ PrivateKeyCiphertext

Encrypt the private key with a secret.

The secret is sensitive and will be needed to decrypt the private key later, so it should be stored securely

Kind: instance method of PrivateKey

ParamType
secretstring

PrivateKey.from_seed_unchecked(seed) ⇒ PrivateKey

Get a private key from a series of unchecked bytes

Kind: static method of PrivateKey

ParamType
seedUint8Array

PrivateKey.from_string(private_key) ⇒ PrivateKey

Create a private key from a string representation

This function will fail if the text is not a valid private key

Kind: static method of PrivateKey

ParamType
private_keystring

PrivateKey.newEncrypted(secret) ⇒ PrivateKeyCiphertext

Get a private key ciphertext using a secret.

The secret is sensitive and will be needed to decrypt the private key later, so it should be stored securely

Kind: static method of PrivateKey

ParamType
secretstring

PrivateKey.fromPrivateKeyCiphertext(ciphertext, secret) ⇒ PrivateKey

Get private key from a private key ciphertext using a secret.

Kind: static method of PrivateKey

ParamType
ciphertextPrivateKeyCiphertext
secretstring

PrivateKeyCiphertext

Private Key in ciphertext form

Kind: global class

privateKeyCiphertext.decryptToPrivateKey(secret) ⇒ PrivateKey

Decrypts a private ciphertext using a secret string.

This must be the same secret used to encrypt the private key

Kind: instance method of PrivateKeyCiphertext

ParamType
secretstring

privateKeyCiphertext.toString() ⇒ string

Returns the ciphertext string

Kind: instance method of PrivateKeyCiphertext

PrivateKeyCiphertext.encryptPrivateKey(private_key, secret) ⇒ PrivateKeyCiphertext

Encrypt a private key using a secret string.

The secret is sensitive and will be needed to decrypt the private key later, so it should be stored securely.

Kind: static method of PrivateKeyCiphertext

ParamType
private_keyPrivateKey
secretstring

PrivateKeyCiphertext.fromString(ciphertext) ⇒ PrivateKeyCiphertext

Creates a PrivateKeyCiphertext from a string

Kind: static method of PrivateKeyCiphertext

ParamType
ciphertextstring

Program

Webassembly Representation of an Aleo program

This object is required to create an Execution or Deployment transaction. It includes several convenience methods for enumerating available functions and each functions' inputs in a javascript object for usage in creation of web forms for input capture.

Kind: global class

program.toString() ⇒ string

Get a string representation of the program

Kind: instance method of Program

program.getFunctions() ⇒ Array.<any>

Get javascript array of functions names in the program

Kind: instance method of Program

program.getFunctionInputs(function_name) ⇒ Array.<any>

Get a javascript object representation of the function inputs and types. This can be used to generate a webform to capture user inputs for an execution of a function.

Kind: instance method of Program

ParamType
function_namestring

program.getMappings() ⇒ Array | Array.<any>

Get a list of a program's mappings and the names/types of their keys and values.

Kind: instance method of Program Returns: Array - - An array of objects representing the mappings in the programArray.<any> Example

const expected_mappings = [
{
name: "account",
key_name: "owner",
key_type: "address",
value_name: "microcredits",
value_type: "u64"
}
]

const credits_program = aleo_wasm.Program.getCreditsProgram();
const credits_mappings = credits_program.getMappings();
console.log(credits_mappings === expected_mappings); // Output should be "true"

program.getRecordMembers(record_name) ⇒ object

Get a javascript object representation of a program record and its types

Kind: instance method of Program

ParamType
record_namestring

program.getStructMembers(struct_name) ⇒ Array.<any>

Get a javascript object representation of a program struct and its types

Kind: instance method of Program

ParamType
struct_namestring

program.id() ⇒ string

Get the id of the program

Kind: instance method of Program

program.isEqual(other) ⇒ boolean

Determine equality with another program

Kind: instance method of Program

ParamType
otherProgram

program.getImports() ⇒ Array.<any>

Get program_imports

Kind: instance method of Program

Program.fromString(program) ⇒ Program

Create a program from a program string

Kind: static method of Program

ParamType
programstring

Program.getCreditsProgram() ⇒ Program

Get the credits.aleo program

Kind: static method of Program

ProvingKey

Kind: global class

provingKey.toBytes() ⇒ Uint8Array

Create a byte array from a proving key

Kind: instance method of ProvingKey

ProvingKey.fromBytes(bytes) ⇒ ProvingKey

Construct a new proving key from a byte array

Kind: static method of ProvingKey

ParamType
bytesUint8Array

RecordCiphertext

Encrypted Aleo record

Kind: global class

recordCiphertext.toString() ⇒ string

Return the record ciphertext string.

Kind: instance method of RecordCiphertext

recordCiphertext.decrypt(view_key) ⇒ RecordPlaintext

Decrypt the record ciphertext into plaintext using the view key.

Kind: instance method of RecordCiphertext

ParamType
view_keyViewKey

recordCiphertext.isOwner(view_key) ⇒ boolean

Returns true if the view key can decrypt the record ciphertext.

Kind: instance method of RecordCiphertext

ParamType
view_keyViewKey

RecordCiphertext.fromString(record) ⇒ RecordCiphertext

Return a record ciphertext from a string.

Kind: static method of RecordCiphertext

ParamType
recordstring

RecordPlaintext

Aleo record plaintext

Kind: global class

recordPlaintext.toString() ⇒ string

Returns the record plaintext string

Kind: instance method of RecordPlaintext

recordPlaintext.microcredits() ⇒ bigint

Returns the amount of microcredits in the record

Kind: instance method of RecordPlaintext

recordPlaintext.serialNumberString(private_key, program_id, record_name) ⇒ string

Attempt to get the serial number of a record to determine whether or not it has been spent

Kind: instance method of RecordPlaintext

ParamType
private_keyPrivateKey
program_idstring
record_namestring

RecordPlaintext.fromString(record) ⇒ RecordPlaintext

Return a record plaintext from a string.

Kind: static method of RecordPlaintext

ParamType
recordstring

Signature

Kind: global class

signature.verify(address, message) ⇒ boolean

Kind: instance method of Signature

ParamType
addressAddress
messageUint8Array

signature.to_string() ⇒ string

Kind: instance method of Signature

Signature.sign(private_key, message) ⇒ Signature

Kind: static method of Signature

ParamType
private_keyPrivateKey
messageUint8Array

Signature.from_string(signature) ⇒ Signature

Kind: static method of Signature

ParamType
signaturestring

Transaction

Webassembly Representation of an Aleo transaction

This object is created when generating an on-chain function deployment or execution and is the object that should be submitted to the Aleo Network in order to deploy or execute a function.

Kind: global class

transaction.toString() ⇒ string

Get the transaction as a string. If you want to submit this transaction to the Aleo Network this function will create the string that should be submitted in the POST data.

Kind: instance method of Transaction

transaction.transactionId() ⇒ string

Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.

This value can be used to query the status of the transaction on the Aleo Network to see if it was successful. If successful, the transaction will be included in a block and this value can be used to lookup the transaction data on-chain.

Kind: instance method of Transaction

transaction.transactionType() ⇒ string

Get the type of the transaction (will return "deploy" or "execute")

Kind: instance method of Transaction

Transaction.fromString(transaction) ⇒ Transaction

Create a transaction from a string

Kind: static method of Transaction

ParamType
transactionstring

VerifyingKey

Kind: global class

verifyingKey.toBytes() ⇒ Uint8Array

Create a byte array from a verifying key

Kind: instance method of VerifyingKey

VerifyingKey.fromBytes(bytes) ⇒ VerifyingKey

Construct a new verifying key from a byte array

Kind: static method of VerifyingKey

ParamType
bytesUint8Array

ViewKey

Kind: global class

viewKey.to_string() ⇒ string

Kind: instance method of ViewKey

viewKey.to_address() ⇒ Address

Kind: instance method of ViewKey

viewKey.decrypt(ciphertext) ⇒ string

Kind: instance method of ViewKey

ParamType
ciphertextstring

ViewKey.from_private_key(private_key) ⇒ ViewKey

Kind: static method of ViewKey

ParamType
private_keyPrivateKey

ViewKey.from_string(view_key) ⇒ ViewKey

Kind: static method of ViewKey

ParamType
view_keystring