Skip to content

Instantly share code, notes, and snippets.

@MajdT51
Last active September 25, 2019 11:39
Show Gist options
  • Save MajdT51/97a982fa294329079b69db6e69cca79b to your computer and use it in GitHub Desktop.
Save MajdT51/97a982fa294329079b69db6e69cca79b to your computer and use it in GitHub Desktop.
example contract using AddrArrayLib
pragma solidity >= 0.4.25 < 0.6.0;
import '../node_modules/openzeppelin solidity/contracts/ownership/Ownable.sol';
import '../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol';
import './AddrArrayLib.sol';
contract TokenContract is Ownable {
using AddrArrayLib for AddrArrayLib.Addresses;
using SafeMath for uint256;
// List of trusted addresses which can mint tokens
AddrArrayLib.Addresses trustedMinters;
uint256 public totalSupply;
mapping (address => uint256) balances;
constructor () public {
totalSupply = 100;
balances[msg.sender] = 100;
}
function addMinter(address minter) public onlyOwner() {
trustedMinters.pushAddress(minter);
}
function removeMinter(address minter) public onlyOwner() {
trustedMinters.removeAddress(minter);
}
function mintToken(address to, uint256 amount) external {
require(trustedMinters.exists(msg.sender), 'The sender address is not registered as a Minter');
totalSupply = totalSupply.add(amount);
balances[to] = balances[to]. add(amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment