pub struct ProgramManager<N: Network> { /* private fields */ }
Expand description
Program management object for loading programs for building, execution, and deployment
This object is meant to be a software abstraction that can be consumed by software like CLI tools, IDE plugins, Server-side stack components and other software that needs to interact with the Aleo network.
Implementations§
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn deploy_program(
&mut self,
program_id: impl TryInto<ProgramID<N>>,
priority_fee: u64,
fee_record: Option<Record<N, Plaintext<N>>>,
password: Option<&str>,
) -> Result<String>
pub fn deploy_program( &mut self, program_id: impl TryInto<ProgramID<N>>, priority_fee: u64, fee_record: Option<Record<N, Plaintext<N>>>, password: Option<&str>, ) -> Result<String>
Deploy a program to the network
Sourcepub fn create_deploy_transaction(
program: &Program<N>,
private_key: &PrivateKey<N>,
priority_fee: u64,
fee_record: Option<Record<N, Plaintext<N>>>,
node_url: String,
api_client: &AleoAPIClient<N>,
vm: &Option<VM<N, ConsensusMemory<N>>>,
) -> Result<Transaction<N>>
pub fn create_deploy_transaction( program: &Program<N>, private_key: &PrivateKey<N>, priority_fee: u64, fee_record: Option<Record<N, Plaintext<N>>>, node_url: String, api_client: &AleoAPIClient<N>, vm: &Option<VM<N, ConsensusMemory<N>>>, ) -> Result<Transaction<N>>
Create a deploy transaction for a program without instantiating the program manager
Sourcepub fn estimate_deployment_fee<A: Aleo<Network = N>>(
&self,
program: &Program<N>,
) -> Result<(u64, (u64, u64))>
pub fn estimate_deployment_fee<A: Aleo<Network = N>>( &self, program: &Program<N>, ) -> Result<(u64, (u64, u64))>
Estimate deployment fee for a program in microcredits. The result will be in the form (total_cost, (storage_cost, namespace_cost))
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
Sourcepub fn estimate_namespace_fee(
program_id: impl TryInto<ProgramID<N>>,
) -> Result<u64>
pub fn estimate_namespace_fee( program_id: impl TryInto<ProgramID<N>>, ) -> Result<u64>
Estimate the component of the deployment cost derived from 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
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn execute_program_offline<A: Aleo<Network = N>>(
&self,
private_key: &PrivateKey<N>,
program: &Program<N>,
function: impl TryInto<Identifier<N>>,
imports: &[Program<N>],
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
include_outputs: bool,
url: &str,
) -> Result<OfflineExecution<N>>
pub fn execute_program_offline<A: Aleo<Network = N>>( &self, private_key: &PrivateKey<N>, program: &Program<N>, function: impl TryInto<Identifier<N>>, imports: &[Program<N>], inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, include_outputs: bool, url: &str, ) -> Result<OfflineExecution<N>>
Create an offline execution of a program to share with a third party.
DISCLAIMER: Offline executions will not interact with the Aleo network and cannot use all of the features of the Leo programming language or Aleo instructions. Any code written inside finalize blocks will not be executed, mappings cannot be initialized, updated or read, and a chain of records cannot be created.
Offline executions however can be used to verify that program outputs follow from program inputs and that the program was executed correctly. If this is the aim and no chain interaction is desired, this function can be used.
Sourcepub fn execute_program(
&mut self,
program_id: impl TryInto<ProgramID<N>>,
function: impl TryInto<Identifier<N>>,
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
priority_fee: u64,
fee_record: Option<Record<N, Plaintext<N>>>,
password: Option<&str>,
private_key: Option<&PrivateKey<N>>,
) -> Result<String>
pub fn execute_program( &mut self, program_id: impl TryInto<ProgramID<N>>, function: impl TryInto<Identifier<N>>, inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, priority_fee: u64, fee_record: Option<Record<N, Plaintext<N>>>, password: Option<&str>, private_key: Option<&PrivateKey<N>>, ) -> Result<String>
Execute a program function on the Aleo Network.
To run this function successfully, the program must already be deployed on the Aleo Network
Sourcepub fn create_execute_transaction(
private_key: &PrivateKey<N>,
priority_fee: u64,
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
fee_record: Option<Record<N, Plaintext<N>>>,
program: &Program<N>,
function: impl TryInto<Identifier<N>>,
node_url: String,
api_client: &AleoAPIClient<N>,
vm: &Option<VM<N, ConsensusMemory<N>>>,
) -> Result<Transaction<N>>
pub fn create_execute_transaction( private_key: &PrivateKey<N>, priority_fee: u64, inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, fee_record: Option<Record<N, Plaintext<N>>>, program: &Program<N>, function: impl TryInto<Identifier<N>>, node_url: String, api_client: &AleoAPIClient<N>, vm: &Option<VM<N, ConsensusMemory<N>>>, ) -> Result<Transaction<N>>
Create an execute transaction without initializing a program manager instance
Sourcepub fn estimate_execution_fee<A: Aleo<Network = N>>(
&self,
program: &Program<N>,
function: impl TryInto<Identifier<N>>,
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
) -> Result<(u64, (u64, u64))>
pub fn estimate_execution_fee<A: Aleo<Network = N>>( &self, program: &Program<N>, function: impl TryInto<Identifier<N>>, inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, ) -> Result<(u64, (u64, u64))>
Estimate the cost of executing a program with the given inputs in microcredits. The response will be in the form of (total_cost, (storage_cost, finalize_cost))
Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
Sourcepub fn estimate_finalize_fee(
&self,
program: &Program<N>,
function: impl TryInto<Identifier<N>>,
) -> Result<u64>
pub fn estimate_finalize_fee( &self, program: &Program<N>, function: impl TryInto<Identifier<N>>, ) -> Result<u64>
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
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn broadcast_transaction(
&self,
transaction: Transaction<N>,
) -> Result<String>
pub fn broadcast_transaction( &self, transaction: Transaction<N>, ) -> Result<String>
Broadcast a transaction to the network
Sourcepub fn api_client(&self) -> Result<&AleoAPIClient<N>>
pub fn api_client(&self) -> Result<&AleoAPIClient<N>>
Get a reference to the configured API client
Sourcepub fn on_chain_program_state(
&self,
program: &Program<N>,
) -> Result<OnChainProgramState>
pub fn on_chain_program_state( &self, program: &Program<N>, ) -> Result<OnChainProgramState>
Check the on-chain version of a program to determine if it is deployed, and if so, if it is the same as the local version
Sourcepub fn get_mapping_value(
&self,
program_id: impl TryInto<ProgramID<N>>,
mapping_name: impl TryInto<Identifier<N>>,
key: impl TryInto<Plaintext<N>>,
) -> Result<Value<N>>
pub fn get_mapping_value( &self, program_id: impl TryInto<ProgramID<N>>, mapping_name: impl TryInto<Identifier<N>>, key: impl TryInto<Plaintext<N>>, ) -> Result<Value<N>>
Check the value of an on-chain mapping
Sourcepub fn get_mappings(
&self,
program_id: impl TryInto<ProgramID<N>>,
) -> Result<Vec<Identifier<N>>>
pub fn get_mappings( &self, program_id: impl TryInto<ProgramID<N>>, ) -> Result<Vec<Identifier<N>>>
Check the mappings available in a program
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn find_program(&self, program_id: &ProgramID<N>) -> Result<Program<N>>
pub fn find_program(&self, program_id: &ProgramID<N>) -> Result<Program<N>>
Find a program by first looking on disk, and if not found, on the aleo network
Sourcepub fn find_program_on_disk(
&self,
program_id: &ProgramID<N>,
) -> Result<Program<N>>
pub fn find_program_on_disk( &self, program_id: &ProgramID<N>, ) -> Result<Program<N>>
Load a program from a local program directory
Sourcepub fn find_program_on_chain(
&self,
program_id: &ProgramID<N>,
) -> Result<Program<N>>
pub fn find_program_on_chain( &self, program_id: &ProgramID<N>, ) -> Result<Program<N>>
Load a program from the network
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn transfer(
&self,
amount: u64,
fee: u64,
recipient_address: Address<N>,
transfer_type: TransferType,
password: Option<&str>,
amount_record: Option<Record<N, Plaintext<N>>>,
fee_record: Option<Record<N, Plaintext<N>>>,
) -> Result<String>
pub fn transfer( &self, amount: u64, fee: u64, recipient_address: Address<N>, transfer_type: TransferType, password: Option<&str>, amount_record: Option<Record<N, Plaintext<N>>>, fee_record: Option<Record<N, Plaintext<N>>>, ) -> Result<String>
Executes a transfer to the specified recipient_address with the specified amount and fee. Specify 0 for no fee.
Source§impl<N: Network> ProgramManager<N>
impl<N: Network> ProgramManager<N>
Sourcepub fn new(
private_key: Option<PrivateKey<N>>,
private_key_ciphertext: Option<Ciphertext<N>>,
api_client: Option<AleoAPIClient<N>>,
local_program_directory: Option<PathBuf>,
use_cache: bool,
) -> Result<Self>
pub fn new( private_key: Option<PrivateKey<N>>, private_key_ciphertext: Option<Ciphertext<N>>, api_client: Option<AleoAPIClient<N>>, local_program_directory: Option<PathBuf>, use_cache: bool, ) -> Result<Self>
Create a new program manager by specifying custom options for the private key (or private key ciphertext) and resolver. Use this method if you want to create a custom resolver (i.e. one that searches a local or remote database) for program and record resolution.
Sourcepub fn add_program(&mut self, program: &Program<N>) -> Result<()>
pub fn add_program(&mut self, program: &Program<N>) -> Result<()>
Manually add a program to the program manager from memory if it does not already exist
Sourcepub fn initialize_vm(
api_client: &AleoAPIClient<N>,
program: &Program<N>,
initialize_execution: bool,
) -> Result<VM<N, ConsensusMemory<N>>>
pub fn initialize_vm( api_client: &AleoAPIClient<N>, program: &Program<N>, initialize_execution: bool, ) -> Result<VM<N, ConsensusMemory<N>>>
Initialize a SnarkVM instance with a program and its imports
Sourcepub fn update_program(&mut self, program: &Program<N>) -> Option<Program<N>>
pub fn update_program(&mut self, program: &Program<N>) -> Option<Program<N>>
Manually add a program to the program manager if it does not already exist or update it if it does
Sourcepub fn get_program(
&self,
program_id: impl TryInto<ProgramID<N>>,
) -> Result<Program<N>>
pub fn get_program( &self, program_id: impl TryInto<ProgramID<N>>, ) -> Result<Program<N>>
Retrieve a program from the program manager if it exists
Sourcepub fn contains_program(
&self,
program_id: impl TryInto<ProgramID<N>>,
) -> Result<bool>
pub fn contains_program( &self, program_id: impl TryInto<ProgramID<N>>, ) -> Result<bool>
Determine if a program exists in the program manager
pub fn vm(&self) -> &Option<VM<N, ConsensusMemory<N>>>
Trait Implementations§
Source§impl<N: Clone + Network> Clone for ProgramManager<N>
impl<N: Clone + Network> Clone for ProgramManager<N>
Source§fn clone(&self) -> ProgramManager<N>
fn clone(&self) -> ProgramManager<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<N> Freeze for ProgramManager<N>
impl<N> !RefUnwindSafe for ProgramManager<N>
impl<N> Send for ProgramManager<N>
impl<N> Sync for ProgramManager<N>
impl<N> Unpin for ProgramManager<N>where
<N as Environment>::Field: Unpin,
<N as Environment>::Scalar: Unpin,
N: Unpin,
<N as Environment>::Projective: Unpin,
impl<N> !UnwindSafe for ProgramManager<N>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more