refer2earn
v1.0.6
Published
Refer2Earn Smart Contract library for Solidity
Downloads
18
Maintainers
Readme
Refer2Earn
A library for integrating Web 3 affiliate marketing features into Solidity smart contracts.
Overview
Installation
Using NPM:
$ npm install refer2earn --save
Using Yarn:
$ yarn add refer2earn
Usage
Once installed, you can integrate with Refer2Earn by importing the library and adding a couple lines of code to your contract:
pragma solidity ^0.8.9;
...
import "refer2earn/Referable.sol";
contract MyCollectible is Ownable, ReentrancyGuard, Referable {
constructor(
address r2eAddress,
) Referable(r2eAddress) {}
...
mint(uint256 _quantity, address payable _referrer) external payable nonReentrant {
...
Referable.payReferral(msg.sender, _referrer, _quantity, msg.value);
}
}
The payReferral function call should be placed at the bottom of your mint function to ensure that the payout only occurs after the mint is successful.
A non-reentrancy guard is not required on your mint function, but it is always recommended.
Your contract must inherit the OpenZeppelin Ownable module in order to work with Refer2Earn.
Publisher
This project is maintained by WenMint, the #1 generative NFT launchpad on Ethereum.