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
- instance
- .to_string() ⇒
string
- .verify(message, signature) ⇒
boolean
- .to_string() ⇒
- static
- instance
address.to_string() ⇒ string
Kind: instance method of Address
address.verify(message, signature) ⇒ boolean
Kind: instance method of Address
Param | Type |
---|---|
message | Uint8Array |
signature | Signature |
Address.from_private_key(private_key) ⇒ Address
Kind: static method of Address
Param | Type |
---|---|
private_key | PrivateKey |
Address.from_view_key(view_key) ⇒ Address
Kind: static method of Address
Param | Type |
---|---|
view_key | ViewKey |
Address.from_string(address) ⇒ Address
Kind: static method of Address
Param | Type |
---|---|
address | string |
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
Param | Type |
---|---|
proving_key | ProvingKey |
verifying_key | VerifyingKey |
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
- PrivateKey
- new PrivateKey()
- instance
- static
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
Param | Type |
---|---|
message | Uint8Array |
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
Param | Type |
---|---|
secret | string |
PrivateKey.from_seed_unchecked(seed) ⇒ PrivateKey
Get a private key from a series of unchecked bytes
Kind: static method of PrivateKey
Param | Type |
---|---|
seed | Uint8Array |
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
Param | Type |
---|---|
private_key | string |
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
Param | Type |
---|---|
secret | string |
PrivateKey.fromPrivateKeyCiphertext(ciphertext, secret) ⇒ PrivateKey
Get private key from a private key ciphertext using a secret.
Kind: static method of PrivateKey
Param | Type |
---|---|
ciphertext | PrivateKeyCiphertext |
secret | string |
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
Param | Type |
---|---|
secret | string |
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
Param | Type |
---|---|
private_key | PrivateKey |
secret | string |
PrivateKeyCiphertext.fromString(ciphertext) ⇒ PrivateKeyCiphertext
Creates a PrivateKeyCiphertext from a string
Kind: static method of PrivateKeyCiphertext
Param | Type |
---|---|
ciphertext | string |
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
- instance
- .toString() ⇒
string
- .getFunctions() ⇒
Array.<any>
- .getFunctionInputs(function_name) ⇒
Array.<any>
- .getMappings() ⇒
Array
|Array.<any>
- .getRecordMembers(record_name) ⇒
object
- .getStructMembers(struct_name) ⇒
Array.<any>
- .id() ⇒
string
- .isEqual(other) ⇒
boolean
- .getImports() ⇒
Array.<any>
- .toString() ⇒
- static
- instance
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
Param | Type |
---|---|
function_name | string |
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
Param | Type |
---|---|
record_name | string |
program.getStructMembers(struct_name) ⇒ Array.<any>
Get a javascript object representation of a program struct and its types
Kind: instance method of Program
Param | Type |
---|---|
struct_name | string |
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
Param | Type |
---|---|
other | Program |
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
Param | Type |
---|---|
program | string |
Program.getCreditsProgram() ⇒ Program
Get the credits.aleo program
Kind: static method of Program
ProvingKey
Kind: global class
- ProvingKey
- instance
- .toBytes() ⇒
Uint8Array
- .toBytes() ⇒
- static
- instance
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
Param | Type |
---|---|
bytes | Uint8Array |
RecordCiphertext
Encrypted Aleo record
Kind: global class
- RecordCiphertext
- instance
- .toString() ⇒
string
- .decrypt(view_key) ⇒
RecordPlaintext
- .isOwner(view_key) ⇒
boolean
- .toString() ⇒
- static
- instance
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
Param | Type |
---|---|
view_key | ViewKey |
recordCiphertext.isOwner(view_key) ⇒ boolean
Returns true
if the view key can decrypt the record ciphertext.
Kind: instance method of RecordCiphertext
Param | Type |
---|---|
view_key | ViewKey |
RecordCiphertext.fromString(record) ⇒ RecordCiphertext
Return a record ciphertext from a string.
Kind: static method of RecordCiphertext
Param | Type |
---|---|
record | string |
RecordPlaintext
Aleo record plaintext
Kind: global class
- RecordPlaintext
- instance
- .toString() ⇒
string
- .microcredits() ⇒
bigint
- .serialNumberString(private_key, program_id, record_name) ⇒
string
- .toString() ⇒
- static
- instance
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
Param | Type |
---|---|
private_key | PrivateKey |
program_id | string |
record_name | string |
RecordPlaintext.fromString(record) ⇒ RecordPlaintext
Return a record plaintext from a string.
Kind: static method of RecordPlaintext
Param | Type |
---|---|
record | string |
Signature
Kind: global class
- Signature
- instance
- .verify(address, message) ⇒
boolean
- .to_string() ⇒
string
- .verify(address, message) ⇒
- static
- instance
signature.verify(address, message) ⇒ boolean
Kind: instance method of Signature
Param | Type |
---|---|
address | Address |
message | Uint8Array |
signature.to_string() ⇒ string
Kind: instance method of Signature
Signature.sign(private_key, message) ⇒ Signature
Kind: static method of Signature
Param | Type |
---|---|
private_key | PrivateKey |
message | Uint8Array |
Signature.from_string(signature) ⇒ Signature
Kind: static method of Signature
Param | Type |
---|---|
signature | string |
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
- instance
- .toString() ⇒
string
- .transactionId() ⇒
string
- .transactionType() ⇒
string
- .toString() ⇒
- static
- instance
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
Param | Type |
---|---|
transaction | string |
VerifyingKey
Kind: global class
- VerifyingKey
- instance
- .toBytes() ⇒
Uint8Array
- .toBytes() ⇒
- static
- instance
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
Param | Type |
---|---|
bytes | Uint8Array |
ViewKey
Kind: global class
- ViewKey
- instance
- .to_string() ⇒
string
- .to_address() ⇒
Address
- .decrypt(ciphertext) ⇒
string
- .to_string() ⇒
- static
- instance
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
Param | Type |
---|---|
ciphertext | string |
ViewKey.from_private_key(private_key) ⇒ ViewKey
Kind: static method of ViewKey
Param | Type |
---|---|
private_key | PrivateKey |
ViewKey.from_string(view_key) ⇒ ViewKey
Kind: static method of ViewKey
Param | Type |
---|---|
view_key | string |