Struct hedera::ContractCreateFlow

source ·
pub struct ContractCreateFlow { /* private fields */ }
Expand description

Create a new smart contract

The operation of this flow is as follows:

  1. Create a file for the contract’s bytecode (via a FileCreateTransaction and zero or more FileAppendTransactions)
  2. Execute a ContractCreateTransaction using the provided information and the newly created file.
  3. Delete the file created in step 1.

Implementations§

source§

impl ContractCreateFlow

source

pub fn new() -> Self

Create a new ContractCreateFlow.

source

pub fn get_bytecode(&self) -> &[u8]

Returns bytes of the smart contract.

source

pub fn bytecode(&mut self, bytecode: Vec<u8>) -> &mut Self

Sets the raw bytes of the smart contract.

source

pub fn bytecode_hex(&mut self, bytecode: &str) -> Result<&mut Self>

Sets the bytecode of the smart contract in hex.

§Errors
source

pub fn get_node_account_ids(&self) -> Option<&[AccountId]>

Returns the account IDs of the nodes the transactions may be submitted to.

source

pub fn node_account_ids( &mut self, node_account_ids: impl IntoIterator<Item = AccountId>, ) -> &mut Self

Sets the account IDs of the nodes the transactions may be submitted to.

Defaults to the full list of nodes configured on the client.

source

pub fn get_max_chunks(&self) -> Option<usize>

Returns maximum number of chunks the FileAppendTransaction can be split into.

If null, the default value for a FileAppendTransaction will be used.

source

pub fn max_chunks(&mut self, max_chunks: usize) -> &mut Self

Sets the maximum number of chunks the FileAppendTransaction can be split into.

source

pub fn get_constructor_parameters(&self) -> &[u8]

Returns the parameters to pass to the constructor.

source

pub fn constructor_parameters( &mut self, constructor_parameters: impl Into<Vec<u8>>, ) -> &mut Self

Sets the parameters to pass to the constructor.

source

pub fn get_gas(&self) -> u64

Returns the gas limit to deploy the smart contract.

source

pub fn gas(&mut self, gas: u64) -> &mut Self

Sets the gas limit to deploy the smart contract.

source

pub fn get_initial_balance(&self) -> Hbar

Returns the initial balance to put into the cryptocurrency account associated with the new smart contract.

source

pub fn initial_balance(&mut self, initial_balance: Hbar) -> &mut Self

Sets the initial balance to put into the cryptocurrency account associated with the new smart contract.

source

pub fn get_max_automatic_token_associations(&self) -> u32

Retunrs the maximum number of tokens that the contract can be automatically associated with.

source

pub fn max_automatic_token_associations( &mut self, max_automatic_token_associations: u32, ) -> &mut Self

Sets the maximum number of tokens that the contract can be automatically associated with.

source

pub fn get_decline_staking_reward(&self) -> bool

If true, the contract will decline receiving a staking reward.

The default value is false.

source

pub fn decline_staking_reward( &mut self, decline_staking_reward: bool, ) -> &mut Self

If set to true, the contract will decline receiving a staking reward.

source

pub fn get_admin_key(&self) -> Option<&Key>

Reutrns the admin key for the new contract.

source

pub fn admin_key(&mut self, admin_key: impl Into<Key>) -> &mut Self

Sets the admin key for the new contract.

source

pub fn get_auto_renew_account_id(&self) -> Option<AccountId>

Returns the account to be used at the contract’s expiration time to extend the life of the contract.

source

pub fn auto_renew_account_id( &mut self, auto_renew_account_id: AccountId, ) -> &mut Self

Sets the account to be used at the contract’s expiration time to extend the life of the contract.

source

pub fn get_auto_renew_period(&self) -> Option<Duration>

Returns the auto renew period for the smart contract.

source

pub fn auto_renew_period(&mut self, auto_renew_period: Duration) -> &mut Self

Sets the auto renew period for the smart contract.

source

pub fn get_contract_memo(&self) -> Option<&str>

Returns the memo for the new smart contract.

source

pub fn contract_memo(&mut self, contract_memo: String) -> &mut Self

Sets the memo for the new smart contract.

source

pub fn get_staked_account_id(&self) -> Option<AccountId>

Returns the ID of the account to which the contract is staking.

source

pub fn staked_account_id(&mut self, staked_account_id: AccountId) -> &mut Self

Sets the ID of the account to which the contract is staking.

source

pub fn get_staked_node_id(&self) -> Option<u64>

Returns ID of the node to which the contract is staking.

source

pub fn staked_node_id(&mut self, staked_node_id: u64) -> &mut Self

Sets the ID of the node to which the contract is staking.

source

pub fn freeze_with(&mut self, client: Client) -> &mut Self

Sets the client to use for freezing the generated ContractCreateTransaction.

By default freezing will use the client provided to execute.

Note: This only affects the ContractCreateTransaction currently, that is not guaranteed to always be the case.

source

pub fn sign(&mut self, key: PrivateKey) -> &mut Self

Sets the signer for use in the ContractCreateTransaction

Important: Only one signer is allowed.

source

pub fn sign_with<F: Fn(&[u8]) -> Vec<u8> + Send + Sync + 'static>( &mut self, public_key: PublicKey, signer: F, ) -> &mut Self

Sets the signer for use in the ContractCreateTransaction

Important: Only one signer is allowed.

source

pub async fn execute(&self, client: &Client) -> Result<TransactionResponse>

Generates the required transactions and executes them all.

source

pub async fn execute_with_timeout( &self, client: &Client, timeout_per_transaction: Duration, ) -> Result<TransactionResponse>

Generates the required transactions and executes them all.

Trait Implementations§

source§

impl Debug for ContractCreateFlow

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ContractCreateFlow

source§

fn default() -> ContractCreateFlow

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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.

source§

impl<T> Instrument for T

source§

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

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

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 T
where 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.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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