Staking1155Base
note: This contract is provided as a base contract.
Methods
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
_tokenId
uint256
Staked token Id.
contractURI
function contractURI() external view returns (string)
Returns the contract metadata URI.
Returns
_0
string
undefined
depositRewardTokens
function depositRewardTokens(uint256 _amount) external payable
Admin deposits reward tokens.
Parameters
_amount
uint256
undefined
getDefaultRewardsPerUnitTime
function getDefaultRewardsPerUnitTime() external view returns (uint256 _rewardsPerUnitTime)
Returns
_rewardsPerUnitTime
uint256
undefined
getDefaultTimeUnit
function getDefaultTimeUnit() external view returns (uint256 _timeUnit)
Returns
_timeUnit
uint256
undefined
getRewardTokenBalance
function getRewardTokenBalance() external view returns (uint256)
View total rewards available in the staking contract.
Returns
_0
uint256
undefined
getRewardsPerUnitTime
function getRewardsPerUnitTime(uint256 _tokenId) external view returns (uint256 _rewardsPerUnitTime)
Parameters
_tokenId
uint256
undefined
Returns
_rewardsPerUnitTime
uint256
undefined
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
_staker
address
Address for which to calculated rewards.
Returns
_tokensStaked
uint256[]
List of token-ids staked.
_tokenAmounts
uint256[]
Amount of each token-id staked.
_totalRewards
uint256
Total 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
_tokenId
uint256
undefined
_staker
address
Address for which to calculated rewards.
Returns
_tokensStaked
uint256
Amount of tokens staked for given token-id.
_rewards
uint256
Available reward amount.
getTimeUnit
function getTimeUnit(uint256 _tokenId) external view returns (uint256 _timeUnit)
Parameters
_tokenId
uint256
undefined
Returns
_timeUnit
uint256
undefined
indexedTokens
function indexedTokens(uint256) external view returns (uint256)
Parameters
_0
uint256
undefined
Returns
_0
uint256
undefined
isIndexed
function isIndexed(uint256) external view returns (bool)
Parameters
_0
uint256
undefined
Returns
_0
bool
undefined
multicall
function multicall(bytes[] data) external nonpayable returns (bytes[] results)
Receives and executes a batch of function calls on this contract.
Receives and executes a batch of function calls on this contract.
Parameters
data
bytes[]
The bytes data that makes up the batch of function calls to execute.
Returns
results
bytes[]
The bytes data that makes up the result of the batch of function calls executed.
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
operator
address
The address which initiated the batch transfer (i.e. msg.sender)
from
address
The address which previously owned the token
ids
uint256[]
An array containing ids of each token being transferred (order and length must match values array)
values
uint256[]
An array containing amounts of each token being transferred (order and length must match ids array)
data
bytes
Additional data with no specified format
Returns
_0
bytes4
bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
if transfer is allowed
onERC1155Received
function onERC1155Received(address, address, uint256, uint256, bytes) external view returns (bytes4)
Parameters
_0
address
undefined
_1
address
undefined
_2
uint256
undefined
_3
uint256
undefined
_4
bytes
undefined
Returns
_0
bytes4
undefined
owner
function owner() external view returns (address)
Returns the owner of the contract.
Returns
_0
address
undefined
rewardToken
function rewardToken() external view returns (address)
ERC20 Reward Token address. See {_mintRewards} below.
Returns
_0
address
undefined
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
_uri
string
keccak256 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
_defaultRewardsPerUnitTime
uint256
New 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
_defaultTimeUnit
uint256
New time unit.
setOwner
function setOwner(address _newOwner) external nonpayable
Lets an authorized wallet set a new owner for the contract.
Parameters
_newOwner
address
The address to set as the new owner of the contract.
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
_tokenId
uint256
ERC1155 token Id.
_rewardsPerUnitTime
uint256
New 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
_tokenId
uint256
ERC1155 token Id.
_timeUnit
uint256
New time unit.
stake
function stake(uint256 _tokenId, uint256 _amount) external nonpayable
Stake ERC721 Tokens.
See {_stake}. Override that to implement custom logic.
Parameters
_tokenId
uint256
ERC1155 token-id to stake.
_amount
uint256
Amount to stake.
stakers
function stakers(uint256, address) external view returns (uint256 amountStaked, uint256 timeOfLastUpdate, uint256 unclaimedRewards, uint256 conditionIdOflastUpdate)
Parameters
_0
uint256
undefined
_1
address
undefined
Returns
amountStaked
uint256
undefined
timeOfLastUpdate
uint256
undefined
unclaimedRewards
uint256
undefined
conditionIdOflastUpdate
uint256
undefined
stakersArray
function stakersArray(uint256, uint256) external view returns (address)
Parameters
_0
uint256
undefined
_1
uint256
undefined
Returns
_0
address
undefined
stakingToken
function stakingToken() external view returns (address)
Returns
_0
address
undefined
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool)
Parameters
interfaceId
bytes4
undefined
Returns
_0
bool
undefined
withdraw
function withdraw(uint256 _tokenId, uint256 _amount) external nonpayable
Withdraw staked tokens.
See {_withdraw}. Override that to implement custom logic.
Parameters
_tokenId
uint256
ERC1155 token-id to withdraw.
_amount
uint256
Amount to withdraw.
withdrawRewardTokens
function withdrawRewardTokens(uint256 _amount) external nonpayable
Admin can withdraw excess reward tokens.
Parameters
_amount
uint256
undefined
Events
ContractURIUpdated
event ContractURIUpdated(string prevURI, string newURI)
Parameters
prevURI
string
undefined
newURI
string
undefined
OwnerUpdated
event OwnerUpdated(address indexed prevOwner, address indexed newOwner)
Parameters
prevOwner indexed
address
undefined
newOwner indexed
address
undefined
RewardsClaimed
event RewardsClaimed(address indexed staker, uint256 rewardAmount)
Parameters
staker indexed
address
undefined
rewardAmount
uint256
undefined
TokensStaked
event TokensStaked(address indexed staker, uint256 indexed tokenId, uint256 amount)
Parameters
staker indexed
address
undefined
tokenId indexed
uint256
undefined
amount
uint256
undefined
TokensWithdrawn
event TokensWithdrawn(address indexed staker, uint256 indexed tokenId, uint256 amount)
Parameters
staker indexed
address
undefined
tokenId indexed
uint256
undefined
amount
uint256
undefined
UpdatedDefaultRewardsPerUnitTime
event UpdatedDefaultRewardsPerUnitTime(uint256 oldRewardsPerUnitTime, uint256 newRewardsPerUnitTime)
Parameters
oldRewardsPerUnitTime
uint256
undefined
newRewardsPerUnitTime
uint256
undefined
UpdatedDefaultTimeUnit
event UpdatedDefaultTimeUnit(uint256 oldTimeUnit, uint256 newTimeUnit)
Parameters
oldTimeUnit
uint256
undefined
newTimeUnit
uint256
undefined
UpdatedRewardsPerUnitTime
event UpdatedRewardsPerUnitTime(uint256 indexed _tokenId, uint256 oldRewardsPerUnitTime, uint256 newRewardsPerUnitTime)
Parameters
_tokenId indexed
uint256
undefined
oldRewardsPerUnitTime
uint256
undefined
newRewardsPerUnitTime
uint256
undefined
UpdatedTimeUnit
event UpdatedTimeUnit(uint256 indexed _tokenId, uint256 oldTimeUnit, uint256 newTimeUnit)
Parameters
_tokenId indexed
uint256
undefined
oldTimeUnit
uint256
undefined
newTimeUnit
uint256
undefined
Last updated