Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept transfers #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

accept transfers #38

wants to merge 3 commits into from

Conversation

brostiko
Copy link

608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50604051610a0f380380610a0f8339818101604052602081101561004d57600080fd5b50516d30cf8e866d7078300fe38000000060008181556001600160a01b03831680825260016020908152604080842085905580519485525191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35061094d806100c26000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100c35760003560e01c8063395093511161008b57806339509351146101f357806370a082311461021f57806395d89b4114610245578063a457c2d71461024d578063a9059cbb14610279578063dd62ed3e146102a5576100c3565b806306fdde03146100c8578063095ea7b31461014557806318160ddd1461018557806323b872dd1461019f578063313ce567146101d5575b600080fd5b6100d06102d3565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010a5781810151838201526020016100f2565b50505050905090810190601f1680156101375780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101716004803603604081101561015b57600080fd5b506001600160a01b0381351690602001356102f9565b604080519115158252519081900360200190f35b61018d61035f565b60408051918252519081900360200190f35b610171600480360360608110156101b557600080fd5b506001600160a01b03813581169160208101359091169060400135610365565b6101dd610624565b6040805160ff9092168252519081900360200190f35b6101716004803603604081101561020957600080fd5b506001600160a01b038135169060200135610629565b61018d6004803603602081101561023557600080fd5b50356001600160a01b031661070c565b6100d0610727565b6101716004803603604081101561026357600080fd5b506001600160a01b038135169060200135610746565b6101716004803603604081101561028f57600080fd5b506001600160a01b0381351690602001356107c4565b61018d600480360360408110156102bb57600080fd5b506001600160a01b03813581169160200135166107d8565b6040518060400160405280600a815260200169109a5d151bdc9c995b9d60b21b81525081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005490565b6001600160a01b0383166000908152600160205260408120548211156103cb576040805162461bcd60e51b81526020600482015260166024820152750e6e4c640c4c2d8c2dcc6ca40dcdee840cadcdeeaced60531b604482015290519081900360640190fd5b6001600160a01b038416331480159061040957506001600160a01b038416600090815260026020908152604080832033845290915290205460001914155b15610514576001600160a01b0384166000908152600260209081526040808320338452909152902054821115610486576040805162461bcd60e51b815260206004820152601b60248201527f73726320616c6c6f77616e6365206973206e6f7420656e6f7567680000000000604482015290519081900360640190fd5b604080518082018252601e81527f616c6c6f77616e6365207375627472616374696f6e206f766572666c6f7700006020808301919091526001600160a01b03871660009081526002825283812033825290915291909120546104ef91849063ffffffff61080316565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610557826040518060600160405280602181526020016108f9602191396001600160a01b038716600090815260016020526040902054919063ffffffff61080316565b6001600160a01b0380861660009081526001602081815260408084209590955584518086018652601c81527f746f2062616c616e6365206164646974696f6e206f766572666c6f77000000008183015293881683525291909120546105c391849063ffffffff61089a16565b6001600160a01b0380851660008181526001602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b601281565b60006001600160a01b03831661063e57600080fd5b604080518082018252601b81527f616c6c6f77616e6365206164646974696f6e206f766572666c6f770000000000602080830191909152336000908152600282528381206001600160a01b038816825290915291909120546106a791849063ffffffff61089a16565b3360008181526002602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6001600160a01b031660009081526001602052604090205490565b6040518060400160405280600381526020016210951560ea1b81525081565b60006001600160a01b03831661075b57600080fd5b604080518082018252601e81527f616c6c6f77616e6365207375627472616374696f6e206f766572666c6f770000602080830191909152336000908152600282528381206001600160a01b038816825290915291909120546106a791849063ffffffff61080316565b60006107d1338484610365565b9392505050565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b600081848411156108925760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561085757818101518382015260200161083f565b50505050905090810190601f1680156108845780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600083830182858210156108ef5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561085757818101518382015260200161083f565b5094935050505056fe66726f6d2062616c616e6365207375627472616374696f6e206f766572666c6f77a26474726f6e58200b19d6f1b623efc370df5874c29ce6ab9005aebcb067acd94be71eaec1df3f9364736f6c63430005120031000000000000000000000000cf649401692e5eea5fd28000f452e7f35acc720b

Signed-off-by: brostiko <[email protected]>
pragma solidity ^0.5.8;

interface ITRC20 {
    function transfer(address to, uint256 value) external returns (bool);
    function approve(address spender, uint256 value) external returns (bool);
    function transferFrom(address from, address to, uint256 value) external returns (bool);
    function totalSupply() external view returns (uint256);
    function balanceOf(address who) external view returns (uint256);
    function allowance(address owner, address spender) external view returns (uint256);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

library SafeMath {

    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

}

contract BTT is ITRC20 {
    using SafeMath for uint256;
    string constant public name = "BitTorrent";
    string constant public symbol = "BTT";
    uint8 constant  public decimals = 18;

    uint256 private totalSupply_;
    mapping(address => uint256) private  balanceOf_;
    mapping(address => mapping(address => uint256)) private  allowance_;

    constructor(address fund) public {
        totalSupply_ = 9900 * 1e8 * 1e18 * 1e3;
        balanceOf_[fund] = totalSupply_;
        emit Transfer(address(0x00), fund, totalSupply_);
    }

    function totalSupply() public view returns (uint256) {
        return totalSupply_;
    }

    function balanceOf(address guy) public view returns (uint256){
        return balanceOf_[guy];
    }

    function allowance(address src, address guy) public view returns (uint256){
        return allowance_[src][guy];
    }

    function approve(address guy, uint256 sad) public returns (bool) {
        allowance_[msg.sender][guy] = sad;
        emit Approval(msg.sender, guy, sad);
        return true;
    }

    function transfer(address dst, uint256 sad) public returns (bool) {
        return transferFrom(msg.sender, dst, sad);
    }

    function transferFrom(address src, address dst, uint256 sad)
    public returns (bool)
    {
        require(balanceOf_[src] >= sad, "src balance not enough");

        if (src != msg.sender && allowance_[src][msg.sender] != uint256(-1)) {
            require(allowance_[src][msg.sender] >= sad, "src allowance is not enough");
            allowance_[src][msg.sender] = allowance_[src][msg.sender].sub(sad, "allowance subtraction overflow") ;
        }
        balanceOf_[src] = balanceOf_[src].sub(sad, "from balance subtraction overflow");
        balanceOf_[dst] = balanceOf_[dst].add(sad, "to balance addition overflow") ;

        emit Transfer(src, dst, sad);
        return true;
    }

    function increaseAllowance(address guy, uint256 addedValue) public returns (bool) {
        require(guy != address(0));

        allowance_[msg.sender][guy] = allowance_[msg.sender][guy].add(addedValue, "allowance addition overflow") ;
        emit Approval(msg.sender, guy, allowance_[msg.sender][guy]);
        return true;
    }

    function decreaseAllowance(address guy, uint256 subtractedValue) public returns (bool) {
        require(guy != address(0));

        allowance_[msg.sender][guy] = allowance_[msg.sender][guy].sub(subtractedValue, "allowance subtraction overflow") ;
        emit Approval(msg.sender, guy, allowance_[msg.sender][guy]);
        return true;
    }
}
Copy link
Author

@brostiko brostiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[{"inputs":[{"internalType":"address","name":"fund","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"guy","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"},{"internalType":"uint256","name":"sad","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"sad","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"sad","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]

@brostiko
Copy link
Author

pragma solidity ^0.5.8;

interface ITRC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}

library SafeMath {

function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, errorMessage);

    return c;
}

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b <= a, errorMessage);
    uint256 c = a - b;

    return c;
}

}

contract BTT is ITRC20 {
using SafeMath for uint256;
string constant public name = "BitTorrent";
string constant public symbol = "BTT";
uint8 constant public decimals = 18;

uint256 private totalSupply_;
mapping(address => uint256) private  balanceOf_;
mapping(address => mapping(address => uint256)) private  allowance_;

constructor(address fund) public {
    totalSupply_ = 9900 * 1e8 * 1e18 * 1e3;
    balanceOf_[fund] = totalSupply_;
    emit Transfer(address(0x00), fund, totalSupply_);
}

function totalSupply() public view returns (uint256) {
    return totalSupply_;
}

function balanceOf(address guy) public view returns (uint256){
    return balanceOf_[guy];
}

function allowance(address src, address guy) public view returns (uint256){
    return allowance_[src][guy];
}

function approve(address guy, uint256 sad) public returns (bool) {
    allowance_[msg.sender][guy] = sad;
    emit Approval(msg.sender, guy, sad);
    return true;
}

function transfer(address dst, uint256 sad) public returns (bool) {
    return transferFrom(msg.sender, dst, sad);
}

function transferFrom(address src, address dst, uint256 sad)
public returns (bool)
{
    require(balanceOf_[src] >= sad, "src balance not enough");

    if (src != msg.sender && allowance_[src][msg.sender] != uint256(-1)) {
        require(allowance_[src][msg.sender] >= sad, "src allowance is not enough");
        allowance_[src][msg.sender] = allowance_[src][msg.sender].sub(sad, "allowance subtraction overflow") ;
    }
    balanceOf_[src] = balanceOf_[src].sub(sad, "from balance subtraction overflow");
    balanceOf_[dst] = balanceOf_[dst].add(sad, "to balance addition overflow") ;

    emit Transfer(src, dst, sad);
    return true;
}

function increaseAllowance(address guy, uint256 addedValue) public returns (bool) {
    require(guy != address(0));

    allowance_[msg.sender][guy] = allowance_[msg.sender][guy].add(addedValue, "allowance addition overflow") ;
    emit Approval(msg.sender, guy, allowance_[msg.sender][guy]);
    return true;
}

function decreaseAllowance(address guy, uint256 subtractedValue) public returns (bool) {
    require(guy != address(0));

    allowance_[msg.sender][guy] = allowance_[msg.sender][guy].sub(subtractedValue, "allowance subtraction overflow") ;
    emit Approval(msg.sender, guy, allowance_[msg.sender][guy]);
    return true;
}

}

608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50604051610a0f380380610a0f8339818101604052602081101561004d57600080fd5b50516d30cf8e866d7078300fe38000000060008181556001600160a01b03831680825260016020908152604080842085905580519485525191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35061094d806100c26000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100c35760003560e01c8063395093511161008b57806339509351146101f357806370a082311461021f57806395d89b4114610245578063a457c2d71461024d578063a9059cbb14610279578063dd62ed3e146102a5576100c3565b806306fdde03146100c8578063095ea7b31461014557806318160ddd1461018557806323b872dd1461019f578063313ce567146101d5575b600080fd5b6100d06102d3565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561010a5781810151838201526020016100f2565b50505050905090810190601f1680156101375780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101716004803603604081101561015b57600080fd5b506001600160a01b0381351690602001356102f9565b604080519115158252519081900360200190f35b61018d61035f565b60408051918252519081900360200190f35b610171600480360360608110156101b557600080fd5b506001600160a01b03813581169160208101359091169060400135610365565b6101dd610624565b6040805160ff9092168252519081900360200190f35b6101716004803603604081101561020957600080fd5b506001600160a01b038135169060200135610629565b61018d6004803603602081101561023557600080fd5b50356001600160a01b031661070c565b6100d0610727565b6101716004803603604081101561026357600080fd5b506001600160a01b038135169060200135610746565b6101716004803603604081101561028f57600080fd5b506001600160a01b0381351690602001356107c4565b61018d600480360360408110156102bb57600080fd5b506001600160a01b03813581169160200135166107d8565b6040518060400160405280600a815260200169109a5d151bdc9c995b9d60b21b81525081565b3360008181526002602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005490565b6001600160a01b0383166000908152600160205260408120548211156103cb576040805162461bcd60e51b81526020600482015260166024820152750e6e4c640c4c2d8c2dcc6ca40dcdee840cadcdeeaced60531b604482015290519081900360640190fd5b6001600160a01b038416331480159061040957506001600160a01b038416600090815260026020908152604080832033845290915290205460001914155b15610514576001600160a01b0384166000908152600260209081526040808320338452909152902054821115610486576040805162461bcd60e51b815260206004820152601b60248201527f73726320616c6c6f77616e6365206973206e6f7420656e6f7567680000000000604482015290519081900360640190fd5b604080518082018252601e81527f616c6c6f77616e6365207375627472616374696f6e206f766572666c6f7700006020808301919091526001600160a01b03871660009081526002825283812033825290915291909120546104ef91849063ffffffff61080316565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610557826040518060600160405280602181526020016108f9602191396001600160a01b038716600090815260016020526040902054919063ffffffff61080316565b6001600160a01b0380861660009081526001602081815260408084209590955584518086018652601c81527f746f2062616c616e6365206164646974696f6e206f766572666c6f77000000008183015293881683525291909120546105c391849063ffffffff61089a16565b6001600160a01b0380851660008181526001602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b601281565b60006001600160a01b03831661063e57600080fd5b604080518082018252601b81527f616c6c6f77616e6365206164646974696f6e206f766572666c6f770000000000602080830191909152336000908152600282528381206001600160a01b038816825290915291909120546106a791849063ffffffff61089a16565b3360008181526002602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6001600160a01b031660009081526001602052604090205490565b6040518060400160405280600381526020016210951560ea1b81525081565b60006001600160a01b03831661075b57600080fd5b604080518082018252601e81527f616c6c6f77616e6365207375627472616374696f6e206f766572666c6f770000602080830191909152336000908152600282528381206001600160a01b038816825290915291909120546106a791849063ffffffff61080316565b60006107d1338484610365565b9392505050565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b600081848411156108925760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561085757818101518382015260200161083f565b50505050905090810190601f1680156108845780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600083830182858210156108ef5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561085757818101518382015260200161083f565b5094935050505056fe66726f6d2062616c616e6365207375627472616374696f6e206f766572666c6f77a26474726f6e58200b19d6f1b623efc370df5874c29ce6ab9005aebcb067acd94be71eaec1df3f9364736f6c63430005120031000000000000000000000000cf649401692e5eea5fd28000f452e7f35acc720b

Signed-off-by: brostiko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant