Inspiration

While researching and developing dApps on different blockchains, we always wondered what business model we could transform from Web2 to Web3. In the Web2 ecosystem, subscription & recurring payment is a popular and effective business model. Recurring payment-related Web2 applications have some obvious limitations:

  • Most do not support cryptocurrency.
  • High transaction fee.
  • To use or integrate are complicated and many steps, requiring a deep understanding of the SDK and API.
  • Payment is limited by credit card type, country, and bank.
  • Be slow with updates and changes.

Meanwhile, the cryptocurrency market is still very potential, and there is almost no similar Web3 application, especially in the BTTC ecosystem. This ecosystem has many advantages:

  • Supports tokens from 3 major ecosystems: Tron, BNB chain, and Ethereum.
  • The transaction fee is small, and the processing speed is good, so it is very suitable for applications with large recurring transactions.
  • Global and uncensored.
  • Easy to update and change.

When we thought about how the app we built could contribute to and promote the ecosystem on BTTC, we were more motivated to get started, even though we knew we would have many challenges. If done, it can bring more value to users.

What it does

Main features

Deposit: transfer money from wallet to smart contract, allowing to make payments later. DApp supports three basic tokens on the BitTorrent chain: BTT, USDT, and TRX. The amount of money deposited will be managed according to each Wallet address; therefore, it will ensure security and privacy.

Create subscription product: includes two main components: Subscription Plans and General Information.

  • Each product will be created up to 4 plans, and users can choose a Token, Period (Day, Week, Month, Year), Interval, and Price for each.
  • Users can enter information about the product’s title, description, product image, and external link.

Subscribe product: Customers can select a subscription plan and accept recurring payments.

Automation system: the system automatically searches for due date subscriptions, then performs a transaction to add and subtract money in the product provider and subscriber’s accounts.

Other features

Connect wallet: connect to Metamask and perform Smart contract-related features.

Withdraw: allows users to withdraw money from smart contracts to their wallets.

View balance: show user balance in a smart contract.

Cancel subscription: This allows a subscriber to cancel the subscription. In the canceling process, the system will calculate and transfer the amount paid into the account of the product provider, depending on the subscription plan.

View subscriptions: display user’s subscriptions.

View subscribers: display user’s subscribers.

Manage profile: allows users to edit profiles and display information to customers.

Show all subscription products: show all user’s products.

Show all service/product providers: show all service/product providers.

View product details & related products: display product details and associated products.

Manage refund requests: create refund requests, approve, cancel, and reject refund requests.

Integration with Web2 application via API/SDK; this feature is still in beta.

Reports & Statistics: function to display user data on the dashboard page.

Below is a chart depicting a user's balance in an A2N Smart Contract:

Users Balance

How we built it

Architecture Simple Architecture To develop & deploy smart contracts, we use:

  • Solidity
  • Open Zeppelin
  • Truffle

Below is the diagram of a Smart Contract in which: IUser, ISubscriber, IAdmin, ISystem, and IA2N are interfaces. Pausable & ReentrancyGuard is taken from the Open Zeppelin library. Interfaces

To build the dApp front-end, we use:

  • NodeJS, React 18.2 & NextJS 12.3
  • Redux & Redux Toolkit 8.0
  • Chakra UI components
  • Ethers JS & Web3 JS
  • Cloud DB
  • Metamask API.
  • Typescript 4.8

To test smart contract:

  • Mocha & Jest

To build A2N finance API/SDK:

  • NodeJS
  • Ethers JS
  • Typescript
  • Webpack.

Challenges we ran into

Time constraint: we found out about Tron hackathon season 3 late, so we started in October; therefore, it could be better to compare the time to the complexity of the dApp. To keep up with the schedule, we had to work evenings and weekends to get a workable product out in time.

Pushing vs. Pulling: In the cryptocurrency market, transactions can only be initiated by customers (a “push” payment) and not by merchants (a “pull” payment). Therefore, the automatic recurring payment will be difficult; we solve as follows:

  • For A2N finance to be proactive in controlling cash flow, users need to Deposit tokens into smart contracts before using them.
  • Systems like Chainlink Automation do not yet support BTTC, so we had to build an Automation System to execute scheduled transactions.
  • This system will use one of our system accounts, and we will cover transaction fees without requiring the user to initiate payment.
  • 0.2% fee on one subscription, the app will push the cost to the system account to maintain it.

Fees: in Web2, most users only pay a fee when a FIAT-related transaction occurs, but for Web3, every action written to a smart contract must pay a fee. There will be many such actions for the Recurring Payment application. To reduce complexity, we have combined the Off-chain database to execute the operations; only when necessary will the app write data to a smart contract.

Integration: for the application to be used practically with existing products, we need to integrate the cryptocurrency recurring payment into Web2 products such as e-commerce sites, event ticket sales, Etc. We have built our authentication mechanism and an API/SDK that allows it; although it is still in beta, we will complete it soon.

There are also many other technical challenges related to EVM, Solidity, system design, security, and optimization… but fortunately, we also had support from the community to solve those problems.

Accomplishments that we're proud of

  • Built a dApp that allows users to use Recurring Payment features on BitTorrent Chain (BTTC).
  • It has solved some of the challenges mentioned above, especially the Automation System that allows scheduled transactions to be executed.
  • Design a software architecture that extends to other platforms, such as Tron and BNB chain, without rebuilding.
  • It has built experimental features that allow integration with Web2 applications.
  • Know the following problems that need to be solved.

What we learned

  • We figure out how to quickly complete a large amount of work when participating in Hackathon.
  • We gain experience designing a reusable and extensible software architecture.
  • Difference between FIAT recurring payment model & Cryptocurrency recurring payment model.
  • We know about the strengths and limitations of the ecosystem around the BitTorrent Chain.

What's next for A2N Finance - Subscription & Recurring Payment on BTTC

  • Complete missing features.
  • Complete and test the SDK.
  • Support more Tokens.
  • Improved UX.
  • Optimize Smart Contract & transaction fees.
  • Conduct Security Audit for Smart Contract.
  • Issue A2N token and set up tokennomics.
  • Conduct community building and Beta tests.
  • Go to BTTC mainnet.
  • Extend SDK support for major platforms like WooCommerce, Shopify, and BigCommerce...
  • Support Tron Network and BNB chain.

Built With

Share this project:

Updates

posted an update

  • Added an attribute to specify whether a subscription product is a physical product; if correct, we will add more information about Shipping & Delivery policies.
  • Added My Addresses (address book) feature allows users to manage their Billing & Shipping addresses.
  • For physical products, when the user subscribes, there will be an additional request to select shipping & billing address to support invoicing and shipping. Soon, we will enter the Smart Contract optimization phase to fix security errors and add other essential features.

Log in or sign up for Devpost to join the conversation.

posted an update

  • To continue improving A2N SDK to integrate with Web2 platforms, we have written instructions for the Shopify platform at How to integrate with Shopify - A2N Finance.
  • These user guides are for testing purposes, and we plan to develop our plugins/apps that will allow integration with orders and invoices for WooCommerce and Shopify.
  • Those interested can see the complete source code of the project at a2nfinance · GitHub.

Log in or sign up for Devpost to join the conversation.

posted an update

We have improved A2N SDK to integrate with the Web2 platform. Currently, everyone can test the creation of recurring payments on Web2.

Log in or sign up for Devpost to join the conversation.