Skip to content

Split Contract Clone Factory for Per-Invoice Deployment #494

Description

@Kingsman-99

Description

Deploying a fresh WASM instance per invoice is gas-intensive. A clone factory pattern should deploy minimal-proxy or thin-init clones pointing to a single canonical WASM blob, reducing deployment cost while maintaining per-invoice state isolation.

Technical Context

Add a SplitFactory contract in contracts/factory/src/lib.rs (new crate in the workspace Cargo.toml). Implement deploy_invoice_contract(wasm_hash: BytesN<32>, salt: BytesN<32>, init_args: Vec<Val>) using env.deployer().with_current_contract(salt). Register each deployed address under DeployedContracts(creator) in factory storage.

Acceptance Criteria

  • Factory deploys a new split contract with a unique address per (creator, salt) pair
  • Duplicate salts for the same creator are rejected
  • ContractDeployed(creator, contract_address) event is emitted by the factory
  • The factory is added to the workspace Cargo.toml as a new member
  • Integration test deploys via factory and invokes init on the deployed contract
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions