Task: Implement User Management Contract Integration Hook
Description
Implement the integration of the user_management contract in the frontend to manage user creation, updates, and retrieval using Stellar smart contracts. The integration must be modular, reusable, and ready for use in the welcome page for user onboarding logic.
Prerequisites
-
Wallet Provider Context:
Ensure that the wallet provider is functional and accessible across the app to retrieve the user wallet address.
-
Contract Deployment:
Verify that the user_management contract is deployed on the Stellar testnet. Check deployment details or connections in the SkillCert Contracts Repository.
-
Contract Binding:
Confirm that the contract binding (auto-generated classes/interfaces) exists.
- Expected path:
src/contract_connections/user_management_binding
- If missing, generate the binding using the Stellar CLI and place it in the specified folder.
Requirements
-
Hook Creation:
Create a React hook file named useUserManagement.ts inside src/hooks/.
The hook must:
-
Import and use the user_management_binding contract.
-
Provide functions:
createUser(address: string, data: UserProfileInput): Promise<void>
updateUser(address: string, data: UserProfileUpdate): Promise<void>
getUser(address: string): Promise<UserProfile | null>
-
Use the wallet address, signer, and contract ID as external parameters — do not access wallet context directly inside the hook.
-
Error Handling:
- Implement structured error handling with clear console logs or thrown exceptions.
- Validate required parameters (e.g.,
address, contractId) before calling the contract.
-
Usage Example (Welcome Page):
In src/app/welcome/page.tsx:
- Retrieve the connected wallet address from context.
- Call
getUser(address) on load.
- If a profile exists, redirect to
/dashboard.
- Otherwise, remain in
/welcome.
-
Testing:
Deliverables
Acceptance Criteria
- The hook successfully connects to the deployed contract.
getUser, createUser, and updateUser methods work without context dependencies.
- Routing logic in
/welcome behaves correctly based on user existence.
- No wallet or contract hardcoding in the hook.
- Clean, documented code following TypeScript best practices.
Task: Implement User Management Contract Integration Hook
Description
Implement the integration of the
user_managementcontract in the frontend to manage user creation, updates, and retrieval using Stellar smart contracts. The integration must be modular, reusable, and ready for use in thewelcomepage for user onboarding logic.Prerequisites
Wallet Provider Context:
Ensure that the wallet provider is functional and accessible across the app to retrieve the user wallet address.
Contract Deployment:
Verify that the
user_managementcontract is deployed on the Stellar testnet. Check deployment details or connections in the SkillCert Contracts Repository.Contract Binding:
Confirm that the contract binding (auto-generated classes/interfaces) exists.
src/contract_connections/user_management_bindingRequirements
Hook Creation:
Create a React hook file named
useUserManagement.tsinsidesrc/hooks/.The hook must:
Import and use the
user_management_bindingcontract.Provide functions:
createUser(address: string, data: UserProfileInput): Promise<void>updateUser(address: string, data: UserProfileUpdate): Promise<void>getUser(address: string): Promise<UserProfile | null>Use the wallet address, signer, and contract ID as external parameters — do not access wallet context directly inside the hook.
Error Handling:
address,contractId) before calling the contract.Usage Example (Welcome Page):
In
src/app/welcome/page.tsx:getUser(address)on load./dashboard./welcome.Testing:
Include temporary console logs to confirm:
Deliverables
src/hooks/useUserManagement.tssrc/contract_connections/user_management_bindingsrc/app/welcome/page.tsxAcceptance Criteria
getUser,createUser, andupdateUsermethods work without context dependencies./welcomebehaves correctly based on user existence.