Skip to content

Commit

Permalink
three more contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
umerzaman committed Nov 18, 2021
1 parent 11318b3 commit d0e3cfd
Show file tree
Hide file tree
Showing 11 changed files with 10,449 additions and 377 deletions.
2 changes: 1 addition & 1 deletion migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Migrations = artifacts.require('Migrations');

module.exports = function deployer() {
module.exports = function deployer(deployer) {
deployer.deploy(Migrations);
};
8 changes: 8 additions & 0 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
const Tether = artifacts.require('Tether');
const RWD = artifacts.require('RWD');
const DecentralBank = artifacts.require('DecentralBank');


module.exports =async function deployer(deployer) {
//Deploye Mock Tether Contract
await deployer.deploy(Tether);
//Deploye RWD Contract
await deployer.deploy(RWD);
//Deploye Decentral Bank Contract
await deployer.deploy(DecentralBank);
};
6 changes: 6 additions & 0 deletions src/contracts/DecentralBank.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.0;

contract DecentralBank {
string public name = 'Decentral Bank';
address public owner;
}
3 changes: 1 addition & 2 deletions src/contracts/Migrations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ contract Migrations {
uint public last_completed_migration;

constructor() public{
owner = msg.sender;

owner = msg.sender;
}

modifier restricted() {
Expand Down
51 changes: 51 additions & 0 deletions src/contracts/RWD.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pragma solidity ^0.5.0;

contract RWD {
string public name = 'Reward Token';
string public symbol = 'RWD';
uint256 totalSupply = 100000000000000000000000000000; // 1 million token
uint8 public decimals = 18;


event Transfer(address indexed _from, address indexed _to,uint _value);

event Approval(address indexed _owner, address indexed _spender,uint _value);

mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;

constructor() public{
balanceOf[msg.sender] = totalSupply;
}

function transfer(address _to,uint _value) public returns (bool success){
//require that value greater or equal for transfer
require(balanceOf[msg.sender]>=_value);

//subtract balance and transfer
balanceOf[msg.sender] -= _value;
//add balance
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}

function approve (address _spender,uint256 _value) public returns (bool success){
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender,_spender,_value);
return true;
}

function TransferFrom(address _from,address _to,uint256 _value) public returns (bool success){
require(_value <=balanceOf[_from]);
require(_value <=allowance[_from][msg.sender]);

balanceOf[_to] -= _value;
//add balance
balanceOf[_from] += _value;
allowance[msg.sender][_from] -=_value;
emit Transfer(_from, _to, _value);
return true;
}

}
40 changes: 40 additions & 0 deletions src/contracts/Tether.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,45 @@ contract Tether {
uint8 public decimals = 18;


event Transfer(address indexed _from, address indexed _to,uint _value);

event Approval(address indexed _owner, address indexed _spender,uint _value);

mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;

constructor() public{
balanceOf[msg.sender] = totalSupply;
}

function transfer(address _to,uint _value) public returns (bool success){
//require that value greater or equal for transfer
require(balanceOf[msg.sender]>=_value);

//subtract balance and transfer
balanceOf[msg.sender] -= _value;
//add balance
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}

function approve (address _spender,uint256 _value) public returns (bool success){
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender,_spender,_value);
return true;
}

function TransferFrom(address _from,address _to,uint256 _value) public returns (bool success){
require(_value <=balanceOf[_from]);
require(_value <=allowance[_from][msg.sender]);

balanceOf[_to] -= _value;
//add balance
balanceOf[_from] += _value;
allowance[msg.sender][_from] -=_value;
emit Transfer(_from, _to, _value);
return true;
}

}
Loading

0 comments on commit d0e3cfd

Please sign in to comment.