Skip to content

Instantly share code, notes, and snippets.

View percybolmer's full-sized avatar

ProgrammingPercy percybolmer

View GitHub Profile
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
/**
* @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
*
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
/**
* @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
*
*/
@percybolmer
percybolmer / gist:15fe85ecd84dec89c2ae6067f9443907
Last active May 13, 2021 20:33
Crypto-BEP20-BurnAndMintv2
/**
* @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");
// 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
*
*/
/**
* @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);
}
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();
// 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()
// 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{