diff --git a/examples/custom-fee-token-with-deterministic-factories/index.ts b/examples/create-rollup-custom-fee-token/index.ts similarity index 100% rename from examples/custom-fee-token-with-deterministic-factories/index.ts rename to examples/create-rollup-custom-fee-token/index.ts diff --git a/examples/eth/package.json b/examples/create-rollup-custom-fee-token/package.json similarity index 83% rename from examples/eth/package.json rename to examples/create-rollup-custom-fee-token/package.json index 5b6c1c73..398ad20f 100644 --- a/examples/eth/package.json +++ b/examples/create-rollup-custom-fee-token/package.json @@ -1,5 +1,5 @@ { - "name": "eth", + "name": "create-rollup-custom-fee-token", "private": true, "version": "0.0.0", "type": "module", diff --git a/examples/custom-fee-token-with-deterministic-factories/tsconfig.json b/examples/create-rollup-custom-fee-token/tsconfig.json similarity index 100% rename from examples/custom-fee-token-with-deterministic-factories/tsconfig.json rename to examples/create-rollup-custom-fee-token/tsconfig.json diff --git a/examples/eth/index.ts b/examples/create-rollup-eth/index.ts similarity index 100% rename from examples/eth/index.ts rename to examples/create-rollup-eth/index.ts diff --git a/examples/custom-fee-token/package.json b/examples/create-rollup-eth/package.json similarity index 87% rename from examples/custom-fee-token/package.json rename to examples/create-rollup-eth/package.json index bfa67292..1f274307 100644 --- a/examples/custom-fee-token/package.json +++ b/examples/create-rollup-eth/package.json @@ -1,5 +1,5 @@ { - "name": "custom-fee-token", + "name": "create-rollup-eth", "private": true, "version": "0.0.0", "type": "module", diff --git a/examples/custom-fee-token/tsconfig.json b/examples/create-rollup-eth/tsconfig.json similarity index 100% rename from examples/custom-fee-token/tsconfig.json rename to examples/create-rollup-eth/tsconfig.json diff --git a/examples/custom-fee-token-with-deterministic-factories/package.json b/examples/custom-fee-token-with-deterministic-factories/package.json deleted file mode 100644 index 8a48a96e..00000000 --- a/examples/custom-fee-token-with-deterministic-factories/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "custom-fee-token-with-deterministic-factories", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "tsc --outDir dist && node ./dist/index.js" - }, - "devDependencies": { - "@types/node": "^20.9.0", - "typescript": "^5.2.2" - } -} diff --git a/examples/custom-fee-token/index.ts b/examples/custom-fee-token/index.ts deleted file mode 100644 index 69d6a6a2..00000000 --- a/examples/custom-fee-token/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Chain, createPublicClient, http } from 'viem'; -import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; -import { arbitrumSepolia } from 'viem/chains'; -import { - createRollupPrepareConfig, - prepareChainConfig, - createRollupPrepareTransactionRequest, - createRollupPrepareTransactionReceipt, -} from '@arbitrum/orbit-sdk'; -import { generateChainId } from '@arbitrum/orbit-sdk/utils'; - -function sanitizePrivateKey(privateKey: string): `0x${string}` { - if (!privateKey.startsWith('0x')) { - return `0x${privateKey}`; - } - - return privateKey as `0x${string}`; -} - -function withFallbackPrivateKey(privateKey: string | undefined): `0x${string}` { - if (typeof privateKey === 'undefined') { - return generatePrivateKey(); - } - - return sanitizePrivateKey(privateKey); -} - -function getBlockExplorerUrl(chain: Chain) { - return chain.blockExplorers?.default.url; -} - -if (typeof process.env.DEPLOYER_PRIVATE_KEY === 'undefined') { - throw new Error(`Please provide the "DEPLOYER_PRIVATE_KEY" environment variable`); -} - -// load or generate a random batch poster account -const batchPosterPrivateKey = withFallbackPrivateKey(process.env.BATCH_POSTER_PRIVATE_KEY); -const batchPoster = privateKeyToAccount(batchPosterPrivateKey).address; - -// load or generate a random validator account -const validatorPrivateKey = withFallbackPrivateKey(process.env.VALIDATOR_PRIVATE_KEY); -const validator = privateKeyToAccount(validatorPrivateKey).address; - -// set the parent chain and create a public client for it -const parentChain = arbitrumSepolia; -const parentChainPublicClient = createPublicClient({ chain: parentChain, transport: http() }); - -// load the deployer account -const deployer = privateKeyToAccount(sanitizePrivateKey(process.env.DEPLOYER_PRIVATE_KEY)); - -async function main() { - // generate a random chain id - const chainId = generateChainId(); - - // create the chain config - const chainConfig = prepareChainConfig({ - chainId, - arbitrum: { InitialChainOwner: deployer.address, DataAvailabilityCommittee: true }, - }); - - // prepare the transaction for deploying the core contracts - const request = await createRollupPrepareTransactionRequest({ - params: { - config: createRollupPrepareConfig({ - chainId: BigInt(chainId), - owner: deployer.address, - chainConfig, - }), - batchPoster, - validators: [validator], - nativeToken: '0xf861378b543525ae0c47d33c90c954dc774ac1f9', // $ARB - }, - account: deployer.address, - publicClient: parentChainPublicClient, - }); - - // sign and send the transaction - const txHash = await parentChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(request), - }); - - // get the transaction receipt after waiting for the transaction to complete - const txReceipt = createRollupPrepareTransactionReceipt( - await parentChainPublicClient.waitForTransactionReceipt({ hash: txHash }) - ); - - console.log(`Deployed in ${getBlockExplorerUrl(parentChain)}/tx/${txReceipt.transactionHash}`); -} - -main(); diff --git a/examples/eth-with-deterministic-factories/index.ts b/examples/eth-with-deterministic-factories/index.ts deleted file mode 100644 index 39e3a35b..00000000 --- a/examples/eth-with-deterministic-factories/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Chain, createPublicClient, http } from 'viem'; -import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; -import { arbitrumSepolia } from 'viem/chains'; -import { - createRollupPrepareConfig, - prepareChainConfig, - createRollupPrepareTransactionRequest, - createRollupPrepareTransactionReceipt, -} from '@arbitrum/orbit-sdk'; -import { generateChainId } from '@arbitrum/orbit-sdk/utils'; - -function sanitizePrivateKey(privateKey: string): `0x${string}` { - if (!privateKey.startsWith('0x')) { - return `0x${privateKey}`; - } - - return privateKey as `0x${string}`; -} - -function withFallbackPrivateKey(privateKey: string | undefined): `0x${string}` { - if (typeof privateKey === 'undefined') { - return generatePrivateKey(); - } - - return sanitizePrivateKey(privateKey); -} - -function getBlockExplorerUrl(chain: Chain) { - return chain.blockExplorers?.default.url; -} - -if (typeof process.env.DEPLOYER_PRIVATE_KEY === 'undefined') { - throw new Error(`Please provide the "DEPLOYER_PRIVATE_KEY" environment variable`); -} - -// load or generate a random batch poster account -const batchPosterPrivateKey = withFallbackPrivateKey(process.env.BATCH_POSTER_PRIVATE_KEY); -const batchPoster = privateKeyToAccount(batchPosterPrivateKey).address; - -// load or generate a random validator account -const validatorPrivateKey = withFallbackPrivateKey(process.env.VALIDATOR_PRIVATE_KEY); -const validator = privateKeyToAccount(validatorPrivateKey).address; - -// set the parent chain and create a public client for it -const parentChain = arbitrumSepolia; -const parentChainPublicClient = createPublicClient({ chain: parentChain, transport: http() }); - -// load the deployer account -const deployer = privateKeyToAccount(sanitizePrivateKey(process.env.DEPLOYER_PRIVATE_KEY)); - -async function main() { - // generate a random chain id - const chainId = generateChainId(); - - // create the chain config - const chainConfig = prepareChainConfig({ - chainId, - arbitrum: { InitialChainOwner: deployer.address, DataAvailabilityCommittee: true }, - }); - - // prepare the transaction for deploying the core contracts - const request = await createRollupPrepareTransactionRequest({ - params: { - config: createRollupPrepareConfig({ - chainId: BigInt(chainId), - owner: deployer.address, - chainConfig, - }), - batchPoster, - validators: [validator], - deployFactoriesToL2: true, - }, - account: deployer.address, - publicClient: parentChainPublicClient, - }); - - // sign and send the transaction - const txHash = await parentChainPublicClient.sendRawTransaction({ - serializedTransaction: await deployer.signTransaction(request), - }); - - // get the transaction receipt after waiting for the transaction to complete - const txReceipt = createRollupPrepareTransactionReceipt( - await parentChainPublicClient.waitForTransactionReceipt({ hash: txHash }) - ); - - console.log(`Deployed in ${getBlockExplorerUrl(parentChain)}/tx/${txReceipt.transactionHash}`); -} - -main(); diff --git a/examples/eth-with-deterministic-factories/package.json b/examples/eth-with-deterministic-factories/package.json deleted file mode 100644 index 03c6f99c..00000000 --- a/examples/eth-with-deterministic-factories/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "eth-with-deterministic-factories", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "tsc --outDir dist && node ./dist/index.js" - }, - "devDependencies": { - "@types/node": "^20.9.0", - "typescript": "^5.2.2" - } -} diff --git a/examples/eth-with-deterministic-factories/tsconfig.json b/examples/eth-with-deterministic-factories/tsconfig.json deleted file mode 100644 index abf0a90d..00000000 --- a/examples/eth-with-deterministic-factories/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "include": ["./**/*"] -} diff --git a/examples/eth/tsconfig.json b/examples/eth/tsconfig.json deleted file mode 100644 index abf0a90d..00000000 --- a/examples/eth/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "include": ["./**/*"] -}