Struct aleo_wasm::programs::manager::ProgramManager
source · pub struct ProgramManager;
Implementations§
source§impl ProgramManager
impl ProgramManager
sourcepub async fn deploy(
private_key: &PrivateKey,
program: &str,
fee_credits: f64,
fee_record: Option<RecordPlaintext>,
url: Option<String>,
imports: Option<Object>,
fee_proving_key: Option<ProvingKey>,
fee_verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<Transaction, String>
pub async fn deploy( private_key: &PrivateKey, program: &str, fee_credits: f64, fee_record: Option<RecordPlaintext>, url: Option<String>, imports: Option<Object>, fee_proving_key: Option<ProvingKey>, fee_verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<Transaction, String>
Deploy an Aleo program
@param private_key The private key of the sender @param program The source code of the program being deployed @param imports A javascript object holding the source code of any imported programs in the form {“program_name1”: “program_source_code”, “program_name2”: “program_source_code”, ..}. Note that all imported programs must be deployed on chain before the main program in order for the deployment to succeed @param fee_credits The amount of credits to pay as a fee @param fee_record The record to spend the fee from @param url The url of the Aleo network node to send the transaction to @param imports (optional) Provide a list of imports to use for the program deployment in the form of a javascript object where the keys are a string of the program name and the values are a string representing the program source code { “hello.aleo”: “hello.aleo source code” } @param fee_proving_key (optional) Provide a proving key to use for the fee execution @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution @returns {Transaction | Error}
sourcepub async fn estimate_deployment_fee(
program: &str,
imports: Option<Object>
) -> Result<u64, String>
pub async fn estimate_deployment_fee( program: &str, imports: Option<Object> ) -> Result<u64, String>
Estimate the fee for a program deployment
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
@param program The source code of the program being deployed @param imports (optional) Provide a list of imports to use for the deployment fee estimation in the form of a javascript object where the keys are a string of the program name and the values are a string representing the program source code { “hello.aleo”: “hello.aleo source code” } @returns {u64 | Error}
sourcepub fn program_name_cost(name: &str) -> Result<u64, String>
pub fn program_name_cost(name: &str) -> Result<u64, String>
Estimate the component of the deployment cost which comes from the fee for the program name. Note that this cost does not represent the entire cost of deployment. It is additional to the cost of the size (in bytes) of the deployment.
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
@param name The name of the program to be deployed @returns {u64 | Error}
source§impl ProgramManager
impl ProgramManager
sourcepub async fn execute_function_offline(
private_key: &PrivateKey,
program: &str,
function: &str,
inputs: Array,
prove_execution: bool,
cache: bool,
imports: Option<Object>,
proving_key: Option<ProvingKey>,
verifying_key: Option<VerifyingKey>,
url: Option<String>,
offline_query: Option<OfflineQuery>
) -> Result<ExecutionResponse, String>
pub async fn execute_function_offline( private_key: &PrivateKey, program: &str, function: &str, inputs: Array, prove_execution: bool, cache: bool, imports: Option<Object>, proving_key: Option<ProvingKey>, verifying_key: Option<VerifyingKey>, url: Option<String>, offline_query: Option<OfflineQuery> ) -> Result<ExecutionResponse, String>
Execute an arbitrary function locally
@param {PrivateKey} private_key The private key of the sender
@param {string} program The source code of the program being executed
@param {string} function The name of the function to execute
@param {Array} inputs A javascript array of inputs to the function
@param {boolean} prove_execution If true, the execution will be proven and an execution object
containing the proof and the encrypted inputs and outputs needed to verify the proof offline
will be returned.
@param {boolean} cache Cache the proving and verifying keys in the Execution response.
If this is set to ‘true’ the keys synthesized will be stored in the Execution Response
and the ProvingKey
and VerifyingKey
can be retrieved from the response via the .getKeys()
method.
@param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
form of a javascript object where the keys are a string of the program name and the values
are a string representing the program source code { “hello.aleo”: “hello.aleo source code” }
@param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
@param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
sourcepub async fn execute(
private_key: &PrivateKey,
program: &str,
function: &str,
inputs: Array,
fee_credits: f64,
fee_record: Option<RecordPlaintext>,
url: Option<String>,
imports: Option<Object>,
proving_key: Option<ProvingKey>,
verifying_key: Option<VerifyingKey>,
fee_proving_key: Option<ProvingKey>,
fee_verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<Transaction, String>
pub async fn execute( private_key: &PrivateKey, program: &str, function: &str, inputs: Array, fee_credits: f64, fee_record: Option<RecordPlaintext>, url: Option<String>, imports: Option<Object>, proving_key: Option<ProvingKey>, verifying_key: Option<VerifyingKey>, fee_proving_key: Option<ProvingKey>, fee_verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<Transaction, String>
Execute Aleo function and create an Aleo execution transaction
@param private_key The private key of the sender
@param program The source code of the program being executed
@param function The name of the function to execute
@param inputs A javascript array of inputs to the function
@param fee_credits The amount of credits to pay as a fee
@param fee_record The record to spend the fee from
@param url The url of the Aleo network node to send the transaction to
If this is set to ‘true’ the keys synthesized (or passed in as optional parameters via the
proving_key
and verifying_key
arguments) will be stored in the ProgramManager’s memory
and used for subsequent transactions. If this is set to ‘false’ the proving and verifying
keys will be deallocated from memory after the transaction is executed.
@param imports (optional) Provide a list of imports to use for the function execution in the
form of a javascript object where the keys are a string of the program name and the values
are a string representing the program source code { “hello.aleo”: “hello.aleo source code” }
@param proving_key (optional) Provide a verifying key to use for the function execution
@param verifying_key (optional) Provide a verifying key to use for the function execution
@param fee_proving_key (optional) Provide a proving key to use for the fee execution
@param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
@returns {Transaction | Error}
sourcepub async fn estimate_execution_fee(
private_key: &PrivateKey,
program: &str,
function: &str,
inputs: Array,
url: Option<String>,
imports: Option<Object>,
proving_key: Option<ProvingKey>,
verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<u64, String>
pub async fn estimate_execution_fee( private_key: &PrivateKey, program: &str, function: &str, inputs: Array, url: Option<String>, imports: Option<Object>, proving_key: Option<ProvingKey>, verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<u64, String>
Estimate Fee for Aleo function execution. Note if “cache” is set to true, the proving and verifying keys will be stored in the ProgramManager’s memory and used for subsequent program executions.
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
@param private_key The private key of the sender @param program The source code of the program to estimate the execution fee for @param function The name of the function to execute @param inputs A javascript array of inputs to the function @param url The url of the Aleo network node to send the transaction to @param imports (optional) Provide a list of imports to use for the fee estimation in the form of a javascript object where the keys are a string of the program name and the values are a string representing the program source code { “hello.aleo”: “hello.aleo source code” } @param proving_key (optional) Provide a verifying key to use for the fee estimation @param verifying_key (optional) Provide a verifying key to use for the fee estimation @returns {u64 | Error} Fee in microcredits
sourcepub fn estimate_finalize_fee(
program: &str,
function: &str
) -> Result<u64, String>
pub fn estimate_finalize_fee( program: &str, function: &str ) -> Result<u64, String>
Estimate the finalize fee component for executing a function. This fee is additional to the size of the execution of the program in bytes. If the function does not have a finalize step, then the finalize fee is 0.
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
@param program The program containing the function to estimate the finalize fee for @param function The function to estimate the finalize fee for @returns {u64 | Error} Fee in microcredits
source§impl ProgramManager
impl ProgramManager
sourcepub async fn join(
private_key: &PrivateKey,
record_1: RecordPlaintext,
record_2: RecordPlaintext,
fee_credits: f64,
fee_record: Option<RecordPlaintext>,
url: Option<String>,
join_proving_key: Option<ProvingKey>,
join_verifying_key: Option<VerifyingKey>,
fee_proving_key: Option<ProvingKey>,
fee_verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<Transaction, String>
pub async fn join( private_key: &PrivateKey, record_1: RecordPlaintext, record_2: RecordPlaintext, fee_credits: f64, fee_record: Option<RecordPlaintext>, url: Option<String>, join_proving_key: Option<ProvingKey>, join_verifying_key: Option<VerifyingKey>, fee_proving_key: Option<ProvingKey>, fee_verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<Transaction, String>
Join two records together to create a new record with an amount of credits equal to the sum of the credits of the two original records
@param private_key The private key of the sender @param record_1 The first record to combine @param record_2 The second record to combine @param fee_credits The amount of credits to pay as a fee @param fee_record The record to spend the fee from @param url The url of the Aleo network node to send the transaction to @param join_proving_key (optional) Provide a proving key to use for the join function @param join_verifying_key (optional) Provide a verifying key to use for the join function @param fee_proving_key (optional) Provide a proving key to use for the fee execution @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution @returns {Transaction | Error} Transaction object
source§impl ProgramManager
impl ProgramManager
sourcepub async fn split(
private_key: &PrivateKey,
split_amount: f64,
amount_record: RecordPlaintext,
url: Option<String>,
split_proving_key: Option<ProvingKey>,
split_verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<Transaction, String>
pub async fn split( private_key: &PrivateKey, split_amount: f64, amount_record: RecordPlaintext, url: Option<String>, split_proving_key: Option<ProvingKey>, split_verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<Transaction, String>
Split an Aleo credits record into two separate records. This function does not require a fee.
@param private_key The private key of the sender @param split_amount The amount of the credit split. This amount will be subtracted from the value of the record and two new records will be created with the split amount and the remainder @param amount_record The record to split @param url The url of the Aleo network node to send the transaction to @param split_proving_key (optional) Provide a proving key to use for the split function @param split_verifying_key (optional) Provide a verifying key to use for the split function @returns {Transaction | Error} Transaction object
source§impl ProgramManager
impl ProgramManager
sourcepub async fn transfer(
private_key: &PrivateKey,
amount_credits: f64,
recipient: &str,
transfer_type: &str,
amount_record: Option<RecordPlaintext>,
fee_credits: f64,
fee_record: Option<RecordPlaintext>,
url: Option<String>,
transfer_proving_key: Option<ProvingKey>,
transfer_verifying_key: Option<VerifyingKey>,
fee_proving_key: Option<ProvingKey>,
fee_verifying_key: Option<VerifyingKey>,
offline_query: Option<OfflineQuery>
) -> Result<Transaction, String>
pub async fn transfer( private_key: &PrivateKey, amount_credits: f64, recipient: &str, transfer_type: &str, amount_record: Option<RecordPlaintext>, fee_credits: f64, fee_record: Option<RecordPlaintext>, url: Option<String>, transfer_proving_key: Option<ProvingKey>, transfer_verifying_key: Option<VerifyingKey>, fee_proving_key: Option<ProvingKey>, fee_verifying_key: Option<VerifyingKey>, offline_query: Option<OfflineQuery> ) -> Result<Transaction, String>
Send credits from one Aleo account to another
@param private_key The private key of the sender @param amount_credits The amount of credits to send @param recipient The recipient of the transaction @param transfer_type The type of the transfer (options: “private”, “public”, “private_to_public”, “public_to_private”) @param amount_record The record to fund the amount from @param fee_credits The amount of credits to pay as a fee @param fee_record The record to spend the fee from @param url The url of the Aleo network node to send the transaction to @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer function @param fee_proving_key (optional) Provide a proving key to use for the fee execution @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution @returns {Transaction | Error}
source§impl ProgramManager
impl ProgramManager
sourcepub async fn synthesize_keypair(
private_key: &PrivateKey,
program: &str,
function_id: &str,
inputs: Array,
imports: Option<Object>
) -> Result<KeyPair, String>
pub async fn synthesize_keypair( private_key: &PrivateKey, program: &str, function_id: &str, inputs: Array, imports: Option<Object> ) -> Result<KeyPair, String>
Synthesize proving and verifying keys for a program
@param program {string} The program source code of the program to synthesize keys for @param function_id {string} The function to synthesize keys for @param inputs {Array} The inputs to the function @param imports {Object | undefined} The imports for the program
Trait Implementations§
source§impl Clone for ProgramManager
impl Clone for ProgramManager
source§fn clone(&self) -> ProgramManager
fn clone(&self) -> ProgramManager
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl From<ProgramManager> for JsValue
impl From<ProgramManager> for JsValue
source§fn from(value: ProgramManager) -> Self
fn from(value: ProgramManager) -> Self
source§impl FromWasmAbi for ProgramManager
impl FromWasmAbi for ProgramManager
source§impl IntoWasmAbi for ProgramManager
impl IntoWasmAbi for ProgramManager
source§impl LongRefFromWasmAbi for ProgramManager
impl LongRefFromWasmAbi for ProgramManager
source§impl OptionFromWasmAbi for ProgramManager
impl OptionFromWasmAbi for ProgramManager
source§impl OptionIntoWasmAbi for ProgramManager
impl OptionIntoWasmAbi for ProgramManager
source§impl RefFromWasmAbi for ProgramManager
impl RefFromWasmAbi for ProgramManager
§type Anchor = Ref<'static, ProgramManager>
type Anchor = Ref<'static, ProgramManager>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.source§impl RefMutFromWasmAbi for ProgramManager
impl RefMutFromWasmAbi for ProgramManager
source§impl TryFromJsValue for ProgramManager
impl TryFromJsValue for ProgramManager
source§impl VectorFromWasmAbi for ProgramManager
impl VectorFromWasmAbi for ProgramManager
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[ProgramManager]>
source§impl VectorIntoWasmAbi for ProgramManager
impl VectorIntoWasmAbi for ProgramManager
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[ProgramManager]>) -> Self::Abi
source§impl WasmDescribeVector for ProgramManager
impl WasmDescribeVector for ProgramManager
Auto Trait Implementations§
impl RefUnwindSafe for ProgramManager
impl Send for ProgramManager
impl Sync for ProgramManager
impl Unpin for ProgramManager
impl UnwindSafe for ProgramManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.