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
const DevToken = artifacts.require("DevToken"); | |
// Start a test series named DevToken, it will use 10 test accounts | |
contract("DevToken", async accounts => { | |
// each it is a new test, and we name our first test initial supply | |
it("initial supply", async () => { | |
// wait until devtoken is deplyoed, store the results inside devToken | |
// the result is a client to the Smart contract api |
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 balanceOf will return the account balance for the given account | |
*/ | |
function balanceOf(address account) external view returns (uint256) { | |
return _balances[account]; | |
} | |
/** | |
* @notice mint will create tokens on the address inputted and then increase the total supply | |
* |
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("minting", async() => { | |
devToken = await DevToken.deployed(); | |
// Let's use account 1 since that account should have 0 | |
let intial_balance = await devToken.balanceOf(accounts[1]); | |
// Let's verify the balance | |
assert.equal(intial_balance.toNumber(), 0, "intial balance for account 1 should be 0") | |
// Let's mint 100 tokens to the user and grab the balance again |
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 transfer is used to transfer funds from the sender to the recipient | |
* This function is only callable from outside the contract. For internal usage see | |
* _transfer | |
* | |
* Requires | |
* - Caller cannot be zero | |
* - Caller must have a balance = or bigger than amount | |
* | |
*/ |
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 _mint will create tokens on the address inputted and then increase the total supply | |
* | |
* It will also emit an Transfer event, with sender set to zero address (adress(0)) | |
* | |
* Requires that the address that is recieveing the tokens is not zero address | |
*/ | |
function _mint(address account, uint256 amount) internal { | |
require(account != address(0), "DevToken: cannot mint to 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 Contract is a inheritable smart contract that will add a | |
* New modifier called onlyOwner available in the smart contract inherting it | |
* | |
* onlyOwner makes a function only callable from the Token owner | |
* | |
*/ |
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 renounceOwnership will set the owner to zero address | |
* This will make the contract owner less, It will make ALL functions with | |
* onlyOwner no longer callable. | |
* There is no way of restoring the owner | |
*/ | |
function renounceOwnership() public onlyOwner { | |
emit OwnershipTransferred(_owner, address(0)); | |
_owner = address(0); | |
} |
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
const { assert } = require("chai"); | |
const Ownable = artifacts.require("Ownable"); | |
// Start a test series named Ownable, it will use 10 test accounts | |
contract("Ownable", async accounts => { | |
it("transfer ownership", async () => { | |
ownable = await Ownable.deployed(); |
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
// Make sure the DevToken contract is included by requireing it. | |
const DevToken = artifacts.require("DevToken"); | |
const Ownable = artifacts.require('Ownable') | |
// THis is an async function, it will accept the Deployer account, the network, and eventual accounts. | |
module.exports = async function (deployer, network, accounts) { | |
// await while we deploy the DevToken | |
await deployer.deploy(DevToken, "DevToken", "DVTK", 18, "50000000000000000000000"); | |
const devToken = await DevToken.deployed() |
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; | |
import "./Ownable.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{ |