Fantom Alert brings push notification to Fantom blockchain which was not possible before. Developers can integrate Fantom Alert smart contract directly into their smart contract and start sending notification with the help of Fantom Alert.
Fantom Alert smart contract is deployed on Fantom Testnet as of now. You can check out the smart contract here
Fantom Alert heavily depends on the subgraph it uses under the hood. The graph helps Fantom Alert carrying out the functionality it is providing. You can checkout the subgraph that Fantom Alert uses here and you can query the subgraph using the URI given below
https://api.thegraph.com/subgraphs/name/vaibhavarora19/getter
Start integrating Fantom Alert in your smart contract using our Fantom Alert Contract interface. Remember while using Fantom Alert via smart contract the owner will be the smart contract and not your EOA(Externally Owned Account). You can make EOA as the owner using the Fantom Alert website that directly interacts with the smart contract. To visit the website click here
- Import the Fantom Alert interface
import {IChannels} from "https://github.com/VaibhavArora19/FantomAlert/blob/main/hardhat/contracts/IChannels.sol";
- Initialize the contract
IChannels public channel = IChannels(0xddDe75Cd5cBe775A82Ca76D2080a24082Ce6927f);
- You can create a channel using createChannel function
channel.createChannel{value: 0.001 ether}(string calldata name, string calldata description);
- A user can subscribe to the channel using the subscribe function
channel.susbcribe(uint id);
There are multiple functions to send notification to your subscribers depending on your use case. Only owner of the contract can call these functions.
Send notification to only one subscriber👇
channel.notificationForSingle(uint _id, address subscriber, string calldata title, string calldata description);
Send notification to multiple subscribers👇
channel.notificationForMultiple(uint _id, address[] memory subscribers, string calldata title, string calldata description);
Send notification all subscribers👇
channel.notificationForAll(uint _id, string calldata title, string calldata description);
There are some read methods as well that allows you to directly read from the blockchain state.
Get all the subscribers of a channel👇
channel.getSubscribers(uint _id);
Get all notifications of a channel👇
channel.getAllNotifications(uint _id);
Get all channels👇
channel.getAllChannels();
While getSubscribers
& getAllNotifications
can only be called by the owner of the channel. The function getAllChannels
can be called by anyone.
Fantom Alert also provides you the API that you can call to read data. To implement API in your application. Refer here
Kindly open an issue if you face any kind of bug or any other kind of problem by going here.
Kindly support me if you like the project by starring 🌟 the project. It'll be much appreciated 😄.