This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function burn(address account, uint256 amount) public onlyOwner returns(bool) { | |
_burn(account, amount); | |
return true; | |
} | |
/** | |
* @notice mint is used to create tokens and assign them to msg.sender | |
* | |
* See {_mint} | |
* Requires |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice _allowances is used to manage and control allownace | |
* An allowance is the right to use another accounts balance, or part of it | |
*/ | |
mapping (address => mapping (address => uint256)) private _allowances; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice Approval is emitted when a new Spender is approved to spend Tokens on | |
* the Owners account | |
*/ | |
event Approval(address indexed owner, address indexed spender, uint256 value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice getOwner just calls Ownables owner function. | |
* returns owner of the token | |
* | |
*/ | |
function getOwner() external view returns (address) { | |
return owner(); | |
} | |
/** | |
* @notice allowance is used view how much allowance an spender has |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it ("allow account some allowance", async() => { | |
devToken = await DevToken.deployed(); | |
try{ | |
// Give account(0) access too 100 tokens on creator | |
await devToken.approve('0x0000000000000000000000000000000000000000', 100); | |
}catch(error){ | |
assert.equal(error.reason, 'DevToken: approve cannot be to zero address', "Should be able to approve zero address"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
/** | |
* @notice Stakeable is a contract who is ment to be inherited by other contract that wants Staking capabilities | |
*/ | |
contract Stakeable { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./Ownable.sol"; | |
import "./Stakable.sol"; | |
/** | |
* @notice DevToken is a development token that we use to learn how to code solidity | |
* and what BEP-20 interface requires | |
*/ | |
contract DevToken is Ownable, Stakeable{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice Constructor since this contract is not ment to be used without inheritance | |
* push once to stakeholders for it to work proplerly | |
*/ | |
constructor() { | |
// This push is needed so we avoid index 0 causing bug of index-1 | |
stakeholders.push(); | |
} | |
/** | |
* @notice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice _addStakeholder takes care of adding a stakeholder to the stakeholders array | |
*/ | |
function _addStakeholder(address staker) internal returns (uint256){ | |
// Push a empty item to the Array to make space for our new stakeholder | |
stakeholders.push(); | |
// Calculate the index of the last item in the array by Len-1 | |
uint256 userIndex = stakeholders.length - 1; | |
// Assign the address to the new index | |
stakeholders[userIndex].user = staker; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice | |
* _Stake is used to make a stake for an sender. It will remove the amount staked from the stakers account and place those tokens inside a stake container | |
* StakeID | |
*/ | |
function _stake(uint256 _amount) internal{ | |
// Simple check so that user does not stake 0 | |
require(_amount > 0, "Cannot stake nothing"); | |