









































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Designed for blockchain developers working with Hyperledger Fabric, this review guide explains smart contract development, chaincode lifecycle, network configuration, identity management, and transaction flows. The beta-focused review provides exam summaries, coding scenarios, architecture explanations, and practical best practices for enterprise-grade blockchain solutions.
Typology: Exams
1 / 81
This page cannot be seen from the preview
Don't miss anything!










































































Question 1. Which command creates a chaincode package for installation on peers? A) peer lifecycle chaincode install B) peer chaincode instantiate C) peer lifecycle chaincode package D) peer chaincode approveformyorg Answer: C Explanation: peer lifecycle chaincode package bundles the source code and metadata into a .tar.gz file ready for installation. Question 2. In the new Fabric lifecycle, what must organizations do before a chaincode definition can be committed? A) Install the chaincode on all peers B) Approve the chaincode definition for their organization C) Execute the Init function on the ledger D) Generate a private data collection config Answer: B Explanation: Each organization must invoke peer lifecycle chaincode approveformyorg to agree on the definition; only then can it be committed. Question 3. What is the purpose of the sequence number in a chaincode definition? A) To identify the chaincode package ID B) To enforce endorsement policy versioning C) To indicate the order of upgrades for the same chaincode name D) To specify the orderer’s consensus algorithm Answer: C Explanation: The sequence number increments with each upgrade, allowing the network to distinguish newer definitions from older ones.
Question 4. When invoking a chaincode’s Init (or InitLedger) function, which flag must be set on the transaction proposal? A) --isInit=true B) --init-required=true C) --chaincode-mode=init D) --invoke-type=init Answer: A Explanation: The --isInit flag signals to Fabric that the transaction is an initialization request, which is required for chaincodes that define an Init function. Question 5. Which Fabric Contract API annotation marks a method as the transaction that can be invoked by clients? A) @Transaction() B) @Invoke() C) @ContractMethod() D) @ChaincodeFunction() Answer: A Explanation: @Transaction() decorates a method in a contract class, indicating it is a transaction entry point. Question 6. In chaincode, which API call retrieves the value of a key from the world state? A) GetStateByRange B) PutState C) GetState D) DelState Answer: C Explanation: GetState(key) returns the byte array stored for the specified key. Question 7. Which of the following actions would break transaction determinism?
B) Chaincode definition only C) Individual key level using endorsement policies per key D) Orderer consensus Answer: C Explanation: State-based endorsement allows setting endorsement requirements for each key via SetStateValidationParameter. Question 11. Which query method retrieves all keys between two lexical boundaries? A) GetStateByPartialCompositeKey B) GetStateByRange C) GetQueryResult D) GetHistoryForKey Answer: B Explanation: GetStateByRange(startKey, endKey) returns an iterator over all keys in the specified range. Question 12. In CouchDB rich queries, which field specifies the selection criteria? A) selector B) filter C) query D) condition Answer: A Explanation: The selector object defines the JSON criteria for matching documents. Question 13. What is the purpose of a private data collection configuration file? A) To define endorsement policies for the channel B) To list the peers that store private data for a collection C) To configure the orderer’s block size
D) To set the TLS certificates for the network Answer: B Explanation: The collection config file lists member organizations and peer policies for storing private data. Question 14. Which chaincode stub method writes data to a private data collection? A) PutState B) PutPrivateData C) SetPrivateData D) WritePrivateData Answer: B Explanation: PutPrivateData(collection, key, value) stores the value in the specified private collection. Question 15. Pagination in rich queries is achieved by which parameter? A) pageSize and bookmark B) limit and offset C) maxResults and startKey D) pageNumber and pageToken Answer: A Explanation: The GetQueryResultWithPagination(pageSize, bookmark) API uses pageSize and bookmark to paginate results. Question 16. Which library allows chaincode to inspect a client’s X.509 certificate attributes? A) MSP B) CID C) ACL D) IAM
Answer: B Explanation: The Gateway service provides a simplified API for connecting, evaluating, and submitting transactions. Question 20. Which method on a Gateway contract object should be used for read‑only queries? A) submitTransaction B) evaluateTransaction C) queryTransaction D) readTransaction Answer: B Explanation: evaluateTransaction sends a proposal to endorsing peers and returns the result without committing to the ledger. Question 21. How can a chaincode emit an event that client applications can listen for? A) stub.SetEvent(eventName, payload) B) stub.Emit(eventName, payload) C) stub.TriggerEvent(eventName) D) stub.Publish(eventName, payload) Answer: A Explanation: SetEvent registers a named event with an optional payload that the client SDK can capture. Question 22. Which type of event provides notification when a new block is added to the ledger? A) Chaincode event B) Block event C) Transaction event D) Ledger event
Answer: B Explanation: Block events are emitted by peers when a new block is committed, allowing applications to monitor ledger progress. Question 23. When a transaction fails due to MVCC conflict, what is the most common cause? A) The endorsement policy was not satisfied B) The transaction read a key that was modified after simulation C) The orderer rejected the transaction because of insufficient signatures D) The client provided an invalid TLS certificate Answer: B Explanation: MVCC (Multi‑Version Concurrency Control) checks that the version of each read key matches the ledger at commit time; a mismatch causes a conflict. Question 24. In unit testing chaincode, which package is typically used to mock the transaction context? A) fabric-mock-stub B) shimtest C) mockpeer D) fabric-chaincode-go/mock Answer: D Explanation: The github.com/hyperledger/fabric-chaincode-go/shimtest package provides MockStub for simulating chaincode invocations. Question 25. Which log level is most appropriate for troubleshooting endorsement failures? A) INFO B) DEBUG C) WARN D) ERROR
Explanation: The sequence field in the definition must increase for each upgrade to be accepted. Question 29. Which method retrieves the historic values of a key? A) GetStateHistoryForKey B) GetHistoryForKey C) GetStateByHistory D) GetKeyHistory Answer: B Explanation: GetHistoryForKey(key) returns an iterator over all past values and timestamps for that key. Question 30. In a private data collection, which field defines who can read the private data? A) memberOnlyRead B) requiredPeerCount C) endorsementPolicy D) policy Answer: D Explanation: The policy field in the collection config specifies which organizations may read the private data. Question 31. Which of the following is a recommended practice to ensure deterministic chaincode? A) Use time.Now() to timestamp each transaction B) Store random numbers generated by each peer C) Sort slice elements before writing to the ledger D) Access external REST APIs during transaction execution Answer: C Explanation: Sorting ensures that data structures have a consistent order across peers, preserving determinism.
Question 32. What does the --channelID flag specify in the peer CLI lifecycle commands? A) The name of the chaincode package B) The target channel where the definition will be applied C) The orderer service endpoint D) The MSP ID of the invoking organization Answer: B Explanation: --channelID tells the CLI which channel the lifecycle operation (approve, commit, etc.) concerns. Question 33. Which method is used to retrieve the MSP ID of the transaction submitter inside chaincode? A) GetCreatorMSPID() B) GetMSPID() C) GetClientIdentity().GetMSPID() D) GetSubmittingOrg() Answer: C Explanation: cid.GetMSPID() (via the CID library) returns the MSP ID of the invoking client. Question 34. In the Fabric Gateway SDK, what object represents a specific smart contract? A) Contract B) Chaincode C) Ledger D) Network Answer: A Explanation: The Contract object is obtained from a Network and provides methods to evaluate or submit transactions.
Question 38. In a Fabric network, which component orders transactions into blocks? A) Peer B) Orderer C) CA D) Client SDK Answer: B Explanation: The Orderer service implements the consensus protocol and assembles endorsed transactions into blocks. Question 39. Which of the following is a valid way to delete a key from the world state? A) PutState(key, nil) B) DelState(key) C) RemoveState(key) D) DeleteState(key) Answer: B Explanation: DelState(key) removes the key/value pair from the world state. Question 40. What does the --signature-policy flag define when committing a chaincode definition? A) The policy that governs who can invoke the chaincode B) The endorsement policy that must be satisfied for transaction validation C) The policy for private data collection access D) The policy for channel creation Answer: B Explanation: --signature-policy sets the endorsement policy applied to transactions of that chaincode. Question 41. Which Fabric component validates that a transaction’s read‑write set complies with the endorsement policy?
A) Endorser peer B) Orderer C) Validation system chaincode (VSCC) on the committing peer D) Certificate Authority Answer: C Explanation: The VSCC runs during block validation on each committing peer to enforce endorsement policies. Question 42. In a chaincode unit test, which method simulates a transaction proposal? A) MockInvoke B) InvokeTransaction C) SimulateProposal D) ExecuteMock Answer: A Explanation: MockStub.MockInvoke(txID, args) simulates a proposal and runs the chaincode function. Question 43. Which of the following is NOT a supported state database for Fabric? A) LevelDB B) CouchDB C) MySQL D) RocksDB Answer: C Explanation: Fabric supports LevelDB (default) and CouchDB (for rich queries); MySQL is not a built‑in state database. Question 44. What is the purpose of the peer lifecycle chaincode querycommitted command? A) List all chaincode packages installed on the peer
C) Collections that store public data but are encrypted at rest D) Collections that are shared between all channels Answer: A Explanation: Implicit collections are automatically created for each organization (e.g., collectionName = orgMSPID) without explicit configuration. Question 48. Which Fabric system chaincode is responsible for managing channel configuration? A) LSCC (Lifecycle System Chaincode) B) CSCC (Configuration System Chaincode) C) QSCC (Query System Chaincode) D) ESCC (Endorsement System Chaincode) Answer: B Explanation: CSCC handles channel configuration queries and updates. Question 49. What does the --ordererTLSHostnameOverride flag help to resolve? A) Mismatched TLS hostnames when the orderer’s certificate uses a different CN B) Incorrect MSP IDs in the transaction proposal C) Peer discovery failures D) Chaincode package ID mismatches Answer: A Explanation: It overrides the hostname verification during TLS handshake with the orderer. Question 50. Which transaction result indicates that the endorsement policy was satisfied but the MVCC check failed? A) ENDORSEMENT_FAILURE B) MVCC_READ_CONFLICT C) VALIDATION_ERROR
Answer: B Explanation: MVCC_READ_CONFLICT means the read set versions no longer match the ledger at commit time. Question 51. In a chaincode’s InitLedger function, which pattern is recommended for bulk asset creation? A) Invoke PutState for each asset without batching B) Use a single PutState with a JSON array of all assets C) Loop through assets and use PutState, committing after the loop finishes D) Call a private data collection for each asset Answer: C Explanation: Looping with individual PutState calls ensures each asset gets its own key and version; the transaction commits all at once. Question 52. Which of the following is a valid reason to use a private data collection instead of a separate channel? A) To reduce the number of orderer nodes required B) To share confidential data among a subset of organizations while keeping the rest of the ledger public C) To avoid the need for TLS certificates D) To enable faster block propagation Answer: B Explanation: Private collections allow selective data sharing without the overhead of creating a new channel. Question 53. Which command generates the genesis block for a new channel? A) configtxgen - profile MyChannel - outputCreateChannelTx channel.tx B) peer channel create - o orderer.example.com:7050 - c mychannel - f channel.tx C) configtxlator proto_encode --input config.yaml --type common.Config
Answer: B Explanation: GetBlockchainInfo() returns Height, the number of blocks in the ledger. Question 57. In a Fabric network, what is the role of the “Endorser” peer? A) To order transactions into blocks B) To validate transaction signatures after ordering C) To simulate transaction proposals and produce endorsement signatures D) To manage channel configuration updates Answer: C Explanation: Endorsers execute the chaincode simulation and sign the read‑write set, providing endorsements. Question 58. Which of the following events is NOT emitted by the Fabric SDK by default? A) Block event B) Chaincode event C) Transaction commit event D) Peer connection event Answer: D Explanation: The SDK does not emit a specific “peer connection” event; it provides block, chaincode, and transaction events. Question 59. Which attribute of a transaction proposal can be used to enforce a “one‑time” transaction? A) Timestamp B) Transaction ID (nonce) C) Channel ID D) Chaincode name
Answer: B Explanation: The transaction ID (derived from the client’s nonce) ensures uniqueness; replaying the same ID will be rejected. Question 60. What does the --peerTLSRootCertFile flag provide to the CLI? A) The peer’s private key for signing proposals B) The TLS root CA certificate to verify the peer’s TLS certificate C) The MSP config for the organization D) The orderer’s TLS certificate Answer: B Explanation: It points to the root certificate used to validate the TLS connection to the peer. Question 61. Which of the following is a correct way to retrieve the transaction ID inside chaincode? A) stub.GetTxID() B) stub.GetTransactionID() C) stub.GetID() D) stub.GetProposalID() Answer: A Explanation: GetTxID() returns the unique transaction identifier. Question 62. In the context of Fabric, what does “MVCC” stand for? A) Multi‑Version Concurrency Control B) Managed Virtual Chaincode Container C) Mutual Verification Certificate Chain D) Modular Validation Consensus Component Answer: A Explanation: MVCC is the mechanism that checks version consistency of read keys during commit.