@@ -10,6 +10,8 @@ import * as fs from "fs";
1010import { ARB_OWNER } from "./consts" ;
1111import * as TransparentUpgradeableProxy from "@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json"
1212import * as ExpressLaneAuctionContract from "@arbitrum/nitro-contracts/build/contracts/src/express-lane-auction/ExpressLaneAuction.sol/ExpressLaneAuction.json"
13+ import * as StylusDeployerContract from "@arbitrum/nitro-contracts/build/contracts/src/stylus/StylusDeployer.sol/StylusDeployer.json"
14+
1315const path = require ( "path" ) ;
1416
1517async function sendTransaction ( argv : any , threadId : number ) {
@@ -185,6 +187,36 @@ async function deployWETHContract(deployerWallet: Wallet): Promise<string> {
185187 return weth . address ;
186188}
187189
190+ async function createStylusDeployer ( deployerWallet : Wallet ) : Promise < string > {
191+ // this factory should be deployed by the rollupcreator when deploy helper is used
192+ const create2factory = '0x4e59b44847b379578588920ca78fbf26c0b4956c'
193+ if ( await deployerWallet . provider . getCode ( create2factory ) === '0x' ) {
194+ // wait for 30 seconds, check again before throwing an error
195+ await new Promise ( resolve => setTimeout ( resolve , 30000 ) ) ;
196+ if ( await deployerWallet . provider . getCode ( create2factory ) === '0x' ) {
197+ throw new Error ( 'Create2 factory not yet deployed' )
198+ }
199+ }
200+
201+ const salt = ethers . constants . HashZero
202+ const stylusDeployerBytecode = StylusDeployerContract . bytecode
203+ const stylusDeployerAddress = ethers . utils . getCreate2Address ( create2factory , salt , ethers . utils . keccak256 ( stylusDeployerBytecode ) )
204+
205+ // check if the address is already deployed
206+ const code = await deployerWallet . provider . getCode ( stylusDeployerAddress )
207+ if ( code !== '0x' ) {
208+ console . log ( "Stylus deployer already deployed" )
209+ } else {
210+ const stylusDeployerTx = await deployerWallet . sendTransaction ( {
211+ to : create2factory ,
212+ data : ethers . utils . concat ( [ salt , stylusDeployerBytecode ] )
213+ } )
214+ await stylusDeployerTx . wait ( )
215+ }
216+
217+ return stylusDeployerAddress
218+ }
219+
188220export const bridgeFundsCommand = {
189221 command : "bridge-funds" ,
190222 describe : "sends funds from l1 to l2" ,
@@ -593,6 +625,30 @@ export const createWETHCommand = {
593625 } ,
594626} ;
595627
628+ export const createStylusDeployerCommand = {
629+ command : "create-stylus-deployer" ,
630+ describe : "deploys the stylus deployer contract" ,
631+ builder : {
632+ deployer : { string : true , describe : "account (see general help)" } ,
633+ l3 : { boolean : false , describe : "deploy on L3, otherwise deploy on L2" } ,
634+ } ,
635+ handler : async ( argv : any ) => {
636+ console . log ( "create-stylus-deployer" ) ;
637+
638+ const provider = new ethers . providers . WebSocketProvider ( argv . l3 ? argv . l3url : argv . l2url ) ;
639+ const deployerWallet = namedAccount ( argv . deployer ) . connect ( provider ) ;
640+
641+ const stylusDeployerAddress = await createStylusDeployer ( deployerWallet ) ;
642+ if ( argv . l3 ) {
643+ console . log ( "Stylus deployer deployed at L3 address:" , stylusDeployerAddress ) ;
644+ } else {
645+ console . log ( "Stylus deployer deployed at L2 address:" , stylusDeployerAddress ) ;
646+ }
647+
648+ provider . destroy ( ) ;
649+ }
650+ } ;
651+
596652export const sendL1Command = {
597653 command : "send-l1" ,
598654 describe : "sends funds between l1 accounts" ,
0 commit comments