pub struct ProgramManager;

Implementations§

source§

impl ProgramManager

source

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}

source

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}

source

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

source

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

source

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}

source

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

source

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

source

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

source

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

source

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

source

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

source§

fn clone(&self) -> ProgramManager

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<ProgramManager> for JsValue

source§

fn from(value: ProgramManager) -> Self

Converts to this type from the input type.
source§

impl FromWasmAbi for ProgramManager

§

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary.
source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
source§

impl IntoWasmAbi for ProgramManager

§

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary.
source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
source§

impl LongRefFromWasmAbi for ProgramManager

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = Ref<'static, ProgramManager>

Same as RefFromWasmAbi::Anchor
source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
source§

impl OptionFromWasmAbi for ProgramManager

source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
source§

impl OptionIntoWasmAbi for ProgramManager

source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
source§

impl RefFromWasmAbi for ProgramManager

§

type Abi = u32

The wasm ABI type references to Self are recovered from.
§

type Anchor = Ref<'static, ProgramManager>

The type that holds the reference to 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§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
source§

impl RefMutFromWasmAbi for ProgramManager

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = RefMut<'static, ProgramManager>

Same as RefFromWasmAbi::Anchor
source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
source§

impl TryFromJsValue for ProgramManager

§

type Error = JsValue

The type returned in the event of a conversion error.
source§

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl VectorFromWasmAbi for ProgramManager

§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[ProgramManager]>

source§

impl VectorIntoWasmAbi for ProgramManager

source§

impl WasmDescribe for ProgramManager

source§

impl WasmDescribeVector for ProgramManager

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,

§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more