Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion build/contracts/Migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,12 @@
"version": "0.5.16+commit.9c3226ce.Emscripten.clang"
},
"networks": {
"5777": {
"events": {},
"links": {},
"address": "0xf27cb3e890F920aB5db54A6Fc39bd14663DFF5Cf",
"transactionHash": "0x5748d2eb12351865eb575b03e5c2e0a6a6509aa184c281878df75dc3de5c3e23"
},
"1617704049410": {
"events": {},
"links": {},
Expand All @@ -923,10 +929,16 @@
"links": {},
"address": "0x75d8f3196cCC798380f786073F549A35Da53E400",
"transactionHash": "0x894561c5f23679cdebc8a3a067eed5a3e15bb288d5002b80ec74feff9c711154"
},
"1618780535164": {
"events": {},
"links": {},
"address": "0x0B45A4cCC5138EDEFddcc98938D4F019BA31d34c",
"transactionHash": "0xa921c3a7658d48b489981b2d94064eed5502a8370a2b3d2de57baec78a143e08"
}
},
"schemaVersion": "3.3.4",
"updatedAt": "2021-04-06T12:02:18.519Z",
"updatedAt": "2021-05-19T00:16:34.028Z",
"networkType": "ethereum",
"devdoc": {
"methods": {}
Expand Down
14,518 changes: 9,990 additions & 4,528 deletions build/contracts/MyToken.json

Large diffs are not rendered by default.

62 changes: 58 additions & 4 deletions contracts/MyToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,70 @@
pragma solidity >=0.4.22 <0.9.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";



contract MyToken is ERC20 {
uint8 private _decimal = 5;
uint256 private allocate_token = 1000;

uint256 public allocate_token = 1000000000 * 10 ** uint(_decimal);

event CustomTransfer (
address indexed _from,
address indexed _to,
uint256 _amount
);

event CustomApproval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowances;

constructor() ERC20 ("DavidToken", "DTN") {
_mint(msg.sender, allocate_token);
}
balances[msg.sender] += allocate_token;
}


function decimals() override public view returns (uint8) {
return _decimal;
}

function totalSupply() override public view returns (uint) {
return allocate_token;
}

function returnOwnerBalance() public view returns (uint256) {
return balances[msg.sender];
}

function transfer(address _recipient, uint256 _amount) public override returns (bool success) {
require(_recipient != address(0), "Error: transfer to the zero address");
require(balances[msg.sender] >= _amount, 'Error Insufficient balance in the recepient wallet');
balances[msg.sender] -= _amount;
balances[_recipient] += _amount;
emit CustomTransfer(msg.sender, _recipient, _amount);
return true;
}
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool success) {
require(balances[_sender] >= _amount);
require(_recipient != address(0), "Error: transfer to the zero address");
require(_amount <= allowances[_sender][msg.sender]);
balances[_sender] -= _amount;
balances[_recipient] += _amount;
allowances[_sender][msg.sender] -= _amount;
emit CustomTransfer(_sender, _recipient, _amount);
return true;
}
function approve(address _spender, uint256 _amount) public override returns (bool success){
allowances[msg.sender][_spender] = _amount;
emit CustomApproval(msg.sender,_spender,_amount);
return true;
}
function balanceOf( address account) override public view returns (uint256) {
return balances[account];
}

}
3 changes: 3 additions & 0 deletions helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (count) => {
return count * 10 ** 5
}
Loading