Struct aleo_rust::ProgramManager
source · 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>>,
fee: u64,
fee_record: Record<N, Plaintext<N>>,
password: Option<&str>
) -> Result<String>
pub fn deploy_program( &mut self, program_id: impl TryInto<ProgramID<N>>, fee: u64, fee_record: Record<N, Plaintext<N>>, password: Option<&str> ) -> Result<String>
Deploy a program to the network
sourcepub fn create_deploy_transaction(
program: &Program<N>,
imports: &[Program<N>],
private_key: &PrivateKey<N>,
fee: u64,
fee_record: Record<N, Plaintext<N>>,
query: String
) -> Result<Transaction<N>>
pub fn create_deploy_transaction( program: &Program<N>, imports: &[Program<N>], private_key: &PrivateKey<N>, fee: u64, fee_record: Record<N, Plaintext<N>>, query: String ) -> Result<Transaction<N>>
Create a deploy transaction for a program without instantiating the program manager
sourcepub fn estimate_deployment_fee<A: Aleo<Network = N>>(
&mut self,
program: &Program<N>
) -> Result<(u64, (u64, u64))>
pub fn estimate_deployment_fee<A: Aleo<Network = N>>( &mut 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))
sourcepub fn estimate_namespace_fee(
&mut self,
program_id: impl TryInto<ProgramID<N>>
) -> Result<u64>
pub fn estimate_namespace_fee( &mut self, program_id: impl TryInto<ProgramID<N>> ) -> Result<u64>
Estimate the component of the deployment cost which comes from the fee surrounding 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.
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>>,
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>>, 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>>>,
fee: u64,
fee_record: Record<N, Plaintext<N>>,
password: Option<&str>
) -> 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>>>, fee: u64, fee_record: Record<N, Plaintext<N>>, password: Option<&str> ) -> 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>,
fee: u64,
inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>,
fee_record: Record<N, Plaintext<N>>,
program: &Program<N>,
function: impl TryInto<Identifier<N>>,
query: String
) -> Result<Transaction<N>>
pub fn create_execute_transaction( private_key: &PrivateKey<N>, fee: u64, inputs: impl ExactSizeIterator<Item = impl TryInto<Value<N>>>, fee_record: Record<N, Plaintext<N>>, program: &Program<N>, function: impl TryInto<Identifier<N>>, query: String ) -> Result<Transaction<N>>
Create an execute transaction
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))
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.
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: 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: 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>
) -> 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> ) -> 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 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