Executes a function call on a target contract from within the smart account context.
e - Access to the Soroban environment.target - The address of the contract to call.target_fn - The function name to invoke on the target contract.target_args - Arguments to pass to the target function.Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then calling
e.invoke_contract().
fn execute(
env: soroban_sdk::Env,
target: soroban_sdk::Address,
target_fn: soroban_sdk::Symbol,
target_args: soroban_sdk::Vec,
)
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
operator: soroban_sdk::Address,
)
Adds a new policy to an existing context rule, installs it, and returns
the assigned policy ID. The policy's install method will be called
during this operation.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to modify.policy - The address of the policy contract to add.install_param - The installation parameter for the policy.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.SmartAccountError::DuplicatePolicy] - When the policy already
exists in the rule.SmartAccountError::TooManyPolicies] - When adding would exceed
MAX_POLICIES (5).["policy_added", context_rule_id: u32][policy_id: u32]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::add_policy].
fn add_policy(
env: soroban_sdk::Env,
context_rule_id: u32,
policy: soroban_sdk::Address,
install_param: soroban_sdk::Val,
) -> u32
Adds a new signer to an existing context rule, returning the assigned signer ID.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to modify.signer - The signer to add to the context rule.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.SmartAccountError::DuplicateSigner] - When the signer already
exists in the rule.SmartAccountError::TooManySigners] - When adding would exceed
MAX_SIGNERS (15).["signer_added", context_rule_id: u32][signer_id: u32]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::add_signer].
fn add_signer(env: soroban_sdk::Env, context_rule_id: u32, signer: Signer) -> u32
fn __check_auth(
env: soroban_sdk::Env,
signature_payload: soroban_sdk::BytesN<32>,
signatures: AuthPayload,
auth_contexts: soroban_sdk::Vec,
) -> Result<(), SmartAccountError>
Contract constructor — invoked exactly once by the host as part of
create_contract_v2 (deploy_v2) and never callable afterward, so it
needs no "already initialized" guard or require_auth: the deploying
transaction authorizes the whole creation, and the host will not
dispatch a later invocation to __constructor. Installs the initial
Default context rule with the deployer-supplied signers/policies.
fn __constructor(
env: soroban_sdk::Env,
signers: soroban_sdk::Vec,
policies: soroban_sdk::Map,
)
Retrieves the global registry ID for a policy.
e - Access to the Soroban environment.policy - The policy address to look up.SmartAccountError::PolicyNotFound] - When the policy is not
registered in the global registry.fn get_policy_id(env: soroban_sdk::Env, policy: soroban_sdk::Address) -> u32
Retrieves the global registry ID for a signer.
e - Access to the Soroban environment.signer - The signer to look up.SmartAccountError::SignerNotFound] - When the signer is not
registered in the global registry.fn get_signer_id(env: soroban_sdk::Env, signer: Signer) -> u32
Removes a policy from an existing context rule and uninstalls it. The
policy's uninstall method will be called during this operation.
Removing the last policy is allowed only if the rule has at least
one signer.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to modify.policy_id - The ID of the policy to remove from the context rule.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.SmartAccountError::PolicyNotFound] - When the policy doesn't exist
in the rule.["policy_removed", context_rule_id: u32][policy_id: u32]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::remove_policy].
fn remove_policy(env: soroban_sdk::Env, context_rule_id: u32, policy_id: u32)
Removes a signer from an existing context rule. Removing the last signer is allowed only if the rule has at least one policy.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to modify.signer_id - The ID of the signer to remove from the context rule.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.SmartAccountError::SignerNotFound] - When the signer doesn't exist
in the rule.["signer_removed", context_rule_id: u32][signer_id: u32]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::remove_signer].
fn remove_signer(env: soroban_sdk::Env, context_rule_id: u32, signer_id: u32)
Deploys a new contract owned by this account, deriving its address
from this account (the deployer) and salt — the same primitive
factory-contract uses to deploy accounts, just invoked from within
an account instead of the factory.
Unlike batch_add_signer/upgrade, this method does not call
e.current_contract_address().require_auth() itself. deploy_v2's
underlying create_contract_with_constructor host function already
requires authorization from the deployer address — since
with_current_contract makes that deployer this account itself, the
host produces a real
CreateContractHostFn/CreateContractWithCtorHostFn auth context
for __check_auth to validate against a stored
CreateContract(wasm_hash) context rule. Adding an explicit
self-require_auth() here as well would just demand a second,
unrelated authorization (matched as a generic Context::Contract
call to this function, gated by a Default/CallContract(self)
rule instead) — that's what the other methods need, since non
fn deploy_contract(
env: soroban_sdk::Env,
wasm_hash: soroban_sdk::BytesN<32>,
salt: soroban_sdk::BytesN<32>,
constructor_args: soroban_sdk::Vec,
) -> soroban_sdk::Address
Creates a new context rule with the specified configuration, returning
the newly created ContextRule with a unique ID assigned. Installs
all specified policies during creation.
e - Access to the Soroban environment.context_type - The type of context this rule applies to.name - Human-readable name for the context rule.valid_until - Optional expiration ledger sequence.signers - List of signers authorized by this rule.policies - Map of policy addresses to their installation parameters.SmartAccountError::NoSignersAndPolicies] - When both signers and
policies are empty.SmartAccountError::TooManySigners] - When signers exceed
MAX_SIGNERS (15).SmartAccountError::TooManyPolicies] - When policies exceed
MAX_POLICIES (5).SmartAccountError::DuplicateSigner] - When the same signer appears
multiple times.SmartAccountError::PastValidUntil] - When valid_until is in the
past.SmartAccountError::MathOverflow] - When the context rule, sifn add_context_rule(
env: soroban_sdk::Env,
context_type: ContextRuleType,
name: soroban_sdk::String,
valid_until: Option,
signers: soroban_sdk::Vec,
policies: soroban_sdk::Map,
) -> ContextRule
fn batch_add_signer(
env: soroban_sdk::Env,
context_rule_id: u32,
signers: soroban_sdk::Vec,
)
Retrieves a context rule by its unique ID, returning the
ContextRule containing all metadata, signers, and policies.
e - Access to the Soroban environment.context_rule_id - The unique identifier of the context rule to
retrieve.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.fn get_context_rule(env: soroban_sdk::Env, context_rule_id: u32) -> ContextRule
Removes a context rule and cleans up all associated data. This function uninstalls all policies associated with the rule and removes all stored data including signers, policies, and metadata.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to remove.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.["context_rule_removed", context_rule_id: u32][]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::remove_context_rule].
fn remove_context_rule(env: soroban_sdk::Env, context_rule_id: u32)
Returns the index-th contract this account has deployed via
deploy_contract, in deployment order.
LatchSmartAccountError::DeployedContractNotFound] - If no deployed
contract is recorded at index.fn get_deployed_contract(env: soroban_sdk::Env, index: u32) -> DeployedContract
Retrieves the number of all context rules, including expired rules. Defaults to 0.
e - Access to the Soroban environment.fn get_context_rules_count(env: soroban_sdk::Env) -> u32
Updates the name of an existing context rule, returning the updated
ContextRule with the new name.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to update.name - The new human-readable name for the context rule.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.["context_rule_meta_updated", context_rule_id: u32][name: String, context_type: ContextRuleType, valid_until: Option<u32>]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::update_context_rule_name].
fn update_context_rule_name(
env: soroban_sdk::Env,
context_rule_id: u32,
name: soroban_sdk::String,
) -> ContextRule
Returns the number of contracts this account has deployed via
deploy_contract. Defaults to 0.
fn get_deployed_contract_count(env: soroban_sdk::Env) -> u32
Updates the expiration time of an existing context rule, returning the
updated ContextRule with the new expiration time.
e - Access to the Soroban environment.context_rule_id - The ID of the context rule to update.valid_until - New optional expiration ledger sequence. Use None
for no expiration.SmartAccountError::ContextRuleNotFound] - When no context rule
exists with the given ID.SmartAccountError::PastValidUntil] - When valid_until is in the
past.["context_rule_meta_updated", context_rule_id: u32][name: String, context_type: ContextRuleType, valid_until: Option<u32>]Defaults to requiring authorization from the smart account itself
(e.current_contract_address().require_auth()) and then delegating to
[storage::update_context_rule_valid_until].
fn update_context_rule_valid_until(
env: soroban_sdk::Env,
context_rule_id: u32,
valid_until: Option,
) -> ContextRule