hood-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +471 -0
- package/contracts/ERC20.sol +70 -0
- package/dist/chunk-CWEBZB3L.js +2248 -0
- package/dist/chunk-CWEBZB3L.js.map +1 -0
- package/dist/cli.js +1996 -0
- package/dist/cli.js.map +1 -0
- package/dist/dist-PVZTS5LZ.js +138 -0
- package/dist/dist-PVZTS5LZ.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
/// @title HoodToken
|
|
5
|
+
/// @notice A minimal, complete, fixed-supply ERC-20 used by `hood deploy-token`.
|
|
6
|
+
/// The entire supply is minted to the deployer at construction; there is
|
|
7
|
+
/// no mint/owner/pause surface — what you deploy is immutable. Standard
|
|
8
|
+
/// ERC-20 semantics (EIP-20): 18-decimal default, checked arithmetic
|
|
9
|
+
/// (Solidity 0.8 reverts on overflow/underflow).
|
|
10
|
+
/// @dev Self-contained (no imports) so it compiles with a bare solc and the
|
|
11
|
+
/// committed artifact in contracts/ERC20.json is byte-for-byte
|
|
12
|
+
/// reproducible: `npm run compile-erc20`.
|
|
13
|
+
contract HoodToken {
|
|
14
|
+
string public name;
|
|
15
|
+
string public symbol;
|
|
16
|
+
uint8 public immutable decimals;
|
|
17
|
+
uint256 public totalSupply;
|
|
18
|
+
|
|
19
|
+
mapping(address => uint256) public balanceOf;
|
|
20
|
+
mapping(address => mapping(address => uint256)) public allowance;
|
|
21
|
+
|
|
22
|
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
23
|
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
24
|
+
|
|
25
|
+
/// @param _name Token name.
|
|
26
|
+
/// @param _symbol Token ticker.
|
|
27
|
+
/// @param _decimals Token decimals (18 is the ERC-20 convention).
|
|
28
|
+
/// @param _initialSupply Whole-token supply; scaled by 10**_decimals and
|
|
29
|
+
/// minted in full to the deployer.
|
|
30
|
+
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _initialSupply) {
|
|
31
|
+
name = _name;
|
|
32
|
+
symbol = _symbol;
|
|
33
|
+
decimals = _decimals;
|
|
34
|
+
uint256 supply = _initialSupply * (10 ** uint256(_decimals));
|
|
35
|
+
totalSupply = supply;
|
|
36
|
+
balanceOf[msg.sender] = supply;
|
|
37
|
+
emit Transfer(address(0), msg.sender, supply);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function transfer(address to, uint256 value) external returns (bool) {
|
|
41
|
+
return _transfer(msg.sender, to, value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function approve(address spender, uint256 value) external returns (bool) {
|
|
45
|
+
allowance[msg.sender][spender] = value;
|
|
46
|
+
emit Approval(msg.sender, spender, value);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function transferFrom(address from, address to, uint256 value) external returns (bool) {
|
|
51
|
+
uint256 allowed = allowance[from][msg.sender];
|
|
52
|
+
if (allowed != type(uint256).max) {
|
|
53
|
+
require(allowed >= value, "ERC20: insufficient allowance");
|
|
54
|
+
allowance[from][msg.sender] = allowed - value;
|
|
55
|
+
}
|
|
56
|
+
return _transfer(from, to, value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function _transfer(address from, address to, uint256 value) internal returns (bool) {
|
|
60
|
+
require(to != address(0), "ERC20: transfer to the zero address");
|
|
61
|
+
uint256 fromBalance = balanceOf[from];
|
|
62
|
+
require(fromBalance >= value, "ERC20: transfer amount exceeds balance");
|
|
63
|
+
unchecked {
|
|
64
|
+
balanceOf[from] = fromBalance - value;
|
|
65
|
+
balanceOf[to] += value;
|
|
66
|
+
}
|
|
67
|
+
emit Transfer(from, to, value);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|