Guardio is a decentralized insurance smart contract built on the Stacks blockchain. It enables trustless insurance policies, premium collection, and claims processing without the need for traditional intermediaries. By leveraging Clarity, Guardio ensures transparent execution, auditable records, and secure fund management.
-
Policy Creation The contract owner can create insurance policies with defined coverage amounts, premium requirements, and policy durations.
-
Policy Purchase Users can purchase policies directly by paying the calculated premium. Coverage terms and expiration dates are recorded on-chain.
-
Claims Management Insured users can file claims against their active policies. Valid claims are settled automatically if the contract fund has sufficient balance.
-
Fund Management Premium payments are collected into a central insurance fund that is used to settle approved claims. The balance is publicly viewable for transparency.
-
Read-Only Queries Users can check policy details, claim history, and the overall insurance fund balance at any time.
-
Constants
- Maximum coverage amount
- Maximum policy duration
- Minimum premium amount
- Error codes for invalid actions
-
Data Maps
insurance-policies
: Stores policy details per userinsurance-claims
: Stores claim amounts and their status
-
Variables
insurance-fund
: Tracks the balance of collected premiums available for claims
-
Public Functions
create-policy
: Allows the contract owner to define a new policy templatepurchase-policy
: Enables users to buy coverage by paying the premiumfile-claim
: Allows users to submit a claim request against their active policy
-
Read-Only Functions
get-policy-details
: Retrieves details of a given user’s policyget-claim-details
: Retrieves claim information for a given userget-fund-balance
: Returns the current balance of the insurance fund
The contract defines structured error codes for clarity and easier debugging:
u100
: Owner-only action requiredu101
: Invalid claim requestu102
: Insufficient funds to pay claimu103
: User does not hold an active policyu104
: Invalid parameters provided
-
Policy Setup The contract owner creates a policy template with defined limits.
-
Policy Purchase A user selects coverage and duration, pays the required premium, and receives an active policy.
-
Claims Filing If an insured event occurs, the user files a claim within their coverage limit.
-
Claims Settlement If valid, the claim is automatically paid out from the insurance fund and recorded on-chain.
-
Transparency All details of policies, claims, and fund balances are queryable via read-only functions.