0
0
Blockchain / Solidityprogramming~20 mins

CI/CD for smart contracts in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Smart Contract CI/CD Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of a smart contract deployment script
What is the output of this deployment script snippet when deploying a smart contract using Hardhat?
Blockchain / Solidity
const hre = require('hardhat');
async function main() {
  const Contract = await hre.ethers.getContractFactory('MyContract');
  const contract = await Contract.deploy();
  await contract.deployed();
  console.log('Contract deployed to:', contract.address);
}
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
ASyntaxError: Unexpected token
BError: ContractFactory not found
CContract deployed to: 0x1234567890abcdef1234567890abcdef12345678
DContract deployment failed due to gas limit
Attempts:
2 left
💡 Hint
The script logs the deployed contract address on success.
🔀 Workflow
intermediate
2:00remaining
Correct CI/CD pipeline step order for smart contracts
Which option shows the correct order of steps in a CI/CD pipeline for smart contracts?
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Linting should happen before compilation.
Troubleshoot
advanced
2:00remaining
Troubleshooting deployment failure due to missing private key
A CI job fails deploying a smart contract with this error: "Error: No private key provided". Which option is the most likely cause?
AThe environment variable for the deployer's private key is not set in the CI environment.
BThe smart contract code has a syntax error.
CThe testnet network is down.
DThe gas price is set too low.
Attempts:
2 left
💡 Hint
Private keys are usually stored as environment variables in CI.
Best Practice
advanced
2:00remaining
Best practice for managing secrets in smart contract CI/CD
Which option is the best practice for handling private keys and secrets in a smart contract CI/CD pipeline?
ACommit private keys directly into the repository for easy access.
BStore private keys encrypted in the CI tool's secret manager and inject them at runtime.
CSend private keys via email to the deployment server before each run.
DHardcode private keys in the deployment scripts.
Attempts:
2 left
💡 Hint
Secrets should never be stored in code or sent insecurely.
🧠 Conceptual
expert
3:00remaining
Impact of immutable smart contracts on CI/CD updates
Given that deployed smart contracts are immutable, what is the best approach to update contract logic in a CI/CD pipeline?
AUse the same contract address and overwrite the bytecode with the new logic.
BModify the existing contract code on the blockchain directly via the CI pipeline.
CPause the blockchain network, update the contract, then resume the network.
DDeploy a new version of the contract and update references in the application to point to the new address.
Attempts:
2 left
💡 Hint
Smart contracts cannot be changed once deployed.