Dapps Contract SDK
Introduction
Dapps smart contracts provide the functionality to add new dapps to the dapps.co platform. Anyone can register their dapp and other users can subscribe to these dapps to receive notifications. While registering a new dapp, we need to provide an account that will act as the admin of the dapp and will have some extra privileges. We will discuss them later in the documentation. All the notifications will be encrypted using the user's secondary wallet (if it exists, otherwise simply encoded), created during the user onboarding process.
Quickstart -
These are the functionalities provided in the contract SDK -
Create a dapp
Register the dapp
Subscribe/Unsubscribe any user to the dapp
Get the user subscription status for a dapp
Send notifications to the subscribers
Full Overview -
Now, let's explore the dapps contract to achieve these functionalities.
First of all, let’s create a Test contract and then import SubscriptionModule.sol contract. Now, we need to declare an instance of the SubscriptionModule contract, and initialize it in the constructor with the relevant contract address for that chain.
import "./SubscriptionModule.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Test is Ownable {
SubscriptionModule public dapps;
constructor(SubscriptionModule _dapps) {
dapps = _dapps;
}
function updateSubscriptionModule(SubscriptionModule _dapps) external onlyOwner {
dapps = _dapps;
}
}So after the initial setup, developers can perform the above mentioned actions by calling the functions mentioned, in their smart contract.
Last updated