| document setup b1c9b0d julienbrg 10h ago | 1 | # love |
| 2 | |
| 3 | A [Foundry](https://getfoundry.sh) project. |
| 4 | |
| update docs for erc20 69c46a2 julienbrg 10h ago | 5 | `Love` (`LOVE`, 18 decimals) is a basic ERC-20 built on |
| 6 | [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts), with one |
| 7 | deliberate twist: `mint` has **no access control**. |
| 8 | |
| 9 | ```solidity |
| 10 | function mint(address to, uint256 amount) external; |
| 11 | ``` |
| 12 | |
| 13 | Anyone can mint any amount to any address. Supply starts at zero and is |
| 14 | unbounded, so the token carries no economic value — it is a faucet / demo token. |
| 15 | Do not deploy it to mainnet expecting otherwise. |
| document setup b1c9b0d julienbrg 10h ago | 16 | |
| 17 | ## Setup |
| 18 | |
| 19 | ```shell |
| 20 | forge install |
| 21 | cp .env.example .env |
| 22 | ``` |
| 23 | |
| 24 | ## Usage |
| 25 | |
| 26 | ```shell |
| 27 | forge build # compile |
| 28 | forge test # run tests |
| 29 | forge test -vvv # with traces |
| 30 | forge fmt # format |
| 31 | forge coverage # coverage report |
| 32 | forge snapshot # gas snapshot |
| 33 | anvil # local node |
| 34 | ``` |
| 35 | |
| 36 | ## Deploy |
| 37 | |
| document create2 deployment 1c407d3 julienbrg 9h ago | 38 | `Love` is deployed with CREATE2 through the canonical |
| 39 | [deterministic deployer](https://github.com/Arachnid/deterministic-deployment-proxy) |
| 40 | at `0x4e59b44847b379578588920cA78FbF26c0B4956C`, so it gets **the same address on |
| 41 | every EVM network**. The address derives from the salt and the creation code |
| 42 | only — not from the deployer account or its nonce. |
| 43 | |
| 44 | Check the address before spending gas: |
| 45 | |
| 46 | ```shell |
| 47 | forge script script/Love.s.sol:LoveScript --sig 'predict()' |
| 48 | ``` |
| 49 | |
| 50 | Then deploy: |
| 51 | |
| document setup b1c9b0d julienbrg 10h ago | 52 | ```shell |
| 53 | forge script script/Love.s.sol:LoveScript \ |
| 54 | --rpc-url base_sepolia \ |
| 55 | --account "$DEPLOYER_ACCOUNT" \ |
| 56 | --broadcast \ |
| 57 | --verify |
| 58 | ``` |
| 59 | |
| document create2 deployment 1c407d3 julienbrg 9h ago | 60 | Drop `--broadcast` for a dry run. Re-running against a network where the token |
| 61 | already exists is a no-op. |
| 62 | |
| 63 | The salt defaults to `keccak256("LOVE")`; override it — to mine a vanity address, |
| 64 | say — with `SALT=0x… forge script …`. The same salt must be used on every |
| 65 | network. |
| 66 | |
| 67 | ### Keeping the address stable |
| 68 | |
| 69 | The creation code, and therefore the address, changes if any of these change: |
| 70 | |
| 71 | - the contract source (`src/Love.sol`) or its OpenZeppelin version, |
| 72 | - `solc` (pinned to 0.8.30 in `foundry.toml`), |
| 73 | - optimizer settings (`optimizer = true`, `optimizer_runs = 200`, `via_ir = false`), |
| 74 | - `bytecode_hash` (set to `none`, which keeps the metadata hash out of the |
| 75 | bytecode so paths and compiler metadata don't leak into the address). |
| 76 | |
| 77 | Treat those as frozen once the token is deployed anywhere. |
| 78 | |
| 79 | Chains lacking the deterministic deployer — zkSync-style chains in particular, |
| 80 | where CREATE2 addresses are computed differently — cannot match this address. |
| document setup b1c9b0d julienbrg 10h ago | 81 | |
| 82 | ## Layout |
| 83 | |
| 84 | | Path | Contents | |
| 85 | | --------- | ------------------- | |
| 86 | | `src/` | Contracts | |
| 87 | | `test/` | Tests | |
| 88 | | `script/` | Deployment scripts | |
| 89 | | `lib/` | Dependencies | |
| update docs for erc20 69c46a2 julienbrg 10h ago | 90 | |
| 91 | ## Mint |
| 92 | |
| 93 | ```shell |
| 94 | cast send <LOVE_ADDRESS> "mint(address,uint256)" <RECIPIENT> 1000000000000000000 \ |
| 95 | --rpc-url base_sepolia \ |
| 96 | --account "$DEPLOYER_ACCOUNT" |
| 97 | ``` |