DecentrAgora Membership docs

Documentation for DecentrAgora membership contract.

DagoraMembershipsV1

This contract manages the memberships for the Dagora platform.

This contract is upgradeable in order to add new features.

Tiers

enum Tiers {
  Ecclesia,
  Dagorian,
  Hoplite,
  Perclesian
}

Membership

struct Membership {
  uint8 tier;
  address member;
  uint256 tokenId;
  uint256 expiration;
}

baseURI

string baseURI

Base URI for the token metadata.

isPaused

bool isPaused

Boolean to check if the contract is paused.

_isInitialized

bool _isInitialized

Boolean to check if the contract has been initialized.

dagoraTreasury

address dagoraTreasury

Address of the dagora treasury.

DAI

address DAI

Address of the DAI token.

proxyImplementation

address proxyImplementation

Address of the Proxy contract.

ecclesiaPrice

uint256 ecclesiaPrice

The price of the Ecclesia membership.

ecclesiaRenewPrice

uint256 ecclesiaRenewPrice

The price of the Ecclesia membership renewal.

dagorianPrice

uint256 dagorianPrice

The price of the dAgorian membership.

dagoraRenewPrice

uint256 dagoraRenewPrice

The price of the dAgorian membership renewal.

hoplitePrice

uint256 hoplitePrice

The price of the Hoplite membership.

hopliteRenewPrice

uint256 hopliteRenewPrice

The price of the Hoplite membership renewal.

percelsiaPrice

uint256 percelsiaPrice

The price of the Perclesian membership.

percelsiaRenewPrice

uint256 percelsiaRenewPrice

The price of the Perclesian membership renewal.

GRACE_PERIOD

uint256 GRACE_PERIOD

The grace period for renewing a membership.

discount

uint256 discount

The discount for renewing a membership for 12 months.

MembershipPurchased

event MembershipPurchased(address member, uint256 tokenId, uint8 tier, uint256 expiration)

The event emitted when a membership is purchased.

Parameters

FreeMembershipClaimed

event FreeMembershipClaimed(address member, uint256 tokenId, uint8 tier, uint256 expiration)

The event emitted when a free membership is claimed.

Parameters

MembershipUpgraded

event MembershipUpgraded(address member, uint256 tokenId, uint8 oldTier, enum DagoraMembershipsV1.Tiers newTier)

The event emitted when a membership is upgraded.

Parameters

MembershipRenewed

event MembershipRenewed(address member, uint256 tokenId, uint256 expiration)

The event emitted when a membership is renewed.

Parameters

MembershipGifted

event MembershipGifted(address member, uint256 tokenId, uint8 tier, uint256 expiration)

The event emitted when a membership is claimed.

Parameters

MembershipCanceled

event MembershipCanceled(address member, uint256 tokenId, uint256 expiration)

The event emitted when a membership is canceled.

Parameters

DelegateRemoved

event DelegateRemoved(address member, uint256 tokenId, address delegatee)

The event emitted when a delegate is removed.

Parameters

DelegateAdded

event DelegateAdded(address member, uint256 tokenId, address delegatee)

The event emitted when a delegate is added.

Parameters

DelegateSwapped

event DelegateSwapped(address member, uint256 tokenId, address oldDelegatee, address newDelegatee)

The event emitted when a delegate is swapped.

Parameters

memberships

mapping(uint256 => struct DagoraMembershipsV1.Membership) memberships

mapping that stores the membership details.

experation

mapping(uint256 => uint256) experation

mapping that stores a tokenids expiration.

claimed

mapping(address => bool) claimed

mapping that sets true if a membership is claimed.

tokenDelegates

mapping(uint256 => address[]) tokenDelegates

mapping that stores the delegates of a tokenId

initialize

function initialize(string _name, string _symbol, string baseURI_, address _dagoraTreasury, address _DAI) public

The initializer function that replaces the constructor.

Parameters

isNotPaused

modifier isNotPaused()

Modifier to check if the contract is paused or, not paused.

isNotMember

modifier isNotMember()

Modifier to check if the msg.sender has already claimed their membership.

isPerclesian

modifier isPerclesian(uint256 tokenId)

Modifier to check if the tokenId tier is Perclesian.

_isValidMembership

modifier _isValidMembership(uint256 _tokenId)

Modifier to check if the membership is not expired.

durationCheck

modifier durationCheck(uint256 _dur)

Modifier to check if the duration is valid.

duration must be greater than 0 and less than 12 months.

onlyController

modifier onlyController(uint256 _tokenId)

Modifier to check if the msg.sender is the owner of the membership.

onlyDelegateeAndOwner

modifier onlyDelegateeAndOwner(uint256 _tokenId)

Modifier to check if the msg.sender is the owner or delegatee of the membership.

mintMembership

function mintMembership(uint8 _tier, uint96 _durationInMonths, uint256 _deadline, address _proxy, uint8 _v, bytes32 _r, bytes32 _s) public

Function to mint a membership.

The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.

Parameters

freeMint

function freeMint() public

Function to claim a ecclesia membership.

renewMembership

function renewMembership(uint96 _durationInMonths, uint256 _tokenId, uint256 _deadline, address _proxy, uint8 _v, bytes32 _r, bytes32 _s) external

Function to Renew a membership.

The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.

Parameters

upgradeMembership

function upgradeMembership(uint8 newTier, uint8 oldTier, uint256 tokenId, uint256 deadline, address _proxy, uint8 v, bytes32 r, bytes32 s) public

Function to upgrade a membership.

The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.

Parameters

cancelMembership

function cancelMembership(uint256 tokenId) public

Function to cancel a membership.

Parameters

addDelegate

function addDelegate(address _delegatee, uint256 _tokenId) external

Function to add a delegate to a membership.

Parameters

removeDelegate

function removeDelegate(address _delegatee, uint256 _tokenId, uint8 slot) public

Function to remove a delegate from a membership.

Parameters

swapDelegate

function swapDelegate(uint256 _tokenId, address oldDelegate, address newDelegate) public

Function to swap a delegate from a membership.

Parameters

giftMembership

function giftMembership(address to, uint8 tier, uint96 durationInMonths) external

only owner function to gift membership to an address, that address must not already have a membership.

Parameters

giftUpgrade

function giftUpgrade(uint256 tokenId, uint8 tier) external

only owner function to gift a upgrade to an existing membership.

Parameters

giftExtension

function giftExtension(uint256 tokenId, uint96 durationInMonths) external

only owner function to gift a extension to an existing membership.

Parameters

togglePaused

function togglePaused() external

Function to pause the contract.

Only owner can call this function.

setBaseURI

function setBaseURI(string baseURI_) external

Function to set the baseURI.

Only owner can call this function.

setDiscount

function setDiscount(uint256 _discount) external

Function to set the Discount price.

Only owner can call this function.

setPercelsiaPrice

function setPercelsiaPrice(uint256 _price) external

Function to set the price of a Percelsia tier membership.

Only owner can call this function.

setHoplitePrice

function setHoplitePrice(uint256 _price) external

Function to set the price of a Hoplite tier membership.

Only owner can call this function.

setDagorianPrice

function setDagorianPrice(uint256 _price) external

Function to set the price of a Dagorian tier membership.

Only owner can call this function.

setEcclesiaPrice

function setEcclesiaPrice(uint256 _price) external

Function to set the price of a Ecclesia tier membership.

Only owner can call this function.

setPercelsiaRenewPrice

function setPercelsiaRenewPrice(uint256 _price) external

Function to set the price of a Percelsia tier membership renewal.

Only owner can call this function.

setHopliteRenewPrice

function setHopliteRenewPrice(uint256 _price) external

Function to set the price of a Hoplite tier membership renewal.

Only owner can call this function.

setDagorianRenewPrice

function setDagorianRenewPrice(uint256 _price) external

Function to set the price of a Dagorian tier membership renewal.

Only owner can call this function.

setDagoraTreasury

function setDagoraTreasury(address _dagoraTreasury) external

Function to set the price of a Ecclesia tier membership renewal.

Only owner can call this function.

setProxyAddress

function setProxyAddress(address _proxyAddress) external

Function to set the address of the proxy contract.

Only owner can call this function.

Parameters

withdrawERC20

function withdrawERC20(address _token) external

Function to withdraw ERC20 tokens from the contract.

Only owner can call this function.

withdrawETH

function withdrawETH() external

Function to withdraw ETH from the contract.

Only owner can call this function.

getMembership

function getMembership(uint256 _tokenId) external view returns (struct DagoraMembershipsV1.Membership)

Function to get a tokenId membership details.

Parameters

Return Values

getMembershipTier

function getMembershipTier(uint256 _tokenId) external view returns (uint8)

Function to get a tokenId membership tier.

Parameters

Return Values

getExpiration

function getExpiration(uint256 _tokenId) external view returns (uint256)

Function to get a tokenId membership expiration.

Parameters

Return Values

isValidMembership

function isValidMembership(uint256 _tokenId) external view returns (bool)

Function to get a tokenId membership expiration.

Parameters

Return Values

addressTokenIds

function addressTokenIds(address _owner) external view returns (uint256 _tokenId)

getTokenDelegates

function getTokenDelegates(uint256 _tokenId) external view returns (address[])

Function to get a tokenIds delegates.

Parameters

Return Values

isOwnerOrDelegate

function isOwnerOrDelegate(uint256 tokenId, address addrs) public view returns (bool _isOwnerOrDelegate)

Function to check is a address is a owner or delegate of a tokenid

Parameters

Return Values

getMintPrice

function getMintPrice(uint96 _durationInMonths, uint8 _tier) public view returns (uint256 _price)

Function to get the mint price of a membership

Parameters

Return Values

_getUpgradePrice

function _getUpgradePrice(uint256 tokenId, uint8 oldTier, uint8 newTier) public view returns (uint256 _price)

Function to get the upgrade price of a membership

Parameters

Return Values

getRenewalPrice

function getRenewalPrice(uint96 _newDuration, uint8 currentTier) public view returns (uint256 _price)

Function to get the renewal price of a membership

Parameters

Return Values

tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

Returns a tokenIds URI.

Parameters

Return Values

_isDelegatee

function _isDelegatee(uint256 _tokenId, address _delegate) internal view returns (bool)

Internal function to check if an address is a delegate of a specfic tokenId.

This function is used in the isOwnerOrDelegate function.

Parameters

Return Values

_startTokenId

function _startTokenId() internal pure returns (uint256)

Internal function to set the starting tokenId.

Return Values

_getNextTokenId

function _getNextTokenId() internal view returns (uint256)

Internal function to get the next tokenId

Return Values

_beforeTokenTransfers

function _beforeTokenTransfers(address from, address to, uint256 tokenId, uint256 quantity) internal

Internal override function to enable soulbound memberships.

if sender is not address(0), then transfer is not allowed.

Parameters

_contains

function _contains(uint256 _tokenId, address user) internal view returns (bool)

Internal function to check if an address is a contained in a specfic tokenId.

This function is used in the isOwnerOrDelegate function.

Parameters

Return Values

Last updated

Logo