0
0
Blockchain / Solidityprogramming~20 mins

Multi-chain deployment in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Multi-chain Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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);
A{"Ethereum":"Contract deployed on BSC","BSC":"Contract deployed on Ethereum"}
B["Contract deployed on Ethereum","Contract deployed on BSC"]
C{"Ethereum":"Contract deployed on Ethereum","BSC":"Contract deployed on BSC"}
DSyntaxError: Unexpected token
Attempts:
2 left
💡 Hint
Look at how the deployed object keys and values are assigned inside the loop.
🧠 Conceptual
intermediate
1:30remaining
Understanding multi-chain deployment benefits
Which of the following is the main benefit of deploying a smart contract on multiple blockchains?
AIt makes the contract incompatible with wallets.
BIt allows the contract to reach users on different blockchain networks.
CIt reduces the contract's security by spreading it thin.
DIt increases the contract's gas fees on a single chain.
Attempts:
2 left
💡 Hint
Think about why projects want to be on more than one blockchain.
🔧 Debug
advanced
2: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);
AOutput shows empty deployed object {}
BSyntaxError: Unexpected token 'await'
CTypeError: deployContract is not a function
DOutput shows deployed contracts correctly
Attempts:
2 left
💡 Hint
Consider how async functions inside forEach behave.
📝 Syntax
advanced
2: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;
AdeployedContracts['Ethereum'] = 0x1234567890abcdef1234567890abcdef12345678;
BdeployedContracts['Ethereum'] == 0x1234567890abcdef1234567890abcdef12345678;
CdeployedContracts['Ethereum'] := 0x1234567890abcdef1234567890abcdef12345678;
DdeployedContracts('Ethereum') = 0x1234567890abcdef1234567890abcdef12345678;
Attempts:
2 left
💡 Hint
Remember how to assign values to mappings in Solidity.
🚀 Application
expert
2: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);
A3
B0
C1
D2
Attempts:
2 left
💡 Hint
Check which chain is skipped by the continue statement.