forked from p10node/swisstronik-testnet2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PERC20Sample.sol
45 lines (38 loc) · 1.67 KB
/
PERC20Sample.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./PERC20.sol";
/**
* @dev Sample implementation of the {PERC20} contract.
*/
contract PERC20Sample is PERC20 {
constructor() PERC20("Sample PERC20", "pSWTR") {}
/// @dev Wraps SWTR to PSWTR.
receive() external payable {
_mint(_msgSender(), msg.value);
}
/**
* @dev Regular `balanceOf` function marked as internal, so we override it to extend visibility
*/
function balanceOf(address account) public view override returns (uint256) {
// This function should be called by EOA using signed `eth_call` to make EVM able to
// extract original sender of this request. In case of regular (non-signed) `eth_call`
// msg.sender will be empty address (0x0000000000000000000000000000000000000000).
require(msg.sender == account, "PERC20Sample: msg.sender != account");
// If msg.sender is correct we return the balance
return _balances[account];
}
/**
* @dev Regular `allowance` function marked as internal, so we override it to extend visibility
*/
function allowance(
address owner,
address spender
) public view virtual override returns (uint256) {
// This function should be called by EOA using signed `eth_call` to make EVM able to
// extract original sender of this request. In case of regular (non-signed) `eth_call`
// msg.sender will be empty address (0x0000000000000000000000000000000000000000)
require(msg.sender == spender, "PERC20Sample: msg.sender != account");
// If msg.sender is correct we return the allowance
return _allowances[owner][spender];
}
}