You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -295,6 +296,7 @@ data class OZSmartAccountConfig(
295
296
-`externalWallet`: Optional wallet adapter (`ExternalWalletAdapter`) backing the adapter custody model for `SelectedSigner.Wallet` (G-address) signers. The kit injects it into `kit.externalSigners`.
296
297
-`externalEd25519Adapter`: Optional Ed25519 adapter (`OZExternalEd25519SignerAdapter`) backing the adapter custody model for `SelectedSigner.Ed25519` signers (hardware wallet, HSM, remote signing service). The kit injects it into `kit.externalSigners`. See [External Signer Management](#external-signer-management).
297
298
-`maxContextRuleScanId`: Upper bound on rule IDs to scan when iterating context rules (defaults to 50). Increase if the account has had many add/remove cycles.
299
+
-`defaultPolicies`: Policies installed on a new wallet's Default context rule at deploy time, keyed by policy contract address (C...) with the policy's install parameters as the value (see `PolicyInstallParams.toScVal()`). Applied through the contract constructor by `createWallet` and `deployPendingCredential`; a per-call `policies` argument overrides it. Defaults to no policies. Maximum 5. See the `createWallet``policies` parameter for the built-in policies' install constraints at deploy time.
298
300
299
301
### Platform-Specific Providers
300
302
@@ -411,7 +413,8 @@ suspend fun createWallet(
411
413
autoSubmit:Boolean = false,
412
414
autoFund:Boolean = false,
413
415
nativeTokenContract:String? = null,
414
-
forceMethod:SubmissionMethod? = null
416
+
forceMethod:SubmissionMethod? = null,
417
+
policies:Map<String, SCValXdr>? = null
415
418
): CreateWalletResult
416
419
```
417
420
@@ -423,6 +426,7 @@ Creates a new smart account wallet with WebAuthn passkey authentication.
423
426
-`autoFund`: Whether to automatically fund the wallet after deployment (testnet only)
424
427
-`nativeTokenContract`: Required if `autoFund` is true; the native token contract address
425
428
-`forceMethod`: Optional override to force relayer or RPC submission (default: auto-detect based on config)
429
+
-`policies`: Policies to install on the new wallet's Default context rule at deploy time (via the contract constructor), keyed by policy contract address (C...) with the policy's install parameters as the value (see `PolicyInstallParams.toScVal()`). When null (default), `OZSmartAccountConfig.defaultPolicies` is used; pass a map (including an empty one) to override that default. Validated before the passkey ceremony, so an invalid policy config fails without creating an orphaned credential. Maximum 5 policies. Note the built-in policies' own install rules apply against this Default rule and its single initial signer: a spending-limit policy installs only on CallContract rules and cannot be installed here, and a threshold must not exceed the signer count. A threshold of 1 installs and keeps the rule at 1-of-N as more signers are added; beyond that, constructor policies are primarily useful for custom policies.
426
430
427
431
**Returns**: `CreateWalletResult` containing credential ID, contract address, signed transaction XDR, optional transaction hash, and nickname
428
432
@@ -623,7 +627,8 @@ suspend fun deployPendingCredential(
623
627
autoSubmit:Boolean = true,
624
628
autoFund:Boolean = false,
625
629
nativeTokenContract:String? = null,
626
-
forceMethod:SubmissionMethod? = null
630
+
forceMethod:SubmissionMethod? = null,
631
+
policies:Map<String, SCValXdr>? = null
627
632
): DeployPendingResult
628
633
```
629
634
@@ -637,6 +642,7 @@ The kit's connected state and session are set before the deploy transaction is s
637
642
-`autoFund`: Whether to fund the wallet after deployment via Friendbot (default: false, testnet only)
638
643
-`nativeTokenContract`: Required if `autoFund` is true; the native token contract address
639
644
-`forceMethod`: Optional override to force relayer or RPC submission (default: auto-detect based on config)
645
+
-`policies`: Policies to install on the Default context rule at deploy time, keyed by policy contract address (C...). When null (default), `OZSmartAccountConfig.defaultPolicies` is used; pass a map (including an empty one) to override it. Constructor args are not part of the contract-address preimage, so the derived address is unchanged. Maximum 5 policies.
640
646
641
647
**Returns**: `DeployPendingResult` containing contract address, signed transaction XDR, and optional transaction hash
642
648
@@ -1346,6 +1352,8 @@ Low-level method that adds a pre-registered WebAuthn passkey signer to a context
1346
1352
-`selectedSigners`: Optional multi-signer authorization (default: single-signer with the connected passkey).
1347
1353
-`forceMethod`: Optional override to force relayer or RPC submission (default: auto-detect based on config).
1348
1354
1355
+
**Contract limit**: Signer key data (`publicKey` + `credentialId` combined) max 256 bytes.
1356
+
1349
1357
**Returns**: `TransactionResult` indicating success or failure
1350
1358
1351
1359
**Throws**:
@@ -1890,6 +1898,8 @@ suspend fun addContextRule(
1890
1898
**Contract limits**:
1891
1899
- Max 15 signers per rule
1892
1900
- Max 5 policies per rule
1901
+
- Name max 20 UTF-8 bytes
1902
+
- External signer key data max 256 bytes
1893
1903
1894
1904
**Returns**: `TransactionResult`
1895
1905
@@ -2003,7 +2013,7 @@ Updates the name of a context rule.
2003
2013
2004
2014
**Parameters**:
2005
2015
-`id`: Context rule ID
2006
-
-`name`: New rule name (must not be empty)
2016
+
-`name`: New rule name (must not be empty; max 20 UTF-8 bytes)
2007
2017
-`selectedSigners`: Optional multi-signer authorization (default: single-signer with the connected passkey).
2008
2018
-`forceMethod`: Optional override to force relayer or RPC submission (default: auto-detect based on config).
2009
2019
@@ -2888,7 +2898,7 @@ val indexer = OZIndexerClient.forNetwork("Test SDF Network ; September 2015")
Codec for reading and writing `SmartAccountAuthPayload` to and from `SCValXdr`. Inner signer entries are sorted by lowercase-hex of their XDR-encoded keys for deterministic encoding. Signature bytes are verifier-dependent: WebAuthn and Policy entries are XDR-encoded `SCValXdr`; Ed25519 entries carry the raw 64-byte signature (no XDR wrapper).
3356
+
Codec for reading and writing `SmartAccountAuthPayload` to and from `SCValXdr`. Inner signer entries are sorted in the Soroban host's ScMap key order (content order, length as tiebreaker), matching how the contract materializes the map. Signature bytes are verifier-dependent: WebAuthn and Policy entries are XDR-encoded `SCValXdr`; Ed25519 entries carry the raw 64-byte signature (no XDR wrapper).
3347
3357
3348
3358
-`read(signatureScVal)` — accepts `SCValXdr.Void` (returns an empty payload) or `SCValXdr.Map` (the full payload).
3349
3359
-`write(payload)` — builds the outer map (`context_rule_ids` then `signers`) and sorts the inner signer entries deterministically.
@@ -3569,7 +3579,7 @@ sealed class SmartAccountException(
> When inspecting an error code, first check the exception type to determine which namespace it belongs to. The SDK does not parse or map contract error codes — it surfaces the raw `Error(Contract, #NNNN)` message inside the exception, and the consumer extracts and interprets the code.[`ContractErrorCodes`](#contracterrorcodes)is a consumer-side reference catalog for that interpretation; the full on-chain enum is defined by the smart-account contract source (see [`SmartAccountError`, `WebAuthnError`, and policy error enums in `OpenZeppelin/stellar-contracts`](https://github.com/OpenZeppelin/stellar-contracts)).
3582
+
> When inspecting an error code, first check the exception type to determine which namespace it belongs to. For a contract error, the SDK surfaces the raw `Error(Contract, #NNNN)` message inside the exception; extract the numeric code and pass it to[`ContractErrorCodes.decode`](#contracterrorcodes)to resolve it to its defining contract and variant name (or match it against a constant). The full on-chain enum is defined by the smart-account contract source (see [`SmartAccountError`, `WebAuthnError`, and policy error enums in `OpenZeppelin/stellar-contracts`](https://github.com/OpenZeppelin/stellar-contracts)).
3573
3583
3574
3584
```kotlin
3575
3585
enumclassSmartAccountErrorCode(valcode:Int) {
@@ -3769,17 +3779,37 @@ sealed class IndexerException : SmartAccountException {
3769
3779
3770
3780
### ContractErrorCodes
3771
3781
3772
-
Defined in `smartaccount/core/SmartAccountErrors.kt`. A **curated subset** of on-chain error codes from the OpenZeppelin smart-account contract, provided as a reference catalog for consumers. The SDK does not parse or map these codes — failed transactions surface the raw `Error(Contract, #NNNN)` message inside the exception, and the consumer matches the extracted code against these constants. Error code range: 3xxx.
3782
+
Defined in `smartaccount/core/SmartAccountErrors.kt`. Named constants for the smart-account contract's own error enum (the codes a caller is most likely to branch on), plus `decode(code)`, which resolves any known code — smart account, WebAuthn, or a policy contract — into the contract and variant name that defined it. A failed transaction surfaces the raw `Error(Contract, #NNNN)` message inside the exception (typically `TransactionException.SimulationFailed`); extract the code and pass it to `decode`, or match it against a constant. Alternatively, pass a thrown `TransactionException`'s message directly to `decodeFromMessage`, which extracts and decodes the first known marker in one step. Error code range: 3xxx.
3773
3783
3774
-
This object does not mirror the full on-chain enum. The smart-account contract additionally defines codes for context-rule lookup, auth-payload validation, external verification, WebAuthn parsing (3110–3119), and policy enforcement (3200–3227 across the simple-threshold, weighted-threshold, and spending-limit policies). See the contract source for the full list: [OpenZeppelin/stellar-contracts — `packages/accounts`](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/accounts). Note that several values in the 3xxx range also exist in the SDK-side [`SmartAccountErrorCode`](#smartaccounterrorcode) enum with different meanings — the two are distinguished by the exception type they arrive through.
3784
+
`decode` returns an `OZContractError` (`code`, `contract`, `name`) or `null` for an unknown code. It covers the full on-chain surface: `SmartAccountError` (3000–3016; 3001 unused), `WebAuthnError`(3110–3119), and the policy enums `SimpleThresholdError`(3200–3203), `WeightedThresholdError` (3210–3214), and `SpendingLimitError` (3220–3227). Variant names repeat across the policy enums, so `contract` disambiguates; `code` is globally unique. Note that several 3xxx values also exist in the SDK-side [`SmartAccountErrorCode`](#smartaccounterrorcode) enum with different meanings — the two are distinguished by the exception type they arrive through.
3775
3785
3776
3786
```kotlin
3787
+
data classOZContractError(valcode:Int, valcontract:String, valname:String)
3788
+
3777
3789
object ContractErrorCodes {
3778
-
constvalMATH_OVERFLOW=3012// Integer arithmetic overflow occurred in the contract
3779
-
constvalKEY_DATA_TOO_LARGE=3013// The key_data field on a signer exceeds the maximum allowed size
3780
-
constvalCONTEXT_RULE_IDS_LENGTH_MISMATCH=3014// The number of context rule IDs does not match the expected count
3781
-
constvalNAME_TOO_LONG=3015// A name field (e.g. context rule name) exceeds the maximum allowed length
3782
-
constvalUNAUTHORIZED_SIGNER=3016// The signer is not authorized to sign the given context rule
Copy file name to clipboardExpand all lines: docs/smart-accounts/onboarding.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ You can add rules that apply only to specific scenarios. For example, a rule tha
94
94
Each context rule stores:
95
95
- An ID (`u32`)
96
96
- A type: `Default`, `CallContract(address)`, or `CreateContract(wasmHash: ByteArray)`. `wasmHash` is a 32-byte `ByteArray` containing the SHA-256 hash of a compiled smart contract binary. `CreateContract` matches contract creation operations targeting that specific binary.
97
-
- A name (human-readable string)
97
+
- A name (human-readable string, up to 20 UTF-8 bytes)
98
98
- A list of signers (up to 15)
99
99
- A list of policies (up to 5)
100
100
- An optional expiration ledger number. After that ledger is reached, the rule no longer authorizes anything, useful for temporary authorization grants.
@@ -170,6 +170,8 @@ kit.policyManager.addPolicy(
170
170
171
171
The install parameters are policy-specific. Your custom policy contract defines what parameters it expects during installation.
172
172
173
+
Policies can also be installed at deploy time on the wallet's Default rule, instead of being added afterward. Set `OZSmartAccountConfig.defaultPolicies`, or pass a per-call `policies` map to `createWallet` / `deployPendingCredential`, keyed by policy contract address with the policy's install parameters as the value. The kit passes them through the contract constructor, so the new wallet starts with those policies already enforced; a per-call argument overrides the config default. Because the Default rule starts with a single signer and the spending-limit policy only installs on CallContract rules, this is primarily useful for a threshold of 1 (which keeps the rule at 1-of-N as more signers are added) or custom policies.
174
+
173
175
A typical setup involves 3-5 deployed contracts: the smart account (one per user), a WebAuthn verifier (shared across all accounts on the network), and 1-3 policy contracts (also shared).
Copy file name to clipboardExpand all lines: docs/smart-accounts/scf/oz-sm-architecture.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ Signer encoding follows the standard Soroban enum serialization for the on-chain
141
141
142
142
**Signature normalization**: WebAuthn produces DER-encoded secp256r1 signatures. The KMP SDK converts these to compact 64-byte format with low-S enforcement, as required by the on-chain verifier.
143
143
144
-
**Auth entry signing**: The KMP SDK computes `SHA-256(XDR(HashIDPreimage::SorobanAuthorization))` as the payload hash. Signature values use double XDR encoding (encode SCVal to bytes, wrap in SCVal::Bytes). SCVal map keys are sorted by XDR-encoded byte representation for deterministic ordering.
144
+
**Auth entry signing**: The KMP SDK computes `SHA-256(XDR(HashIDPreimage::SorobanAuthorization))` as the payload hash. Signature values use double XDR encoding (encode SCVal to bytes, wrap in SCVal::Bytes). SCVal map keys are sorted in the Soroban host's ScMap key order (content order, length as tiebreaker) for deterministic encoding.
145
145
146
146
**Storage security**: Android uses AES-256-GCM encryption backed by the Android Keystore. Apple platforms use the system Keychain. Web uses IndexedDB. Stored data contains only public keys and session metadata, never secret keys.
0 commit comments