julien/lovepublic Fork 0
905615022f33edfe91842b3dd95650f8fe3e1083
Commits
Clone
git clone https://git.rickub.com/julien/love.git
git clone ssh://git@rickub.com/julien/love.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Love.s.sol · 68 lines · 2.3 KBSolidity Blame HistoryRaw
add love contract 9bf25a7 julienbrg 11h ago1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.30;
3
4import {Love} from "../src/Love.sol";
5import {Script, console} from "forge-std/Script.sol";
6
deploy with create2 9056150 julienbrg 10h ago7/// @notice Deploys `Love` with CREATE2 through the canonical deterministic
8/// deployer, so the token gets the same address on every EVM network.
9/// The address depends only on the salt and the creation code — keep
10/// `solc`, the optimizer settings and `bytecode_hash = "none"` as they
11/// are in `foundry.toml`, or the address changes.
add love contract 9bf25a7 julienbrg 11h ago12contract LoveScript is Script {
deploy with create2 9056150 julienbrg 10h ago13 bytes32 public constant DEFAULT_SALT = keccak256("LOVE");
14
add love contract 9bf25a7 julienbrg 11h ago15 Love public love;
16
deploy with create2 9056150 julienbrg 10h ago17 function run() public returns (Love) {
18 bytes32 s = salt();
19 address predicted = predict(s);
20
21 console.log("deployer ", CREATE2_FACTORY);
22 console.log("salt ", vm.toString(s));
23 console.log("initCodeHash ", vm.toString(initCodeHash()));
24 console.log("predicted ", predicted);
25
26 if (predicted.code.length > 0) {
27 console.log("already deployed, nothing to do");
28 love = Love(predicted);
29 return love;
30 }
31
add love contract 9bf25a7 julienbrg 11h ago32 vm.startBroadcast();
deploy with create2 9056150 julienbrg 10h ago33 love = new Love{salt: s}();
34 vm.stopBroadcast();
35
36 require(address(love) == predicted, "LoveScript: address mismatch");
add love contract 9bf25a7 julienbrg 11h ago37
38 console.log("Love deployed at", address(love));
make love an erc20 with public mint 4c8048e julienbrg 11h ago39 console.log("name ", love.name());
40 console.log("symbol ", love.symbol());
41 console.log("totalSupply ", love.totalSupply());
add love contract 9bf25a7 julienbrg 11h ago42
deploy with create2 9056150 julienbrg 10h ago43 return love;
44 }
45
46 /// @notice Print the address `run()` would deploy to, without broadcasting.
47 function predict() public view returns (address predicted) {
48 bytes32 s = salt();
49 predicted = predict(s);
50
51 console.log("salt ", vm.toString(s));
52 console.log("initCodeHash ", vm.toString(initCodeHash()));
53 console.log("predicted ", predicted);
54 }
55
56 function predict(bytes32 s) public pure returns (address) {
57 return vm.computeCreate2Address(s, initCodeHash(), CREATE2_FACTORY);
58 }
59
60 function initCodeHash() public pure returns (bytes32) {
61 return keccak256(type(Love).creationCode);
62 }
63
64 /// @dev `SALT` overrides the default, e.g. to mine a vanity address.
65 function salt() public view returns (bytes32) {
66 return vm.envOr("SALT", DEFAULT_SALT);
add love contract 9bf25a7 julienbrg 11h ago67 }
68}