Skip to main content

EditionStake

Methods​

DEFAULT_ADMIN_ROLE​

function DEFAULT_ADMIN_ROLE() external view returns (bytes32)

Returns​

NameTypeDescription
_0bytes32undefined

claimRewards​

function claimRewards(uint256 _tokenId) external nonpayable

Claim accumulated rewards.

See {_claimRewards}. Override that to implement custom logic. See {_calculateRewards} for reward-calculation logic.

Parameters​

NameTypeDescription
_tokenIduint256Staked token Id.

contractType​

function contractType() external pure returns (bytes32)

Returns the module type of the contract.

Returns​

NameTypeDescription
_0bytes32undefined

contractURI​

function contractURI() external view returns (string)

Returns the contract metadata URI.

Returns​

NameTypeDescription
_0stringundefined

contractVersion​

function contractVersion() external pure returns (uint8)

Returns the version of the contract.

Returns​

NameTypeDescription
_0uint8undefined

depositRewardTokens​

function depositRewardTokens(uint256 _amount) external payable

Admin deposits reward tokens.

Parameters​

NameTypeDescription
_amountuint256undefined

getDefaultRewardsPerUnitTime​

function getDefaultRewardsPerUnitTime() external view returns (uint256 _rewardsPerUnitTime)

Returns​

NameTypeDescription
_rewardsPerUnitTimeuint256undefined

getDefaultTimeUnit​

function getDefaultTimeUnit() external view returns (uint256 _timeUnit)

Returns​

NameTypeDescription
_timeUnituint256undefined

getRewardTokenBalance​

function getRewardTokenBalance() external view returns (uint256 _rewardsAvailableInContract)

View total rewards available in the staking contract.

Returns​

NameTypeDescription
_rewardsAvailableInContractuint256undefined

getRewardsPerUnitTime​

function getRewardsPerUnitTime(uint256 _tokenId) external view returns (uint256 _rewardsPerUnitTime)

Parameters​

NameTypeDescription
_tokenIduint256undefined

Returns​

NameTypeDescription
_rewardsPerUnitTimeuint256undefined

getRoleAdmin​

function getRoleAdmin(bytes32 role) external view returns (bytes32)

Returns the admin role that controls the specified role.

See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")

Returns​

NameTypeDescription
_0bytes32undefined

getRoleMember​

function getRoleMember(bytes32 role, uint256 index) external view returns (address member)

Returns the role-member from a list of members for a role, at a given index.

Returns member who has role, at index of role-members list. See struct {RoleMembers}, and mapping {roleMembers}

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
indexuint256Index in list of current members for the role.

Returns​

NameTypeDescription
memberaddressAddress of account that has role

getRoleMemberCount​

function getRoleMemberCount(bytes32 role) external view returns (uint256 count)

Returns total number of accounts that have a role.

Returns count of accounts that have role. See struct {RoleMembers}, and mapping {roleMembers}

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")

Returns​

NameTypeDescription
countuint256Total number of accounts that have role

getStakeInfo​

function getStakeInfo(address _staker) external view returns (uint256[] _tokensStaked, uint256[] _tokenAmounts, uint256 _totalRewards)

View all tokens staked and total rewards for a user.

Parameters​

NameTypeDescription
_stakeraddressAddress for which to calculated rewards.

Returns​

NameTypeDescription
_tokensStakeduint256[]List of token-ids staked.
_tokenAmountsuint256[]Amount of each token-id staked.
_totalRewardsuint256Total rewards available.

getStakeInfoForToken​

function getStakeInfoForToken(uint256 _tokenId, address _staker) external view returns (uint256 _tokensStaked, uint256 _rewards)

View amount staked and rewards for a user, for a given token-id.

Parameters​

NameTypeDescription
_tokenIduint256undefined
_stakeraddressAddress for which to calculated rewards.

Returns​

NameTypeDescription
_tokensStakeduint256Amount of tokens staked for given token-id.
_rewardsuint256Available reward amount.

getTimeUnit​

function getTimeUnit(uint256 _tokenId) external view returns (uint256 _timeUnit)

Parameters​

NameTypeDescription
_tokenIduint256undefined

Returns​

NameTypeDescription
_timeUnituint256undefined

grantRole​

function grantRole(bytes32 role, address account) external nonpayable

Grants a role to an account, if not previously granted.

Caller must have admin role for the role. Emits {RoleGranted Event}.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
accountaddressAddress of the account to which the role is being granted.

hasRole​

function hasRole(bytes32 role, address account) external view returns (bool)

Checks whether an account has a particular role.

Returns true if account has been granted role.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
accountaddressAddress of the account for which the role is being checked.

Returns​

NameTypeDescription
_0boolundefined

hasRoleWithSwitch​

function hasRoleWithSwitch(bytes32 role, address account) external view returns (bool)

Checks whether an account has a particular role; role restrictions can be switched on and off.

Returns true if account has been granted role. Role restrictions can be switched on and off: - If address(0) has ROLE, then the ROLE restrictions don't apply. - If address(0) does not have ROLE, then the ROLE restrictions will apply.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
accountaddressAddress of the account for which the role is being checked.

Returns​

NameTypeDescription
_0boolundefined

indexedTokens​

function indexedTokens(uint256) external view returns (uint256)

Parameters​

NameTypeDescription
_0uint256undefined

Returns​

NameTypeDescription
_0uint256undefined

initialize​

function initialize(address _defaultAdmin, string _contractURI, address[] _trustedForwarders, address _rewardToken, address _stakingToken, uint256 _defaultTimeUnit, uint256 _defaultRewardsPerUnitTime) external nonpayable

Initializes the contract, like a constructor.

Parameters​

NameTypeDescription
_defaultAdminaddressundefined
_contractURIstringundefined
_trustedForwardersaddress[]undefined
_rewardTokenaddressundefined
_stakingTokenaddressundefined
_defaultTimeUnituint256undefined
_defaultRewardsPerUnitTimeuint256undefined

isIndexed​

function isIndexed(uint256) external view returns (bool)

Parameters​

NameTypeDescription
_0uint256undefined

Returns​

NameTypeDescription
_0boolundefined

isTrustedForwarder​

function isTrustedForwarder(address forwarder) external view returns (bool)

Parameters​

NameTypeDescription
forwarderaddressundefined

Returns​

NameTypeDescription
_0boolundefined

multicall​

function multicall(bytes[] data) external nonpayable returns (bytes[] results)

Receives and executes a batch of function calls on this contract.

Parameters​

NameTypeDescription
databytes[]undefined

Returns​

NameTypeDescription
resultsbytes[]undefined

onERC1155BatchReceived​

function onERC1155BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data) external nonpayable returns (bytes4)

Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a safeBatchTransferFrom after the balances have been updated. NOTE: To accept the transfer(s), this must return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) (i.e. 0xbc197c81, or its own function selector).

Parameters​

NameTypeDescription
operatoraddressThe address which initiated the batch transfer (i.e. msg.sender)
fromaddressThe address which previously owned the token
idsuint256[]An array containing ids of each token being transferred (order and length must match values array)
valuesuint256[]An array containing amounts of each token being transferred (order and length must match ids array)
databytesAdditional data with no specified format

Returns​

NameTypeDescription
_0bytes4bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed

onERC1155Received​

function onERC1155Received(address, address, uint256, uint256, bytes) external nonpayable returns (bytes4)

Parameters​

NameTypeDescription
_0addressundefined
_1addressundefined
_2uint256undefined
_3uint256undefined
_4bytesundefined

Returns​

NameTypeDescription
_0bytes4undefined

renounceRole​

function renounceRole(bytes32 role, address account) external nonpayable

Revokes role from the account.

Caller must have the role, with caller being the same as account. Emits {RoleRevoked Event}.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
accountaddressAddress of the account from which the role is being revoked.

revokeRole​

function revokeRole(bytes32 role, address account) external nonpayable

Revokes role from an account.

Caller must have admin role for the role. Emits {RoleRevoked Event}.

Parameters​

NameTypeDescription
rolebytes32keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
accountaddressAddress of the account from which the role is being revoked.

rewardToken​

function rewardToken() external view returns (address)

ERC20 Reward Token address. See {_mintRewards} below.

Returns​

NameTypeDescription
_0addressundefined

setContractURI​

function setContractURI(string _uri) external nonpayable

Lets a contract admin set the URI for contract-level metadata.

Caller should be authorized to setup contractURI, e.g. contract admin. See {_canSetContractURI}. Emits {ContractURIUpdated Event}.

Parameters​

NameTypeDescription
_uristringkeccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")

setDefaultRewardsPerUnitTime​

function setDefaultRewardsPerUnitTime(uint256 _defaultRewardsPerUnitTime) external nonpayable

Set rewards per unit of time. Interpreted as x rewards per second/per day/etc based on time-unit.

Only admin/authorized-account can call it.

Parameters​

NameTypeDescription
_defaultRewardsPerUnitTimeuint256New rewards per unit time.

setDefaultTimeUnit​

function setDefaultTimeUnit(uint256 _defaultTimeUnit) external nonpayable

Set time unit. Set as a number of seconds. Could be specified as -- x 1 hours, x 1 days, etc.

Only admin/authorized-account can call it.

Parameters​

NameTypeDescription
_defaultTimeUnituint256New time unit.

setRewardsPerUnitTime​

function setRewardsPerUnitTime(uint256 _tokenId, uint256 _rewardsPerUnitTime) external nonpayable

Set rewards per unit of time. Interpreted as x rewards per second/per day/etc based on time-unit.

Only admin/authorized-account can call it.

Parameters​

NameTypeDescription
_tokenIduint256ERC1155 token Id.
_rewardsPerUnitTimeuint256New rewards per unit time.

setTimeUnit​

function setTimeUnit(uint256 _tokenId, uint256 _timeUnit) external nonpayable

Set time unit. Set as a number of seconds. Could be specified as -- x 1 hours, x 1 days, etc.

Only admin/authorized-account can call it.

Parameters​

NameTypeDescription
_tokenIduint256ERC1155 token Id.
_timeUnituint256New time unit.

stake​

function stake(uint256 _tokenId, uint256 _amount) external nonpayable

Stake ERC721 Tokens.

See {_stake}. Override that to implement custom logic.

Parameters​

NameTypeDescription
_tokenIduint256ERC1155 token-id to stake.
_amountuint256Amount to stake.

stakers​

function stakers(uint256, address) external view returns (uint256 amountStaked, uint256 timeOfLastUpdate, uint256 unclaimedRewards, uint256 conditionIdOflastUpdate)

Parameters​

NameTypeDescription
_0uint256undefined
_1addressundefined

Returns​

NameTypeDescription
amountStakeduint256undefined
timeOfLastUpdateuint256undefined
unclaimedRewardsuint256undefined
conditionIdOflastUpdateuint256undefined

stakersArray​

function stakersArray(uint256, uint256) external view returns (address)

Parameters​

NameTypeDescription
_0uint256undefined
_1uint256undefined

Returns​

NameTypeDescription
_0addressundefined

stakingToken​

function stakingToken() external view returns (address)

Returns​

NameTypeDescription
_0addressundefined

supportsInterface​

function supportsInterface(bytes4 interfaceId) external view returns (bool)

Parameters​

NameTypeDescription
interfaceIdbytes4undefined

Returns​

NameTypeDescription
_0boolundefined

withdraw​

function withdraw(uint256 _tokenId, uint256 _amount) external nonpayable

Withdraw staked tokens.

See {_withdraw}. Override that to implement custom logic.

Parameters​

NameTypeDescription
_tokenIduint256ERC1155 token-id to withdraw.
_amountuint256Amount to withdraw.

withdrawRewardTokens​

function withdrawRewardTokens(uint256 _amount) external nonpayable

Admin can withdraw excess reward tokens.

Parameters​

NameTypeDescription
_amountuint256undefined

Events​

ContractURIUpdated​

event ContractURIUpdated(string prevURI, string newURI)

Parameters​

NameTypeDescription
prevURIstringundefined
newURIstringundefined

Initialized​

event Initialized(uint8 version)

Parameters​

NameTypeDescription
versionuint8undefined

RewardTokensDepositedByAdmin​

event RewardTokensDepositedByAdmin(uint256 _amount)

Parameters​

NameTypeDescription
_amountuint256undefined

RewardTokensWithdrawnByAdmin​

event RewardTokensWithdrawnByAdmin(uint256 _amount)

Parameters​

NameTypeDescription
_amountuint256undefined

RewardsClaimed​

event RewardsClaimed(address indexed staker, uint256 rewardAmount)

Parameters​

NameTypeDescription
staker indexedaddressundefined
rewardAmountuint256undefined

RoleAdminChanged​

event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole)

Parameters​

NameTypeDescription
role indexedbytes32undefined
previousAdminRole indexedbytes32undefined
newAdminRole indexedbytes32undefined

RoleGranted​

event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender)

Parameters​

NameTypeDescription
role indexedbytes32undefined
account indexedaddressundefined
sender indexedaddressundefined

RoleRevoked​

event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender)

Parameters​

NameTypeDescription
role indexedbytes32undefined
account indexedaddressundefined
sender indexedaddressundefined

TokensStaked​

event TokensStaked(address indexed staker, uint256 indexed tokenId, uint256 amount)

Parameters​

NameTypeDescription
staker indexedaddressundefined
tokenId indexeduint256undefined
amountuint256undefined

TokensWithdrawn​

event TokensWithdrawn(address indexed staker, uint256 indexed tokenId, uint256 amount)

Parameters​

NameTypeDescription
staker indexedaddressundefined
tokenId indexeduint256undefined
amountuint256undefined

UpdatedDefaultRewardsPerUnitTime​

event UpdatedDefaultRewardsPerUnitTime(uint256 oldRewardsPerUnitTime, uint256 newRewardsPerUnitTime)

Parameters​

NameTypeDescription
oldRewardsPerUnitTimeuint256undefined
newRewardsPerUnitTimeuint256undefined

UpdatedDefaultTimeUnit​

event UpdatedDefaultTimeUnit(uint256 oldTimeUnit, uint256 newTimeUnit)

Parameters​

NameTypeDescription
oldTimeUnituint256undefined
newTimeUnituint256undefined

UpdatedRewardsPerUnitTime​

event UpdatedRewardsPerUnitTime(uint256 indexed _tokenId, uint256 oldRewardsPerUnitTime, uint256 newRewardsPerUnitTime)

Parameters​

NameTypeDescription
_tokenId indexeduint256undefined
oldRewardsPerUnitTimeuint256undefined
newRewardsPerUnitTimeuint256undefined

UpdatedTimeUnit​

event UpdatedTimeUnit(uint256 indexed _tokenId, uint256 oldTimeUnit, uint256 newTimeUnit)

Parameters​

NameTypeDescription
_tokenId indexeduint256undefined
oldTimeUnituint256undefined
newTimeUnituint256undefined