Skip to main content
Version: v2.0_alpha

MockWETH

A mock WETH contract for testing

name

string name

symbol

string symbol

decimals

uint256 decimals

totalBalance

uint256 totalBalance

balances

mapping(address => uint256) balances

Deposit

event Deposit(uint256 amount, address depositor)

Withdraw

event Withdraw(uint256 amount, address withdrawer)

Transfer

event Transfer(address receiver, uint256 amount)

UserBalanceTooLow

error UserBalanceTooLow()

BalanceTooLow

error BalanceTooLow()

WithdrawFailed

error WithdrawFailed()

constructor

constructor(string _name, string _symbol) public payable

Constructor

Parameters

NameTypeDescription
_namestringThe name of the token
_symbolstringThe symbol of the token

deposit

function deposit() external payable

Deposit ETH

withdraw

function withdraw(uint256 amount) external

Withdraw ETH

Parameters

NameTypeDescription
amountuint256The amount to withdraw

transfer

function transfer(address to, uint256 amount) external

Transfer ETH

Parameters

NameTypeDescription
toaddressThe address to transfer to
amountuint256The amount to transfer

balanceOf

function balanceOf(address account) external view returns (uint256)

Get the balance of an address

Parameters

NameTypeDescription
accountaddressThe address to get the balance of

Return Values

NameTypeDescription
[0]uint256The balance of the address