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

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

tier

uint8

the tier of the membership

expiration

uint256

the expiration of the membership

FreeMembershipClaimed

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

The event emitted when a free membership is claimed.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

tier

uint8

the tier of the membership

expiration

uint256

the expiration of the membership

MembershipUpgraded

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

The event emitted when a membership is upgraded.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

oldTier

uint8

the old tier of the membership

newTier

enum DagoraMembershipsV1.Tiers

the new tier of the membership

MembershipRenewed

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

The event emitted when a membership is renewed.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

expiration

uint256

the expiration of the membership

MembershipGifted

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

The event emitted when a membership is claimed.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

tier

uint8

the tier of the membership

expiration

uint256

the expiration of the membership

MembershipCanceled

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

The event emitted when a membership is canceled.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

expiration

uint256

the expiration of the membership

DelegateRemoved

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

The event emitted when a delegate is removed.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

delegatee

address

the address of the delegatee

DelegateAdded

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

The event emitted when a delegate is added.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

delegatee

address

the address of the delegatee

DelegateSwapped

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

The event emitted when a delegate is swapped.

Parameters

NameTypeDescription

member

address

the address of the member

tokenId

uint256

the tokenId of the membership

oldDelegatee

address

the address of the old delegatee

newDelegatee

address

the address of the new delegatee

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

NameTypeDescription

_name

string

the name of the token

_symbol

string

the symbol of the token

baseURI_

string

the base URI for the token metadata

_dagoraTreasury

address

the address of the dagora treasury

_DAI

address

the address of the DAI token.

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

NameTypeDescription

_tier

uint8

The tier of the membership. (Perclesian, Hoplite, dAgorian, Ecclesia)

_durationInMonths

uint96

The duration of the membership in months. (1-12)

_deadline

uint256

The deadline for the permit signature.

_proxy

address

The address of the proxy contract.

_v

uint8

The v value of the permit signature.

_r

bytes32

The r value of the permit signature.

_s

bytes32

The s value of the permit signature.

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

NameTypeDescription

_durationInMonths

uint96

The duration of the membership in months. (1-12)

_tokenId

uint256

The tokenId of the membership.

_deadline

uint256

The deadline for the permit signature.

_proxy

address

The address of the proxy contract.

_v

uint8

The v value of the permit signature.

_r

bytes32

The r value of the permit signature.

_s

bytes32

The s value of the permit signature.

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

NameTypeDescription

newTier

uint8

The new tier of the membership.

oldTier

uint8

The old tier of the membership.

tokenId

uint256

The tokenId of the membership.

deadline

uint256

The deadline for the permit signature.

_proxy

address

The address of the proxy contract.

v

uint8

The v value of the permit signature.

r

bytes32

The r value of the permit signature.

s

bytes32

The s value of the permit signature.

cancelMembership

function cancelMembership(uint256 tokenId) public

Function to cancel a membership.

Parameters

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

addDelegate

function addDelegate(address _delegatee, uint256 _tokenId) external

Function to add a delegate to a membership.

Parameters

NameTypeDescription

_delegatee

address

The address of the delegatee.

_tokenId

uint256

The tokenId of the membership.

removeDelegate

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

Function to remove a delegate from a membership.

Parameters

NameTypeDescription

_delegatee

address

The address of the delegatee.

_tokenId

uint256

The tokenId of the membership.

slot

uint8

The slot of the delegatee.

swapDelegate

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

Function to swap a delegate from a membership.

Parameters

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

oldDelegate

address

The address of the old delegate.

newDelegate

address

The address of the new delegate.

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

NameTypeDescription

to

address

The address to gift membership to.

tier

uint8

The tier of the membership.

durationInMonths

uint96

The duration of the membership in months.

giftUpgrade

function giftUpgrade(uint256 tokenId, uint8 tier) external

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

Parameters

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

tier

uint8

The tier of the membership.

giftExtension

function giftExtension(uint256 tokenId, uint96 durationInMonths) external

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

Parameters

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

durationInMonths

uint96

The duration of the membership in months.

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

NameTypeDescription

_proxyAddress

address

The address of the proxy contract.

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

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

struct DagoraMembershipsV1.Membership

Membership struct.

getMembershipTier

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

Function to get a tokenId membership tier.

Parameters

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

uint8

uint8 tier.

getExpiration

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

Function to get a tokenId membership expiration.

Parameters

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

uint256

uint256 expiration.

isValidMembership

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

Function to get a tokenId membership expiration.

Parameters

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

bool

bool isValid.

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

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

address[]

address[] delegates.

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

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

addrs

address

The address to check.

Return Values

NameTypeDescription

_isOwnerOrDelegate

bool

bool.

getMintPrice

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

Function to get the mint price of a membership

Parameters

NameTypeDescription

_durationInMonths

uint96

The duration of the membership in months.

_tier

uint8

The tier of the membership.

Return Values

NameTypeDescription

_price

uint256

The price of the membership.

_getUpgradePrice

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

Function to get the upgrade price of a membership

Parameters

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

oldTier

uint8

The old tier of the membership.

newTier

uint8

The new tier of the membership.

Return Values

NameTypeDescription

_price

uint256

The price of the membership.

getRenewalPrice

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

Function to get the renewal price of a membership

Parameters

NameTypeDescription

_newDuration

uint96

The new duration of the membership.

currentTier

uint8

The current tier of the membership.

Return Values

NameTypeDescription

_price

uint256

The price of the membership.

tokenURI

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

Returns a tokenIds URI.

Parameters

NameTypeDescription

tokenId

uint256

The tokenId of the membership.

Return Values

NameTypeDescription

[0]

string

The URI of the token.

_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

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

_delegate

address

The address to check.

Return Values

NameTypeDescription

[0]

bool

True if the address is a delegate of the tokenId. False if not.

_startTokenId

function _startTokenId() internal pure returns (uint256)

Internal function to set the starting tokenId.

Return Values

NameTypeDescription

[0]

uint256

The starting tokenId.

_getNextTokenId

function _getNextTokenId() internal view returns (uint256)

Internal function to get the next tokenId

Return Values

NameTypeDescription

[0]

uint256

The next tokenId.

_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

NameTypeDescription

from

address

the address of the sender.

to

address

the address of the receiver.

tokenId

uint256

the tokenId.

quantity

uint256

the quantity.

_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

NameTypeDescription

_tokenId

uint256

The tokenId of the membership.

user

address

The address to check.

Return Values

NameTypeDescription

[0]

bool

True if the address is a delegate of the tokenId. False if not.

Last updated

Logo