"""Vaultfire Key Protocol — Quickstart Example

Protect your AI agent's wallet in 5 lines of code.
This example shows how to create a KeyVault with spending policies
so no prompt injection or leaked key can drain your funds.
"""

from vkp import VKPClient

# 1. Connect to the network
client = VKPClient(
    rpc_url="https://mainnet.base.org",
    network_id="base-mainnet",
    factory_address="0x...",  # Replace with deployed VKPFactory address
)

# 2. Create a KeyVault with spending policies
# Your agent's wallet is now wrapped — on-chain policies can't be bypassed
tx = client.keyvault.create_vault(
    from_address="0xYourAgentAddress",
    max_per_tx="0.1",           # Max 0.1 ETH per transaction
    max_hourly="0.5",           # Max 0.5 ETH per hour
    max_daily="1.0",            # Max 1.0 ETH per day
    emergency_threshold="5.0",  # Freeze if total ever exceeds 5 ETH
)

print("Sign and send this transaction to create your KeyVault:")
print(tx)

# 3. Check your vault status
# status = client.keyvault.get_status("0xYourVaultAddress")
# print(f"Balance: {status.balance_eth} ETH")
# print(f"Remaining hourly: {status.remaining_hourly_wei} wei")
# print(f"Frozen: {status.policy.frozen}")

# 4. Execute transactions through the vault (policy-enforced)
# tx = client.keyvault.execute(
#     vault_address="0xYourVaultAddress",
#     from_address="0xYourAgentAddress",
#     to="0xTargetContract",
#     value="0.05",
#     data=b"",
# )

# 5. Emergency freeze if something goes wrong
# tx = client.keyvault.freeze(
#     vault_address="0xYourVaultAddress",
#     from_address="0xYourAgentAddress",
# )
