Bird
Raised Fist0
Blockchain / Solidityprogramming~20 mins

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

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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.

Practice

(1/5)
1.

What is the main benefit of multi-chain deployment in blockchain apps?

easy
A. It allows the app to run on multiple blockchains to reach more users.
B. It makes the app run faster on a single blockchain.
C. It reduces the app's code size significantly.
D. It guarantees zero transaction fees on all blockchains.

Solution

  1. Step 1: Understand multi-chain deployment purpose

    Multi-chain deployment means putting your app on many blockchains.
  2. Step 2: Identify the main benefit

    This helps reach more users and keeps the app working if one chain has issues.
  3. Final Answer:

    It allows the app to run on multiple blockchains to reach more users. -> Option A
  4. Quick Check:

    Multi-chain deployment = reach more users [OK]
Hint: Multi-chain means many blockchains, so more users [OK]
Common Mistakes:
  • Thinking it only speeds up the app
  • Believing it reduces code size
  • Assuming it removes all fees
2.

Which of the following is the correct way to specify multiple blockchain networks in a deployment config file?

{
  "networks": ["ethereum", "polygon", "binance"]
}
easy
A. { "networks": ["ethereum", "polygon", "binance"] }
B. { networks = [ethereum, polygon, binance] }
C. { networks: (ethereum, polygon, binance) }
D. { "networks": "ethereum, polygon, binance" }

Solution

  1. Step 1: Recognize JSON array syntax

    JSON arrays use square brackets [] with comma-separated strings in quotes.
  2. Step 2: Match correct syntax

    { "networks": ["ethereum", "polygon", "binance"] } correctly uses ["ethereum", "polygon", "binance"] as an array of strings.
  3. Final Answer:

    { "networks": ["ethereum", "polygon", "binance"] } -> Option A
  4. Quick Check:

    JSON arrays use [] with quoted strings [OK]
Hint: JSON arrays use square brackets and quotes for strings [OK]
Common Mistakes:
  • Using parentheses instead of brackets
  • Missing quotes around strings
  • Using equals sign instead of colon
3.

Consider this simplified deployment script snippet for multi-chain:

const chains = ["eth", "bsc"];
for (const chain of chains) {
  deployContract(chain);
}

function deployContract(chain) {
  console.log(`Deploying on ${chain}`);
}

What will be the output when this code runs?

medium
A. Deploying on eth,bsc
B. Deploying on eth\nDeploying on bsc
C. Deploying on chains
D. Error: deployContract is not defined

Solution

  1. Step 1: Understand the loop over chains array

    The for loop runs twice: once with 'eth', once with 'bsc'.
  2. Step 2: Check deployContract output

    Each call prints 'Deploying on ' plus the chain name.
  3. Final Answer:

    Deploying on eth\nDeploying on bsc -> Option B
  4. Quick Check:

    Loop prints each chain name separately [OK]
Hint: Loop prints each chain separately with deployContract [OK]
Common Mistakes:
  • Thinking it prints the whole array as one string
  • Expecting an error due to function scope
  • Confusing variable names
4.

Find the error in this multi-chain deployment snippet:

const chains = ["eth", "polygon"];
chains.forEach(chain => {
  deploy(chain);
});

function deploy(network) {
  console.log("Deploying to " + network);
}
medium
A. The deploy function name conflicts with a reserved word.
B. The forEach method is not valid on arrays.
C. There is no error; the code runs correctly.
D. The function deploy is called before it is defined.

Solution

  1. Step 1: Check function hoisting in JavaScript

    Function declarations are hoisted, so deploy can be called before definition.
  2. Step 2: Verify forEach usage

    forEach is valid on arrays and used correctly here.
  3. Final Answer:

    There is no error; the code runs correctly. -> Option C
  4. Quick Check:

    Function hoisting and forEach usage are correct [OK]
Hint: Function declarations are hoisted; forEach works on arrays [OK]
Common Mistakes:
  • Thinking function must be defined before use
  • Believing forEach is invalid on arrays
  • Assuming deploy is a reserved word
5.

You want to deploy a smart contract on Ethereum, Polygon, and Binance Smart Chain using a script. Which approach best ensures your deployment is safe and works on all chains?

  1. Use test networks for each chain first.
  2. Deploy directly to mainnets without testing.
  3. Write separate scripts for each chain with no shared code.
  4. Ignore chain-specific gas fees and settings.
hard
A. Ignore gas fees and settings; they are the same everywhere.
B. Deploy directly to mainnets to save time.
C. Write separate scripts for each chain without sharing code.
D. Use test networks for each chain first to verify deployment.

Solution

  1. Step 1: Understand importance of test networks

    Test networks simulate real chains safely to catch errors before mainnet deployment.
  2. Step 2: Evaluate deployment best practices

    Deploying directly risks loss; ignoring gas fees causes failures; separate scripts increase errors.
  3. Final Answer:

    Use test networks for each chain first to verify deployment. -> Option D
  4. Quick Check:

    Testing on testnets ensures safe multi-chain deployment [OK]
Hint: Always test on testnets before mainnet deployment [OK]
Common Mistakes:
  • Skipping tests and deploying directly
  • Ignoring chain-specific settings
  • Duplicating code unnecessarily