diff --git a/.env.sample b/.env.sample index 6741a1f5..2c79f61e 100644 --- a/.env.sample +++ b/.env.sample @@ -1 +1,2 @@ -MNEMONIC="" \ No newline at end of file +MNEMONIC="" +RPC="" \ No newline at end of file diff --git a/artifacts/25/deployment.json b/artifacts/25/deployment.json new file mode 100644 index 00000000..36818f1c --- /dev/null +++ b/artifacts/25/deployment.json @@ -0,0 +1,7 @@ +{ + "gasPrice": 10000000000000, + "gasLimit": 100000, + "signerAddress": "0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37", + "transaction": "0xf8a6808609184e72a000830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf355a054b6bc11ebcdd492b5083f82e745b27cf9aabd3afedc969a1fe863219c1094a9a00cd431f6d8e76c58b4ae488c96f95df8c57850088dd362a268cf051b226de259", + "address": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7" +} diff --git a/artifacts/338/deployment.json b/artifacts/338/deployment.json new file mode 100644 index 00000000..f47e5f30 --- /dev/null +++ b/artifacts/338/deployment.json @@ -0,0 +1,7 @@ +{ + "gasPrice": 10000000000000, + "gasLimit": 100000, + "signerAddress": "0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37", + "transaction": "0xf8a8808609184e72a000830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf38202c8a0749cead18bfc5151c8414fab334577f8c56120de5cda871c2237c855962184b3a042f0b6ed04459c15e37381167292f965a93f63e399f99b3c4f0f504b5b934dbb", + "address": "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7" +} diff --git a/package.json b/package.json index 7ba7b853..050a6b6a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ ], "scripts": { "compile": "ts-node scripts/compile.ts", + "estimate": "ts-node scripts/estimate.ts", "build": "yarn rimraf dist && tsc", "prepublish": "yarn build" }, diff --git a/scripts/compile.ts b/scripts/compile.ts index d32cdabc..aabb8af0 100644 --- a/scripts/compile.ts +++ b/scripts/compile.ts @@ -4,6 +4,7 @@ import { CompilerOutput, CompilerInput, compileStandardWrapper, CompilerOutputCo import { ethers } from 'ethers' import dotenv from "dotenv"; import yargs from 'yargs/yargs'; +import { compileContracts } from './utils'; dotenv.config() @@ -16,50 +17,6 @@ export async function ensureDirectoryExists(absoluteDirectoryPath: string) { } } -async function compileContracts(): Promise { - const solidityFilePath = path.join(__dirname, '..', 'source', 'deterministic-deployment-proxy.yul') - const soliditySourceCode = await filesystem.readFile(solidityFilePath, 'utf8') - const compilerInput: CompilerInput = { - language: "Yul", - settings: { - optimizer: { - enabled: true, - details: { - yul: true, - }, - }, - outputSelection: { - "*": { - "*": [ "abi", "evm.bytecode.object", "evm.gasEstimates" ] - }, - }, - }, - sources: { - 'deterministic-deployment-proxy.yul': { - content: soliditySourceCode, - }, - }, - } - const compilerInputJson = JSON.stringify(compilerInput) - const compilerOutputJson = compileStandardWrapper(compilerInputJson) - const compilerOutput = JSON.parse(compilerOutputJson) as CompilerOutput - const errors = compilerOutput.errors - if (errors) { - let concatenatedErrors = ""; - - for (let error of errors) { - if (/Yul is still experimental/.test(error.message)) continue - concatenatedErrors += error.formattedMessage + "\n"; - } - - if (concatenatedErrors.length > 0) { - throw new Error("The following errors/warnings were returned by solc:\n\n" + concatenatedErrors); - } - } - - return compilerOutput -} - async function writeBytecode(bytecode: string) { const filePath = path.join(__dirname, '..', 'artifacts', `bytecode.txt`) await filesystem.writeFile(filePath, bytecode, { encoding: 'utf8', flag: 'w' }) diff --git a/scripts/estimate.ts b/scripts/estimate.ts new file mode 100644 index 00000000..3664422c --- /dev/null +++ b/scripts/estimate.ts @@ -0,0 +1,30 @@ +import { promises as filesystem } from 'fs' +import * as path from 'path' +import { CompilerOutput, CompilerInput, compileStandardWrapper, CompilerOutputContract } from 'solc' +import { ethers } from 'ethers' +import dotenv from "dotenv"; +import yargs from 'yargs/yargs'; +import { compileContracts } from './utils'; + +dotenv.config() + +async function doStuff() { + const rpcUrl = process.env.RPC + const provider = new ethers.providers.JsonRpcProvider(rpcUrl) + const chainId = (await provider.getNetwork()).chainId + console.log({chainId}) + const compilerOutput = await compileContracts() + const contract = compilerOutput.contracts['deterministic-deployment-proxy.yul']['Proxy'] + const data = "0x" + contract.evm.bytecode.object + const estimate = await provider.estimateGas({ data }) + console.log({estimate: estimate.toString() }) + const gasPrice = await provider.getGasPrice() + console.log({gasPriceGwei: ethers.utils.formatUnits(gasPrice, "gwei"), gasPrice: gasPrice.toString() }) +} + +doStuff().then(() => { + process.exit(0) +}).catch(error => { + console.error(error) + process.exit(1) +}) diff --git a/scripts/utils.ts b/scripts/utils.ts new file mode 100644 index 00000000..eb996d37 --- /dev/null +++ b/scripts/utils.ts @@ -0,0 +1,47 @@ +import { promises as filesystem } from 'fs' +import * as path from 'path' +import { CompilerOutput, CompilerInput, compileStandardWrapper } from 'solc' + +export async function compileContracts(): Promise { + const solidityFilePath = path.join(__dirname, '..', 'source', 'deterministic-deployment-proxy.yul') + const soliditySourceCode = await filesystem.readFile(solidityFilePath, 'utf8') + const compilerInput: CompilerInput = { + language: "Yul", + settings: { + optimizer: { + enabled: true, + details: { + yul: true, + }, + }, + outputSelection: { + "*": { + "*": [ "abi", "evm.bytecode.object", "evm.gasEstimates" ] + }, + }, + }, + sources: { + 'deterministic-deployment-proxy.yul': { + content: soliditySourceCode, + }, + }, + } + const compilerInputJson = JSON.stringify(compilerInput) + const compilerOutputJson = compileStandardWrapper(compilerInputJson) + const compilerOutput = JSON.parse(compilerOutputJson) as CompilerOutput + const errors = compilerOutput.errors + if (errors) { + let concatenatedErrors = ""; + + for (let error of errors) { + if (/Yul is still experimental/.test(error.message)) continue + concatenatedErrors += error.formattedMessage + "\n"; + } + + if (concatenatedErrors.length > 0) { + throw new Error("The following errors/warnings were returned by solc:\n\n" + concatenatedErrors); + } + } + + return compilerOutput +} \ No newline at end of file