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
Verify authorization for the smart account.
This function is called by the Soroban host when authorization is required. It validates signatures against the configured context rules and policies.
signature_payload - Hash of the data that was signedsignatures - Map of signers to their signature dataauth_contexts - Contexts being authorized (contract calls,
deployments, etc.)Ok(()) if authorization succeedsErr(SmartAccountError) if authorization failsfn __check_auth(
env: soroban_sdk::Env,
signature_payload: soroban_sdk::BytesN<32>,
signatures: AuthPayload,
auth_contexts: soroban_sdk::Vec,
) -> Result<(), soroban_sdk::Error>
Creates a default context rule with the provided signers and policies.
signers - Vector of signers (Delegated or External) that can
authorize transactionspolicies - Map of policy contract addresses to their installation
parametersfn __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)
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)
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
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