Challenge - 5 Problems
Multi-chain Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of multi-chain contract deployment script
What is the output of this simplified multi-chain deployment script snippet when deploying a contract to Ethereum and Binance Smart Chain?
Blockchain / Solidity
const chains = ['Ethereum', 'BSC']; const deployed = {}; for (const chain of chains) { deployed[chain] = `Contract deployed on ${chain}`; } console.log(deployed);
Attempts:
2 left
💡 Hint
Look at how the deployed object keys and values are assigned inside the loop.
✗ Incorrect
The script loops over each chain and assigns a string indicating deployment to the deployed object with the chain name as key. The output is a JSON object with keys 'Ethereum' and 'BSC' and corresponding deployment messages.
🧠 Conceptual
intermediate1:30remaining
Understanding multi-chain deployment benefits
Which of the following is the main benefit of deploying a smart contract on multiple blockchains?
Attempts:
2 left
💡 Hint
Think about why projects want to be on more than one blockchain.
✗ Incorrect
Deploying on multiple blockchains lets the contract interact with users and assets on different networks, increasing reach and usability.
🔧 Debug
advanced2:30remaining
Identify the error in multi-chain deployment script
What error will this multi-chain deployment snippet produce?
Blockchain / Solidity
const chains = ['Ethereum', 'Polygon']; const deployed = {}; chains.forEach(async (chain) => { deployed[chain] = await deployContract(chain); }); console.log(deployed);
Attempts:
2 left
💡 Hint
Consider how async functions inside forEach behave.
✗ Incorrect
The forEach loop does not wait for async callbacks to finish, so console.log runs before deployments complete, showing an empty object.
📝 Syntax
advanced2:00remaining
Correct syntax for multi-chain deployment mapping
Which option correctly creates a mapping of chain names to deployed contract addresses in Solidity?
Blockchain / Solidity
mapping(string => address) public deployedContracts;
Attempts:
2 left
💡 Hint
Remember how to assign values to mappings in Solidity.
✗ Incorrect
In Solidity, mapping values are assigned using single equals and square brackets for keys.
🚀 Application
expert2:30remaining
Determine the number of deployed contracts after multi-chain deployment
Given this deployment code snippet, how many contracts are deployed and stored in the 'deployed' object after execution?
Blockchain / Solidity
const chains = ['Ethereum', 'BSC', 'Polygon']; const deployed = {}; for (let i = 0; i < chains.length; i++) { if (chains[i] === 'BSC') continue; deployed[chains[i]] = `Contract on ${chains[i]}`; } console.log(Object.keys(deployed).length);
Attempts:
2 left
💡 Hint
Check which chain is skipped by the continue statement.
✗ Incorrect
The loop skips 'BSC', so only 'Ethereum' and 'Polygon' get deployed and stored, total 2.