connect To Contract
Connects the kit to an existing smart account by contract address alone, with no passkey credential and no WebAuthn ceremony.
Intended for backends and autonomous signers (e.g. a reference agent holding an Ed25519 key) that operate via the multi-signer / external-signer pipeline. The connected state is populated with the real contractId and a null credential, marking the connection as headless. After this call, OZSmartAccountKit.isConnected is true, OZSmartAccountKit.isHeadless is true, OZSmartAccountKit.contractId is contractId, and OZSmartAccountKit.credentialId is null.
Behaviour:
Validates contractId is a contract address (C...), before any network call.
Verifies the contract exists on-chain (reuses the shared existence check).
Best-effort clears any previously saved session so a later silent connectWallet restore cannot resurrect a stale passkey session that contradicts this headless in-memory state. A persistent-storage write failure here is swallowed so it cannot leave the kit unconnected; a later connectWallet could then still restore a stale session.
Sets the connected state with a null credential.
Emits SmartAccountEvent.HeadlessConnected (never SmartAccountEvent.WalletConnected, which carries a credential a headless connection does not have).
This path writes no session and performs no WebAuthn or credential-storage work.
Operating boundary
The single-passkey signing paths (OZTransactionOperations.submit, OZTransactionOperations.executeAndSubmit, OZTransactionOperations.transfer, OZTransactionOperations.contractCall, and any manager operation left at the default empty selectedSigners) throw WalletException.HeadlessConnection after a headless connect: they need a passkey credential to produce a WebAuthn signature, and a headless connection holds none. Use the multi-signer / external-signer pipeline (calls made with a non-empty selectedSigners) instead. OZTransactionOperations.fundWallet is the exception: it works headlessly on testnet because it signs with a temporary Friendbot keypair and never routes through the single-passkey submit path.
Return
The connected contract address (the validated contractId).
Parameters
The smart account contract address (C-address) to attach to.
Throws
if contractId is not a valid C-address.
if no contract instance exists at contractId.