@mmpotulo/stablecoin-hooks
v1.1.9
Published
React hooks for stablecoin operations build on top of the lisk stablecoin Api
Readme
🚀 @mmpotulo/stablecoin-hooks
React hooks for stablecoin operations, built on top of the Lisk stablecoin API.
✨ Features
- Easy integration of stablecoin operations in React apps
- Caching, error handling, and loading states built-in
- TypeScript support for all hooks and types
- Modular hooks for balances, bank, business, charges, coupons, staff, transactions, transfers, users, and API tokens
📦 Installation
npm install @mmpotulo/stablecoin-hooks🛠️ Usage
Set up your environment variable:
Add to your
.env.local:NEXT_PUBLIC_LISK_API_BASE=https://your-lisk-api-url.com/api/v1Import and use hooks in your React components:
import { useLiskBalances, useLiskBank, useLiskCharges } from "@mmpotulo/stablecoin-hooks"; const { balances, fetchBalances } = useLiskBalances({ apiKey: "your-api-key" }); const { bankAccount, getBankAccount } = useLiskBank({ apiKey: "your-api-key", user }); const { charges, fetchCharges } = useLiskCharges({ apiKey: "your-api-key", user });API Key
Most hooks require an
apiKeyparameter for authentication:const { balances } = useLiskBalances({ apiKey: "your-api-key" });
🧩 Available Hooks
useLiskBalancesuseLiskBankuseLiskBusinessuseLiskChargesuseLiskCouponsuseLiskStaffuseLiskTransactionsuseLiskTransferuseLiskUsersuseCacheuseLiskApiTokensuseStaff
Each hook provides loading, error, and message states, plus API methods for CRUD operations.
📝 Types
All types are exported for use in your app:
import { iUser, iTransaction, iCharge, iBankAccount, ... } from "@mmpotulo/stablecoin-hooks";🧑💻 Development Guidelines
Prerequisites
- Node.js >= 18
- npm >= 9
- TypeScript
Scripts
- Build:
npm run build - Prebuild (auto version bump): Automatically bumps the package version and cleans the dist folder before building.
- Publish:
Publishing is automated via GitHub Actions on push to
main.
Contributing
- Fork the repo and clone locally.
- Create a new branch for your feature or fix.
- Write tests and ensure all hooks are type-safe.
- Run
npm run buildbefore committing. - Submit a PR with a clear description.
Project Structure
hooks/ # All React hooks
types.ts # Shared TypeScript types
scripts/ # Utility scripts (e.g., version bump)
dist/ # Compiled output
.github/ # GitHub Actions workflows🏗️ Example: Using a Hook
import { useLiskUsers } from "@mmpotulo/stablecoin-hooks";
const { users, fetchUsers, usersLoading, usersError } = useLiskUsers({ apiKey: "your-api-key" });
useEffect(() => {
fetchUsers();
}, []);🛡️ Best Practices
- Always provide a valid
apiKeyto hooks. - Use the loading and error states for UX feedback.
- Purge cache when you need fresh data:
fetchUsers(true)orfetchBalances(userId, true) - Keep your
.env.localsecure and never commit secrets.
📚 More Info
- See the source code for details on each hook's API and return values.
- For advanced usage, check out the types and interfaces in
types.ts.
🏁 License
MIT © mmpotulo
