Complete the code to specify the Layer 2 network RPC URL.
const provider = new ethers.providers.JsonRpcProvider('[1]');
The Polygon Mumbai testnet is a popular L2 network for deployment, so its RPC URL is used here.
Complete the code to deploy a contract using the signer connected to the L2 network.
const signer = new ethers.Wallet('0xYOUR_PRIVATE_KEY', provider); const factory = new ethers.ContractFactory(abi, bytecode, [1]); const contract = await factory.deploy();
The ContractFactory needs a signer to deploy the contract, so we pass the signer object.
Fix the error in the code to wait for the contract deployment transaction to be mined on the L2 network.
const tx = contract.deployTransaction;
await tx.[1]();The correct method to wait for a transaction to be mined is wait().
Fill the blanks to create an object that maps contract names to their deployed addresses on the L2 network, filtering only those with addresses starting with '0x'.
const deployedContracts = Object.keys(contracts).reduce((acc, [1]) => { if (contracts[[1]].address && contracts[[1]].address.[2]('0x')) { acc[[1]] = contracts[[1]].address; } return acc; }, {});
We use 'name' as the variable for keys and 'startsWith' to check the address prefix.
Fill all three blanks to filter and map contract deployment info: create a new object with keys as uppercased contract names, values as addresses, only for contracts deployed on the L2 network with gas used greater than 100000.
const filteredContracts = Object.entries(deployments).reduce((acc, [constName, info]) => {
if (info.network === 'L2' && info.gasUsed [3] 100000) {
acc[[1]] = [2];
}
return acc;
}, {});We uppercase the contract name for the key, use the address as value, and filter gasUsed greater than 100000.