Skip to content

Latest commit

 

History

History
414 lines (356 loc) · 11.7 KB

WRBTC.md

File metadata and controls

414 lines (356 loc) · 11.7 KB

WRBTC.sol

View Source: contracts/testhelpers/WRBTC.sol

WRBTC contract

Contract Members

Constants & Variables

string public name;
string public symbol;
uint8 public decimals;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

Events

event Approval(address indexed src, address indexed guy, uint256  wad);
event Transfer(address indexed src, address indexed dst, uint256  wad);
event Deposit(address indexed dst, uint256  wad);
event Withdrawal(address indexed src, uint256  wad);

Functions


constructor

function () external payable
Source Code
function() external payable {
        deposit();
    }

deposit

function deposit() public payable
Source Code
function deposit() public payable {
        balanceOf[msg.sender] += msg.value;
        emit Deposit(msg.sender, msg.value);
    }

withdraw

function withdraw(uint256 wad) public nonpayable

Arguments

Name Type Description
wad uint256
Source Code
function withdraw(uint256 wad) public {
        require(balanceOf[msg.sender] >= wad);
        balanceOf[msg.sender] -= wad;
        msg.sender.transfer(wad);
        emit Withdrawal(msg.sender, wad);
    }

totalSupply

function totalSupply() public view
returns(uint256)
Source Code
function totalSupply() public view returns (uint256) {
        return address(this).balance;
    }

approve

function approve(address guy, uint256 wad) public nonpayable
returns(bool)

Arguments

Name Type Description
guy address
wad uint256
Source Code
function approve(address guy, uint256 wad) public returns (bool) {
        allowance[msg.sender][guy] = wad;
        emit Approval(msg.sender, guy, wad);
        return true;
    }

transfer

function transfer(address dst, uint256 wad) public nonpayable
returns(bool)

Arguments

Name Type Description
dst address
wad uint256
Source Code
function transfer(address dst, uint256 wad) public returns (bool) {
        return transferFrom(msg.sender, dst, wad);
    }

transferFrom

function transferFrom(address src, address dst, uint256 wad) public nonpayable
returns(bool)

Arguments

Name Type Description
src address
dst address
wad uint256
Source Code
function transferFrom(
        address src,
        address dst,
        uint256 wad
    ) public returns (bool) {
        require(balanceOf[src] >= wad);

        if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {
            require(allowance[src][msg.sender] >= wad);
            allowance[src][msg.sender] -= wad;
        }

        balanceOf[src] -= wad;
        balanceOf[dst] += wad;

        emit Transfer(src, dst, wad);

        return true;
    }

Contracts