Permalink
Browse files

first commit

  • Loading branch information...
iRyanBell committed Jan 2, 2019
0 parents commit 6f59a3b7d725e4a75efccd3eed8f57a3f04271cd
Showing with 113 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +61 −0 ERC_223.sol
  3. +6 −0 ERC_223_Receiver.sol
  4. +17 −0 VIM_ERC20.sol
  5. +13 −0 migrations/1_initial_migration.js
  6. +14 −0 package.json
@@ -0,0 +1,2 @@
.DS_Store
node_modules
@@ -0,0 +1,61 @@
pragma solidity ^0.5.1;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
import "./ERC_223_Receiver.sol";

contract ERC223 is ERC20, ERC20Detailed {
using SafeMath for uint256;

constructor(
string memory name,
string memory symbol,
uint8 decimals,
address owner,
uint256 totalSupply
)
ERC20()
ERC20Detailed(name, symbol, decimals)
public
{
_mint(owner, (totalSupply * 1 ether));
}

function transfer(
address to,
uint256 value
) public returns (bool) {
_transfer(msg.sender, to, value);

uint256 codeLength;
assembly {
codeLength := extcodesize(to)
}

if (codeLength > 0) {
ERC223Receiver receiver = ERC223Receiver(to);
receiver.tokenFallback(msg.sender, value);
}
return true;
}

function transfer(
address to,
uint256 value,
bytes memory data
) public returns (bool) {
_transfer(msg.sender, to, value);

uint256 codeLength;
assembly {
codeLength := extcodesize(to)
}

if (codeLength > 0) {
ERC223Receiver receiver = ERC223Receiver(to);
receiver.tokenFallback(msg.sender, value, data);
}
return true;
}
}
@@ -0,0 +1,6 @@
pragma solidity ^0.5.1;

contract ERC223Receiver {
function tokenFallback(address, uint256) public;
function tokenFallback(address, uint256, bytes memory) public;
}
@@ -0,0 +1,17 @@
pragma solidity ^0.5.1;

import "./ERC_223.sol";

contract VIM_ERC20 is ERC223 {
constructor(
string memory name,
string memory symbol,
uint8 decimals,
address owner,
uint256 totalSupply
)
ERC223(name, symbol, decimals, owner, totalSupply)
public
{
}
}
@@ -0,0 +1,13 @@
/* global artifacts */
const VimErc20Contract = artifacts.require('./VIM_ERC20.sol')

module.exports = (deployer, network, accounts) => {
deployer.deploy(
VimErc20Contract,
'Vim',
'VIM',
'18',
accounts[0],
'10000000000'
)
}
@@ -0,0 +1,14 @@
{
"name": "vim20",
"version": "1.0.0",
"scripts": {
"compile": "truffle compile",
"migrate": "truffle migrate --reset --compile-all"
},
"dependencies": {
"openzeppelin-solidity": "latest",
"solc": "next",
"truffle": "next",
"web3": "latest"
}
}

0 comments on commit 6f59a3b

Please sign in to comment.