// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "forge-std/Script.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IdentityRegistryUpgradeable} from "../src/IdentityRegistryUpgradeable.sol"; import {Bootstrap, RegistryProxy} from "../src/Bootstrap.sol"; import {FiberDesk, IIdentityRegistry} from "../src/FiberDesk.sol"; import {FiberPay} from "../src/FiberPay.sol"; /// Deploys Fiber's contracts on Elysium: the ERC-8004 identity registry (the reference contract behind a proxy), /// the desk that registers agents for them, and the payment contract. The sender becomes the registry's owner. /// /// RELAYER (needed) the only wallet the desk takes calls from: the Worker's gas wallet /// FIBER_PAY (optional) an existing payment contract to keep; without it a new one is deployed /// /// RELAYER=0x… forge script script/Deploy.s.sol --rpc-url https://rpc.elysium.kinetiq.xyz # simulate /// RELAYER=0x… forge script script/Deploy.s.sol --rpc-url https://rpc.elysium.kinetiq.xyz --broadcast --slow \ /// --private-key (the exact command is in the project README) contract Deploy is Script { /// USDC on Elysium (bridged from HyperEVM; EIP-2612 permit, name "USDC", version "1") address constant USDC = 0xb47c4C8F73F009CC0C0d3f92B388d13E293F0B65; struct Out { address registry; address registryImpl; address desk; address pay; } /// `pay` is an existing payment contract to keep, or address(0) to deploy one for `usdc`. function deploy(address owner, address usdc, address relayer, address pay) public returns (Out memory o) { Bootstrap boot = new Bootstrap(); IdentityRegistryUpgradeable impl = new IdentityRegistryUpgradeable(); RegistryProxy proxy = new RegistryProxy(address(boot), abi.encodeCall(Bootstrap.initialize, (owner))); // only the owner can do this step, so `owner` must be the sender Bootstrap(address(proxy)).upgradeToAndCall( address(impl), abi.encodeCall(IdentityRegistryUpgradeable.initialize, ()) ); o.registry = address(proxy); o.registryImpl = address(impl); o.desk = address(new FiberDesk(IIdentityRegistry(address(proxy)), relayer)); o.pay = pay == address(0) ? address(new FiberPay(IERC20(usdc))) : pay; } function run() external { address relayer = vm.envAddress("RELAYER"); address pay = vm.envOr("FIBER_PAY", address(0)); vm.startBroadcast(); Out memory o = deploy(msg.sender, USDC, relayer, pay); vm.stopBroadcast(); console.log("owner ", msg.sender); console.log("relayer ", relayer); console.log("registry ", o.registry); console.log("registry impl", o.registryImpl); console.log("desk ", o.desk); console.log(pay == address(0) ? "pay (new) " : "pay (kept) ", o.pay); string memory j = "d"; vm.serializeAddress(j, "owner", msg.sender); vm.serializeAddress(j, "relayer", relayer); vm.serializeAddress(j, "registry", o.registry); vm.serializeAddress(j, "registryImpl", o.registryImpl); vm.serializeAddress(j, "desk", o.desk); vm.serializeUint(j, "block", block.number); string memory out = vm.serializeAddress(j, "pay", o.pay); // DEPLOY_OUT names the file for a run that isn't the real chain (the fork test writes fork.json) vm.writeJson(out, vm.envOr("DEPLOY_OUT", string.concat("./deployments/", vm.toString(block.chainid), ".json"))); } }