Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free Blockchain BTA Certified Blockchain Developer - Ethereum CBDE Exam Questions

Last updated: · 12 practice questions with answers and explanations

Page: 1 / 11 Total 102 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Implement web3.js

Skill tested: Use web3.js providers and contract calls to distinguish reads from transactions.

A supply-chain dashboard uses web3.js to display a shipment's current status and let an authorized operator update it. The contract exposes a view function `statusOf(id)` and a state-changing function `setStatus(id, value)`. The dashboard must read the status without asking the user to sign a transaction, but updates must be submitted from the operator's wallet and report their mined transaction hash. Which implementation best meets these requirements?

Correct Answer: D. Call `statusOf(id).call()` for the read and `setStatus(id, value).send({ from: operatorAddress })` for the update, handling the transaction receipt or transaction-hash event.
Explanation:

A contract method invoked with `.call()` executes locally against the selected node's state and does not create a transaction, which fits the read-only status lookup. A state-changing method must be submitted with `.send()` and an account authorized to sign; the returned PromiEvent can provide transaction lifecycle events, including a transaction hash and receipt. A reverses the intended behavior. C incorrectly treats `.call()` as a state-committing operation. D needlessly creates a transaction for a read and does not use the normal return-value path.

Question 2

New Multiple answers

Topic: Implement web3.js

Skill tested: Configure web3.js subscriptions and recover cleanly from provider disconnections.

A monitoring service uses web3.js over WebSocket to watch a contract event and update an off-chain shipment index. During network interruptions, the provider may disconnect, and events emitted while the process is offline must not be silently lost. The service can persist the last successfully indexed block number and query historical logs from the node. Which TWO actions provide the most reliable recovery strategy? Select TWO.

Correct Answer: A. Persist the last processed block and, after reconnecting, backfill logs from that block before resuming live subscription processing.; E. On reconnect, recreate the subscription and query the contract event logs from the persisted block through the current head, deduplicating records by transaction hash and log index.
Explanation:

A WebSocket subscription is not a durable event queue; a disconnected client can miss notifications. Persisting progress and querying historical logs after reconnect provides a backfill, while recreating the subscription restores low-latency processing. Deduplication is important because the backfill range and live subscription can overlap, and a transaction hash plus log index identifies a log occurrence. B assumes unsupported buffering. D changes the transport but does not guarantee historical delivery. E skips the offline interval and therefore loses events.

Question 3

New Single answer

Topic: Write and compile Solidity smart contracts

Skill tested: Apply Solidity inheritance and constructor initialization rules during compilation.

A team is consolidating two Solidity contracts. `Registry` has a constructor that takes an address and initializes an immutable `owner`; `Audited` is an abstract base with no constructor arguments. The new concrete contract `ManagedRegistry` inherits from both, and its constructor receives `initialOwner`. Compilation fails because the inherited `Registry` constructor is not initialized. The design requires the owner to be fixed at deployment and the base contracts to retain their existing behavior. Which change is appropriate?

Correct Answer: C. Add `Registry(initialOwner)` to `ManagedRegistry`'s inheritance list or constructor initialization list, preserving the immutable initialization during deployment.
Explanation:

A derived contract must supply the arguments required by a base constructor, using Solidity's inheritance or constructor-initializer syntax. That lets `Registry` initialize its immutable owner as part of deployment while retaining inherited behavior. A changes the security and initialization model by making ownership mutable and separately initialized. C is not valid constructor invocation syntax: base constructors are initialized through the inheritance/initializer mechanism, not called as ordinary functions from the body. D discards the base contract's behavior and risks creating an incompatible implementation.

Question 4

New Multiple answers

Topic: Write and compile Solidity smart contracts

Skill tested: Use ABI encoding and decoding correctly when integrating compiled Solidity contracts.

A release pipeline compiles a contract and publishes its ABI and deployment address to a web application. The contract has an overloaded `quote` function, with variants that accept either one `uint256` or a `uint256` and an address. A developer reports that calls sometimes resolve to the wrong interface in a web3.js integration. The team must preserve the compiled contract's exact external interface and avoid manually constructing calldata. Which TWO practices should the team adopt? Select TWO.

Correct Answer: A. Use the ABI's canonical function signature or argument types to select the intended overloaded `quote` method explicitly.; C. Instantiate the web3.js contract using the ABI produced by compilation and the deployed contract address.
Explanation:

The ABI describes the contract's externally callable functions and their argument and return types; web3.js uses it with the deployed address to encode calls and decode results. Overloaded functions share a name, so selecting the overload by its signature or argument types avoids ambiguity. C is incorrect because web3.js contract interaction is driven by the ABI, not Solidity source. D contradicts Solidity's support for function overloading. E is unreliable: deployed bytecode does not generally provide web3.js with the complete ABI needed to construct the interface.

Question 5

New Single answer

Topic: Create secure smart contracts

Skill tested: Prevent reentrancy in Solidity by controlling external calls and state updates.

A marketplace contract lets a seller withdraw accumulated proceeds. Its current `withdraw` function calls the seller's address with the amount due and clears the seller's balance only after the call succeeds. A security review notes that a contract seller can reenter `withdraw` from its fallback function before the balance is cleared. The team wants a minimal, robust correction that preserves withdrawal behavior and does not rely on sellers being externally owned accounts. What should the developers do?

Correct Answer: D. Clear the seller's recorded balance before the external call, restore it if the call fails, and use a reentrancy guard where appropriate.
Explanation:

The vulnerability arises because control passes to an untrusted recipient while the old balance remains available for another withdrawal. Following checks-effects-interactions means recording the balance as withdrawn before making the external call; if the call fails, the implementation can revert so the state change is undone. A excludes legitimate contract wallets and is not a sound defense. C relies on a gas-stipend assumption that is not a robust general security guarantee and can break compatibility. D is incompatible with a function that transfers funds and changes accounting state.

Question 6

New Single answer

Topic: Create secure smart contracts

Skill tested: Enforce authorization using explicit caller checks rather than transaction-origin identity.

A treasury contract allows only its designated administrator to change the approved recipient. A developer implements the check using `tx.origin`, arguing that it prevents a contract from acting as an administrator. A security review identifies a phishing path: the administrator can be induced to call an intermediary contract, which then calls the treasury. The team needs a standard authorization check that works when the administrator is a contract wallet. Which change is best?

Correct Answer: A. Require `msg.sender == administrator` and update the administrator only through an explicitly authorized operation.
Explanation:

`msg.sender` identifies the immediate caller and is the conventional basis for contract-level access control. It correctly supports a contract administrator: the wallet contract itself is the caller observed by the treasury. `tx.origin` refers to the originating externally owned account across the call chain, enabling the intermediary-contract phishing pattern described. B retains that flaw and unnecessarily rejects some valid flows. C still permits authorization based on `tx.origin`. `block.coinbase` identifies a block beneficiary, not an application administrator.

Question 7

New Single answer

Topic: Deploy smart contracts both the live and test Ethereum networks

Skill tested: Deploy with a configured network, signer, compiled artifact, and verified deployment receipt.

A developer has compiled a contract and wants to deploy it to a public Ethereum test network. The deployment script currently creates a contract instance from the ABI and address of a previous deployment, then calls a state-changing method. No contract address exists for the new release, and the script must deploy the new bytecode using the team's funded deployment account. Which approach is most appropriate?

Correct Answer: B. Create a contract instance with the ABI and new bytecode, submit its deployment transaction from the funded account on the configured test network, and record the address from the deployment receipt.
Explanation:

Deployment requires sending a transaction containing the compiled creation bytecode and constructor arguments from a funded signer on the intended network. The resulting receipt provides the deployed contract address, which should be recorded alongside the corresponding ABI and build. A `.call()` simulates execution and does not persist a deployment. Sending creation bytecode to an existing contract address does not replace its code. An ABI is client-side interface metadata and cannot itself trigger deployment, so D cannot create the new instance.

Question 8

New Multiple answers

Topic: Deploy smart contracts both the live and test Ethereum networks

Skill tested: Separate deployment networks and credentials to avoid accidental production releases.

A company deploys the same Solidity application to a public test network and to Ethereum mainnet. Its release process must ensure that test transactions cannot reach mainnet, production credentials are not exposed to test jobs, and each deployment artifact can be associated with the correct network. The team uses a deployment framework that supports named networks and environment-provided account credentials. Which TWO controls best satisfy these requirements? Select TWO.

Correct Answer: C. Configure distinct network entries with explicit RPC endpoints and chain identifiers, and select the intended network explicitly for each deployment.; D. Provide separate credentials through protected environment-specific secret handling, and ensure test jobs cannot access mainnet signing credentials.
Explanation:

Explicitly named network configuration, including the endpoint and chain identity, makes the deployment target deliberate and auditable. Separating credentials and limiting which jobs can access production signing material reduces the impact of a misconfigured or compromised test pipeline. B reuses both a sensitive key and a target endpoint, so contract names provide no isolation. The Solidity pragma constrains compiler compatibility, not the chain. Different bytecode cannot prevent a transaction from being submitted to the wrong network.

Question 9

New Single answer

Topic: Calculate Ethereum gas costs

Skill tested: Distinguish gas units, gas price, and maximum transaction fee exposure.

A release engineer estimates the cost of a transaction by multiplying its gas limit by a quoted gas price. The transaction's execution normally consumes fewer gas units than the limit, but the team must reserve enough ETH to ensure the transaction can be submitted. In a legacy transaction model, which statement correctly describes the relationship among gas limit, gas used, gas price, and the transaction's actual execution fee?

Correct Answer: B. The sender must be able to cover the gas limit multiplied by gas price; after execution, the fee is based on gas actually used multiplied by gas price, with unused gas not charged.
Explanation:

For a legacy transaction, gas units measure computational work and gas price is the price per unit. A sender must have sufficient balance for the transaction's maximum gas exposure, calculated using the gas limit and gas price. If execution completes, the fee is charged for gas actually used, not the entire limit; unused gas is not charged. A confuses the upfront balance requirement with the final fee. C incorrectly charges all of the limit. D reverses the roles of these values and confuses gas accounting with the transferred value.

Question 10

New Multiple answers

Topic: Calculate Ethereum gas costs

Skill tested: Estimate transaction fees under EIP-1559 using gas usage and fee-cap parameters.

A wallet submits an EIP-1559 transaction with a gas limit of 100,000, a maximum fee per gas of 40 gwei, and a priority fee cap of 3 gwei. At inclusion, the block's base fee is 25 gwei, and the transaction consumes 60,000 gas. Assume the maximum fee cap is sufficient for inclusion and ignore any value transfer. Which TWO statements are correct? Select TWO.

Correct Answer: D. The effective priority fee is 3 gwei per gas, because the priority fee cap is below the available difference between the maximum fee and the base fee.; E. The execution fee is 1,680,000 gwei, calculated using 60,000 gas at an effective price of 28 gwei.
Explanation:

Under EIP-1559, the effective priority fee is bounded by the priority fee cap and the headroom between the maximum fee and the base fee. Here, 3 gwei is below the 15 gwei headroom, so the effective price is 25 + 3 = 28 gwei. Multiplying that by the 60,000 gas actually used gives 1,680,000 gwei. The gas limit sets an execution bound and maximum exposure, not the final charge. The maximum fee cap is not automatically paid, and a priority fee is a price component, not additional gas units.

Question 11

New Single answer

Topic: Unit test smart contracts

Skill tested: Test expected reverts and state invariants with isolated contract-test assertions.

A token contract rejects transfers when the sender's balance is insufficient. A unit test submits such a transfer and then checks that the recipient's balance is unchanged. The test unexpectedly reports a pass even when the transfer succeeds in a faulty version of the contract. The test framework supports explicit revert assertions. What should the test do to verify the intended behavior reliably?

Correct Answer: A. Assert that the transaction reverts with the expected failure condition, and verify relevant balances remain unchanged.
Explanation:

A robust negative test must assert the expected failure itself; otherwise a successful transaction may pass an incidental balance check, particularly if the recipient started with zero tokens. Checking that balances remain unchanged also verifies the failure did not partially alter state. A does not establish that the transfer reverted. C accepts unrelated errors and omits a complete state assertion. D is not appropriate for a state-changing transfer and does not test the contract's transactional failure behavior.

Question 12

New Multiple answers

Topic: Unit test smart contracts

Skill tested: Design deterministic tests for time-dependent Solidity behavior using controlled timestamps.

A vesting contract releases tokens after a cliff timestamp. The test suite currently waits in real time until the cliff passes, making builds slow and flaky. The development test environment allows controlled block timestamp advancement, and tests must confirm both the pre-cliff restriction and post-cliff release without depending on wall-clock timing. Which TWO testing practices are appropriate? Select TWO.

Correct Answer: B. Use the local test environment's time-control facility to advance past the cliff, mine a block, and assert the expected release and state changes.; E. Set or advance the next test block's timestamp to just before the cliff, mine a block, and assert that release is rejected.
Explanation:

Time-dependent contract tests should control block time in the local test environment and mine blocks so the EVM evaluates the intended timestamp. Testing immediately before and after the cliff verifies both the rejection boundary and successful release path while remaining fast and deterministic. C changes production security properties to simplify a test and is unnecessary. D reintroduces slow, nondeterministic wall-clock dependence and cannot reliably target the boundary. E does not exercise or validate the vesting condition.