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
Membership
baseURI
Base URI for the token metadata.
isPaused
Boolean to check if the contract is paused.
_isInitialized
Boolean to check if the contract has been initialized.
dagoraTreasury
Address of the dagora treasury.
DAI
Address of the DAI token.
proxyImplementation
Address of the Proxy contract.
ecclesiaPrice
The price of the Ecclesia membership.
ecclesiaRenewPrice
The price of the Ecclesia membership renewal.
dagorianPrice
The price of the dAgorian membership.
dagoraRenewPrice
The price of the dAgorian membership renewal.
hoplitePrice
The price of the Hoplite membership.
hopliteRenewPrice
The price of the Hoplite membership renewal.
percelsiaPrice
The price of the Perclesian membership.
percelsiaRenewPrice
The price of the Perclesian membership renewal.
GRACE_PERIOD
The grace period for renewing a membership.
discount
The discount for renewing a membership for 12 months.
MembershipPurchased
The event emitted when a membership is purchased.
Parameters
Name | Type | Description |
---|---|---|
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
The event emitted when a free membership is claimed.
Parameters
Name | Type | Description |
---|---|---|
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
The event emitted when a membership is upgraded.
Parameters
Name | Type | Description |
---|---|---|
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
The event emitted when a membership is renewed.
Parameters
Name | Type | Description |
---|---|---|
member | address | the address of the member |
tokenId | uint256 | the tokenId of the membership |
expiration | uint256 | the expiration of the membership |
MembershipGifted
The event emitted when a membership is claimed.
Parameters
Name | Type | Description |
---|---|---|
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
The event emitted when a membership is canceled.
Parameters
Name | Type | Description |
---|---|---|
member | address | the address of the member |
tokenId | uint256 | the tokenId of the membership |
expiration | uint256 | the expiration of the membership |
DelegateRemoved
The event emitted when a delegate is removed.
Parameters
Name | Type | Description |
---|---|---|
member | address | the address of the member |
tokenId | uint256 | the tokenId of the membership |
delegatee | address | the address of the delegatee |
DelegateAdded
The event emitted when a delegate is added.
Parameters
Name | Type | Description |
---|---|---|
member | address | the address of the member |
tokenId | uint256 | the tokenId of the membership |
delegatee | address | the address of the delegatee |
DelegateSwapped
The event emitted when a delegate is swapped.
Parameters
Name | Type | Description |
---|---|---|
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 that stores the membership details.
experation
mapping that stores a tokenids expiration.
claimed
mapping that sets true if a membership is claimed.
tokenDelegates
mapping that stores the delegates of a tokenId
initialize
The initializer function that replaces the constructor.
Parameters
Name | Type | Description |
---|---|---|
_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 to check if the contract is paused or, not paused.
isNotMember
Modifier to check if the msg.sender has already claimed their membership.
isPerclesian
Modifier to check if the tokenId tier is Perclesian.
_isValidMembership
Modifier to check if the membership is not expired.
durationCheck
Modifier to check if the duration is valid.
duration must be greater than 0 and less than 12 months.
onlyController
Modifier to check if the msg.sender is the owner of the membership.
onlyDelegateeAndOwner
Modifier to check if the msg.sender is the owner or delegatee of the membership.
mintMembership
Function to mint a membership.
The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.
Parameters
Name | Type | Description |
---|---|---|
_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 to claim a ecclesia membership.
renewMembership
Function to Renew a membership.
The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.
Parameters
Name | Type | Description |
---|---|---|
_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 to upgrade a membership.
The permit signature is used to transfer the DAI from the msg.sender to the dAgoraTreasury.
Parameters
Name | Type | Description |
---|---|---|
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 to cancel a membership.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The tokenId of the membership. |
addDelegate
Function to add a delegate to a membership.
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | The address of the delegatee. |
_tokenId | uint256 | The tokenId of the membership. |
removeDelegate
Function to remove a delegate from a membership.
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | The address of the delegatee. |
_tokenId | uint256 | The tokenId of the membership. |
slot | uint8 | The slot of the delegatee. |
swapDelegate
Function to swap a delegate from a membership.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
oldDelegate | address | The address of the old delegate. |
newDelegate | address | The address of the new delegate. |
giftMembership
only owner function to gift membership to an address, that address must not already have a membership.
Parameters
Name | Type | Description |
---|---|---|
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
only owner function to gift a upgrade to an existing membership.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The tokenId of the membership. |
tier | uint8 | The tier of the membership. |
giftExtension
only owner function to gift a extension to an existing membership.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The tokenId of the membership. |
durationInMonths | uint96 | The duration of the membership in months. |
togglePaused
Function to pause the contract.
Only owner can call this function.
setBaseURI
Function to set the baseURI.
Only owner can call this function.
setDiscount
Function to set the Discount price.
Only owner can call this function.
setPercelsiaPrice
Function to set the price of a Percelsia tier membership.
Only owner can call this function.
setHoplitePrice
Function to set the price of a Hoplite tier membership.
Only owner can call this function.
setDagorianPrice
Function to set the price of a Dagorian tier membership.
Only owner can call this function.
setEcclesiaPrice
Function to set the price of a Ecclesia tier membership.
Only owner can call this function.
setPercelsiaRenewPrice
Function to set the price of a Percelsia tier membership renewal.
Only owner can call this function.
setHopliteRenewPrice
Function to set the price of a Hoplite tier membership renewal.
Only owner can call this function.
setDagorianRenewPrice
Function to set the price of a Dagorian tier membership renewal.
Only owner can call this function.
setDagoraTreasury
Function to set the price of a Ecclesia tier membership renewal.
Only owner can call this function.
setProxyAddress
Function to set the address of the proxy contract.
Only owner can call this function.
Parameters
Name | Type | Description |
---|---|---|
_proxyAddress | address | The address of the proxy contract. |
withdrawERC20
Function to withdraw ERC20 tokens from the contract.
Only owner can call this function.
withdrawETH
Function to withdraw ETH from the contract.
Only owner can call this function.
getMembership
Function to get a tokenId membership details.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct DagoraMembershipsV1.Membership | Membership struct. |
getMembershipTier
Function to get a tokenId membership tier.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint8 | uint8 tier. |
getExpiration
Function to get a tokenId membership expiration.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 expiration. |
isValidMembership
Function to get a tokenId membership expiration.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool isValid. |
addressTokenIds
getTokenDelegates
Function to get a tokenIds delegates.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | address[] | address[] delegates. |
isOwnerOrDelegate
Function to check is a address is a owner or delegate of a tokenid
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The tokenId of the membership. |
addrs | address | The address to check. |
Return Values
Name | Type | Description |
---|---|---|
_isOwnerOrDelegate | bool | bool. |
getMintPrice
Function to get the mint price of a membership
Parameters
Name | Type | Description |
---|---|---|
_durationInMonths | uint96 | The duration of the membership in months. |
_tier | uint8 | The tier of the membership. |
Return Values
Name | Type | Description |
---|---|---|
_price | uint256 | The price of the membership. |
_getUpgradePrice
Function to get the upgrade price of a membership
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_price | uint256 | The price of the membership. |
getRenewalPrice
Function to get the renewal price of a membership
Parameters
Name | Type | Description |
---|---|---|
_newDuration | uint96 | The new duration of the membership. |
currentTier | uint8 | The current tier of the membership. |
Return Values
Name | Type | Description |
---|---|---|
_price | uint256 | The price of the membership. |
tokenURI
Returns a tokenIds URI.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The tokenId of the membership. |
Return Values
Name | Type | Description |
---|---|---|
[0] | string | The URI of the token. |
_isDelegatee
Internal function to check if an address is a delegate of a specfic tokenId.
This function is used in the isOwnerOrDelegate function.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
_delegate | address | The address to check. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the address is a delegate of the tokenId. False if not. |
_startTokenId
Internal function to set the starting tokenId.
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The starting tokenId. |
_getNextTokenId
Internal function to get the next tokenId
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The next tokenId. |
_beforeTokenTransfers
Internal override function to enable soulbound memberships.
if sender is not address(0), then transfer is not allowed.
Parameters
Name | Type | Description |
---|---|---|
from | address | the address of the sender. |
to | address | the address of the receiver. |
tokenId | uint256 | the tokenId. |
quantity | uint256 | the quantity. |
_contains
Internal function to check if an address is a contained in a specfic tokenId.
This function is used in the isOwnerOrDelegate function.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The tokenId of the membership. |
user | address | The address to check. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the address is a delegate of the tokenId. False if not. |
Last updated