A budget allocating system using Circle API and ENS to provide a seamless experience with crypto-currency money transfer inside an organiosation.
This project implements a budget allocating system like we can find in traditional banking system such as Qonto with their Digital Card features. This is super useful to control the company's cash flow and set precise rules regarding spending policies.
BudAl is a Web3 implementation of this system, giving a seamless experience to allocate cryptocurrency for buying goods and services. Using a simple UI, you can create an organisation managing different groups with specific budget allocation, permissions and spending limits. Using Circle API gives a simple abstraction around wallets so you can perform secure and verified actions on the blockchain in few clicks. Budal manage wallets for the user but also ENS domains to simplify the tree structure inside the organisation. For example, an organisation named "acme" will have an ENS "acme.budal.eth" and its group will be prefix by the organisation ENS (e.g., "marketing.acme.budal.eth"). This also allow users to validate action performed on a smart contract using a simple PIN code.
Then you can interact with your organisation following a graph view and add different people to it. Each member of the organisation can be include into a group to be able to claim part of the budget. As we said before, when you create a group, you can define different settings such as the amount of token allocated, the spending rate and limits. To ensure the respect of the limits, everything is defined in a smart contrain on chain that we developed and the Budal backend serves as a proxy to hide complexity.
When a member of a group want to use the money, he can simply apply for a claim and he'll receive the money on its registered address (an user managed account of Circle API) after approval.
The BudAl WebApp also use the Nouns DAO to display member's profile picture, we planned to add an evolution process depending on the role and budget used but we didn't had time unfortunately.
In short, Budal is an accessible solution to democratize cryptocurrency usage around businesses and mostly target B2B customers.
The project is composed of 3 different part:
The WebApp uses the Tailwind component library to display elegant components and Next to run the application. For request caching we use RTK. We also used the Circle Web SDK to setup user controlled wallet pin creation, providing a nice and secure way to create a wallet without directly dealing with web3.
The Backend is done in TypeScript and runs on Node using tsx. It exposes a REST API that handle the logic inside its endpoints (user creation, authentication, organisation and groups management, operations on chain...). We use redis to store user sessions, prisma/sqlite to store permanent data that we don't want to store on chain and zod for input validation. The backend also implements a wrapper around the Circle User SDK to perform create the user, initializes its wallet and get user's related information stored by Circle. On top of that, we extended the existing Circle SDK to perform contract execution, unfortunately, this feature wasn't implement in the SDK so we create our own called ContractSDK. This is in charge of the interaction with our deployed smart contract that store and manage an organisation. We also added a wrapper around the ENS client to verify and create subdomains for organisation and group. It uses the viem library and @ensdomain to interact with the ens contract.
The Smart contract is responsible of the management and allocation of the differents groups and budget inside an organisation. It stores datas sent by the Budal backend (ENS, wallet address...). There are multiples methods such as budget allocation, the spending rate and its limits (e.g a budget of 1ETH with a spending rate of 0.1ETH by day).
Some hacky things we did to make things works: