Skip to main content

Using Subscriptions

A Contract (DApp) subscription is meant to waive gas fees for EOAs that send transactions to the contract account if the EOA is whitelisted to use the contract's subscription.

A DApp can choose to charge its users in a different way, using any payment method: fiat money, cards or give access to its services for free. Contract subscriptions can also be packed in bundles by resellers, offering access to a range of services using competitive pricing.

DApp subscription plans work in tiers of discounts, with gas prices being cheaper for larger amounts of units purchased.

To enable a contract to have a subscription, it must have an EOA owner that can manage the contract's subscription. The contract itself and must inherit from ISubscriptionOwner and @openzeppelin/contracts/utils/introspection/ERC165.sol and add the following imports and methods to its code:

import "./ISubscriptionOwner.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

/// ... contract code ....

function getSubscriptionOwner() external view returns (address) {
// the owner of the subscription must be an EOA
return address_of_subscription_owner;
}

function supportsInterface(bytes4 interfaceId)
public
view
override(ERC165)
returns (bool)
{
return interfaceId == type(ISubscriptionOwner).interfaceId || super.supportsInterface(interfaceId);
}

The ISubscriptionOwner interface allows Arthera to determine the owner of the subscription, which must be an EOA account. Once the contract gets a subscription, the owner will receive an ERC721 NFT that uniquely identifies the acquired subscription. The code for the ISubscriptionOwner interface is the following:

pragma solidity ^0.8.0;

interface ISubscriptionOwner {
function getSubscriptionOwner() external view returns (address);
}

Whitelisting accounts

After the contract gets a subscription, its users will still pay normal gas fees (Pay-as-You-Go mode) to work with the contract.

The subscription owner (owner of the contract) must call the addWhitlister() method to allow a third party address to whitelist an end-user.

To allow users to consume from the contract's subscription, the whitelister must whitelist the respective user accounts using the whitelistAccount() method available in the Subscribers system contract.

To disallow a whitelisted user from using the contract's subscription, the owner of the contract must use the blacklistAccount() method available in the Subscribers system contract.

Querying if an account is whitelisted/blacklisted can be done by invoking the isWhitelisted() method available in the Subscribers system contract.

Charging DApp customers

The developer of the DApp can charge its users using any payment method: fiat money, cards or give access to its services for free. Arthera provides an advanced Subscription Management Platform for free to all dApps in the ecosystem. This drastically reduces frauds and eliminates scams.

The DApp can create its own revenue stream using for example the Software-as-a-Service model, without worrying about its users having to pay for gas fees or owning cryptocurrencies. The DApp only needs to track its Arthera subscription usage and recharge it when it's low on units, or maybe go for a higher plan. This can easily be done using scheduled tasks or cloud lambda functions.