Public Functions
Public functions modify blockchain state and require a signed transaction. Users must pay gas fees (STX) to execute these functions.set-risk-profile
Save or update user’s risk tolerance level on-chain.contracts/staxiq-user-profile.clar:70
uint
required
User’s risk tolerance:
u1 (Conservative), u2 (Balanced), or u3 (Aggressive)response
Behavior
- If profile exists: Updates
risk-levelandupdated-at, preservescreated-atandstrategy-count - If profile doesn’t exist: Creates new profile with
created-atset to current block height - Validates risk level is 1, 2, or 3 before writing
- Transaction must be signed by the user (tx-sender)
Example Usage
save-strategy
Anchor an AI-generated strategy recommendation to the blockchain.contracts/staxiq-user-profile.clar:99
string-ascii
required
SHA-256 hash (hex string) of the complete strategy details. Should be 64 characters.
string-ascii
required
Name of the target DeFi protocol (e.g., “ALEX”, “Velar”, “StackSwap”). Max 32 characters.
response
Behavior
- Requires user to have an existing risk profile (call
set-risk-profilefirst) - Increments strategy counter and assigns new strategy ID
- Stores strategy with user’s current risk level
- Updates profile’s
strategy-countandupdated-atfields - Each strategy is permanently stored and cannot be modified
Example Usage
Read-Only Functions
Read-only functions query blockchain data without modifying state. They are free to call (no gas fees) and return data instantly.get-user-profile
Retrieve complete profile information for a user.contracts/staxiq-user-profile.clar:142
principal
required
Stacks wallet address (e.g.,
ST9ZZEP9M6VZ9YJA0P69H313CRPV0HQ1ZNPVS8NZ)response
Example Usage
get-strategy
Retrieve a specific strategy from user’s history.contracts/staxiq-user-profile.clar:150
principal
required
Stacks wallet address of the user
uint
required
Strategy ID number (starting from 1)
response
Example Usage
get-strategy-count
Get total number of strategies saved by a user.contracts/staxiq-user-profile.clar:161
principal
required
Stacks wallet address
Example Usage
has-profile
Check if a user has created a risk profile.contracts/staxiq-user-profile.clar:166
principal
required
Stacks wallet address
bool
true if user has a profile, false otherwiseExample Usage
get-risk-label
Get user’s risk level as a human-readable string.contracts/staxiq-user-profile.clar:171
principal
required
Stacks wallet address
response
Example Usage
Function Summary
Public Functions (Require Transaction)
Read-Only Functions (Free)
Next Steps
Integration Guide
Learn how to call these functions from your app
Testing
Test contract functions locally