Crypto 1 to 100: scaling up AppCoins transactions in the blockchain

Paulo Trezentos
6 min readAug 21, 2018

--

The AppCoins protocol integration with Aptoide Dev (a version of Aptoide with a limited user base, mostly developers) was released last May. Anyone with the AppCoins wallet installed (Aptoide, Google Play) can do In-App Purchases (IAP) and User Acquisition using the blockchain.

Listening to users’ feedback and analysing datapoints, lessons were learned:

  • User Experience (UX) limitations, result of the processing time and transaction errors in the Ethereum network, create so much friction in the checkout funnels that it is barely impossible for the user to do an In-App Purchase or to be rewarded in a User Acquisition Campaign.
  • Access to crypto tokens is still difficult. Crypto holders are a minority among the main stream of apps and games users due to all the KYC & AML obstacles of creating an account with a Crypto Exchange.

On the other hand:

  • Blockchain differentiation is tremendously well perceived by app developers: receiving funds immediately (vs.30 to 60 days with Google Play), controlling the transactions in the blockchain, having only one APK to serve multiple distribution channels (e.g. site, third party app stores,..) is like music to developers’ ears.
    The decision of Epic Games to distribute directly Fortnite APK in their own website and in Samsung App Store shows how aggressive is the app stores cut of 30% and how website downloads maybe become, in the future, a viable parallel channel for apps distribution.

Maybe future improvements in blockchain platforms will overcome the UX problem, and exchanges will evolve to facilitate the access to crypto, but that could take time.

Could we devise a solution to overcome those problems and leverage Aptoide user base and Aptoide OEM partners network to be the first cryptoproject to reach 1 million unique Monthly Active Users?

AppCoins goals: Developers SDK integration Vs Wallet Monthly Active Users (MAU)

In the last months, the Aptoide and AppCoins teams worked together in a solution to enhance the AppCoins open protocol and overcome the above listed challenges.

The solution we found includes the inclusion of two new components into the payment flow: 1) a layer 2 payment channel and 2) on-the-fly express conversion for non-crypto users. This solution will be first included in the In-App Purchases flow for the September 2nd release and latter applied to the User Acquisition process.

Payment Channel

After researching different Ethereum layer 2 technologies, the team chose to fork µRaiden’s smart contracts to become the base of the payment channel.

What is a blockchain payment channel? If two parties (app store and end-user, for instance) foresee that they will do several transactions together, they can leverage the trust of the blockchain without the need of using the distributed ledger to keep track of every transaction. In a payment channel, the user “deposits” a fixed amount (e.g. 10 APPC) that will remain locked into this payment channel and every time the user wants to pay for something she can use part of that balance, sending a “proof” with the updated balance of the payment channel. Those transactions are done off-chain and don’t encounter the time and fee limitations of the Ethereum network. The “balance proof” is exchanged between both peers, providing the trust that anytime one of them want to exit the payment channel, they can do it without any economical loss.

On-the-fly express conversion

From September 2nd onwards, any user of a game that wishes to buy an in-app item, will be able to pay for that item with using a credit card. In the background, a fiat-to-crypto conversion is executed such that the developer is paid in APPC.

The above solution will increase the demand for APPC currency (and the corresponding appreciation) because each transaction requires a corresponding payment in APPC to the developer. On the other hand, the non-crypto end-user will not need to go through a KYC/AML process, as no liquidity is being generated but rather a low cost item is being purchased.

In-app purchases integrated flow

After multiple iterations and tests, the AppCoins and Aptoide teams came up with the following architecture:

Flow description:

  1. The user wants to buy an in-game item that costs 2 APPC. If she doesn’t have enough AppCoins, a checkout window is shown asking for her credit card details. If she has enough APPC, then she jumps straight to step 4 bellow.
  2. The credit card processor will execute the transaction in the equivalent fiat amount of the item that will be purchased.
  3. The credit card processor informs the app store that the transaction was successful. Under the hood, 2 APPC will be purchased by our team in a public exchange through API.
    (Note: to save on the exchange fees, we will estimate the daily amount of APPC that will be transacted and purchase the total once a day. All this information will be listed in a Transparency page on the App Store Foundation website).
  4. The app store then: i) creates a payment channel with the user, ii) tops-up her wallet with the purchased amount (i.e. 2 APPC) iii) processes the purchase by receiving a balance proof from the user granting the right to access the 2 APPC iv) sends a confirmation to the game that the item has been payed for.
    (Note: step ii) and iii) can be optimized because are in inverse directions and both performed by the store).
  5. The revenue share is split between the developer, store and OEM.
  6. Both the developer and the user, can confirm in the blockchain that the transaction occurred, i.e. in a website like APPCExplorer.io. This website will be launched soon and will show all on-chain and off-chain AppCoins transactions.

The step 6 above was the most tricky part. “You can’t have your cake and eat it”. If the transaction is not done in the blockchain (to save time and fees), how can you confirm it ?

The solution was to perform the In-App Purchase off-chain and then “notarize” it — to write a proof that it happened in the blockchain. This is done by creating a fingerprint (hash) of the transaction which is only 32 bytes. A Merkle tree of the payment channel transactions of each wallet involved is created and (only) the root hash of Merkle tree is sent to the blockchain. All the changed root hashes will be written asynchronously and in bulk as smart contract events. Relaxing the constraints size (only 32 bytes), time (seconds Vs 1 hour) and the type of record (event Vs local storage) reduces by two orders of magnitude the cost and makes it feasible to support millions of transactions.

Besides the advantages of AppCoins protocol, this architecture guarantees:

  • Fully use of the APPC cryptocurrency: the APPC balances and coins are stored in the main Ethereum network and is owned by the user.
  • Verification: users, OEMs, app stores and developers can always verify the transactions by themselves, or using a website like APPCExplorer.io

After the “Ritchie” release of the AppCoins Wallet and SDK (September 2nd), we will monitor closely the funnel metrics of the In-App Purchase funnel. From the moment the user inserts the credit card information until the item in the game is unlocked should take only 10 seconds, which is comparable to the time it takes today to process a payment in non-crypto app stores (e.g. Apple Store, Google Play).

Our goals are ambitious: in 6 months (until the end of Q1 2019), across different AppCoins adopters, to be processing 100,000 financial AppCoins transactions (IAP, User acquisiton-PoA, peer-to-peer transfers) per month. In the end of 2019, the goal is that this number of transactions will raise to 1 million per month.

This article incorporates valuable contributions from Tiago Alves, Jorge Martins, José Pereira, Diogo Pires and Pedro Almeida.

--

--