




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which method in the Fabric Contract API is used to define the initial state of a smart contract when it is instantiated? A) InitLedger() B) Init() C) Instantiate() D) InitContract() Answer: A Explanation: The InitLedger() function is a user-defined transaction that is typically invoked after deployment to populate the ledger with initial data. Question 2. In chaincode, which of the following statements best describes a deterministic transaction function? A) It uses the current timestamp to calculate a value. B) It generates a random UUID for each asset. C) It produces the same world-state changes for identical inputs on every peer. D) It reads the host machineâs environment variables. Answer: C Explanation: Determinism means that given the same input, all endorsing peers must arrive at identical read/write sets; using time or randomness breaks this guarantee. Question 3. What is the primary purpose of input validation in a chaincode transaction function? A) To improve transaction throughput. B) To ensure the ledger remains consistent and prevent malformed data. C) To encrypt the arguments before processing.
D) To automatically sign the transaction. Answer: B Explanation: Validating and sanitizing arguments prevents invalid or malicious data from being written to the ledger, preserving data integrity. Question 4. Which JSON structure best represents an asset with a composite key consisting of âownerâ and âassetIDâ? A) { "key": "owner:assetID", "value": { ... } } B) { "owner": "owner", "assetID": "assetID", "details": { ... } } C) { "docType": "asset", "owner": "owner", "assetID": "assetID" } D) { "compositeKey": ["owner","assetID"], "payload": { ... } } Answer: C Explanation: Fabric recommends storing a âdocTypeâ field to identify the asset type; the composite key is derived from the owner and assetID fields when using PutState with a composite key. Question 5. Which stub method writes a key-value pair to the world state? A) GetState() B) PutState() C) DelState() D) SetState() Answer: B Explanation: PutState() stores the supplied value under the given key in the ledgerâs world state.
Answer: B Explanation: GetHistoryForKey() returns an iterator over all historical values and transaction IDs for the specified key. Question 9. Private Data Collections (PDC) are primarily used to: A) Increase transaction throughput. B) Store large binary files on the ledger. C) Keep sensitive data off the public world state while still allowing endorsement. D) Replace the need for channels. Answer: C Explanation: PDCs store data on a subset of peers, keeping it private from other orgs while still participating in endorsement and validation. Question 10. In attribute-based access control (ABAC), which library provides functions to retrieve client attributes from their X.509 certificate? A) crypto-suite B) fabric-ca-client C) client-identity (cid) D) msp-client Answer: C Explanation: The cid library allows chaincode to access attributes (e.g., role, department) embedded in the clientâs certificate. Question 11. Which of the following is a non-deterministic operation that must be avoided in chaincode?
A) Reading a value from the ledger. B) Generating a UUID using a cryptographic library. C) Performing a deterministic hash of an input string. D) Serializing JSON consistently. Answer: B Explanation: Generating a UUID (or any random value) yields different results on each peer, breaking endorsement consistency. Question 12. The Fabric Gateway SDK simplifies application development by: A) Removing the need for TLS certificates. B) Providing a high-level API that abstracts endorsement, ordering, and commit handling. C) Automatically generating chaincode packages. D) Replacing the need for a connection profile. Answer: B Explanation: The Gateway SDK offers a unified interface for submitting/evaluating transactions, handling endorsements, ordering, and event listening. Question 13. In a connection profile (CCP), which top-level key defines the networkâs ordering service nodes? A) peers B) orderers C) certificateAuthorities D) client Answer: B
B) The transaction receipt from the orderer only. C) The transactionâs validation code in the block committed to the ledger. D) The chaincodeâs return value. Answer: C Explanation: The commit listener monitors the block events until the transaction is validated and written to the ledger, ensuring finality. Question 17. To listen for contract events emitted by chaincode, which SDK function is typically used? A) addContractListener() B) registerEvent() C) onEvent() D) listenForEvents() Answer: A Explanation: addContractListener() registers a callback for specific contract-level events defined in the chaincode. Question 18. What is the purpose of âstart blockâ checkpoints when implementing replay logic for missed events? A) To store the hash of the last processed transaction. B) To remember the block number from which to resume event subscription after a failure. C) To encrypt event payloads. D) To prune old events from the ledger. Answer: B
Explanation: A start-block checkpoint enables an application to restart listening from a known block height, ensuring no events are lost. Question 19. Which error typically indicates that the proposed transactionâs read-set no longer matches the current world state? A) Endorsement failure B) Timeout error C) MVCC conflict D) Invalid argument error Answer: C Explanation: MVCC (Multi-Version Concurrency Control) conflicts occur when the version of a key read during simulation has been changed before commit. Question 20. When packaging chaincode with the Peer CLI, which command creates the .tar.gz archive? A) peer lifecycle chaincode package B) peer chaincode install C) peer lifecycle chaincode install D) peer chaincode package Answer: A Explanation: The âpeer lifecycle chaincode packageâ command bundles the source code and metadata into a .tar.gz file for installation. Question 21. After installing a chaincode package on a peer, which identifier uniquely references that package for subsequent approval? A) Chaincode name
Question 24. When upgrading chaincode, which parameter must be incremented to allow the new definition to be committed? A) Version B) Sequence C) Endorsement policy D) Package ID Answer: B Explanation: The sequence number must increase with each definition change; the version string may also change but is not mandatory for the lifecycle. Question 25. Which component issues X.509 certificates to users, peers, and orderers in a Fabric network? A) MSP B) CA (Certificate Authority) C) TLS server D) Ledger Answer: B Explanation: The Fabric CA (or an external CA) generates and signs the X. identities used throughout the network. Question 26. In MSP configuration, the âadmincertsâ folder typically contains: A) The private keys of the organizationâs administrators. B) The TLS certificates for the orderer nodes. C) The X.509 certificates of the organizationâs admin identities.
D) The root CA certificates. Answer: C Explanation: âadmincertsâ holds the public certificates that identify the admin users for the organizationâs MSP. Question 27. Channels in Hyperledger Fabric provide: A) Consensus across the entire network. B) Data isolation so that only members of a channel can see its transactions. C) Automatic smart contract upgrades. D) Public ledger visibility. Answer: B Explanation: Channels create separate ledgers, ensuring that only organizations that have joined a channel can access its data. Question 28. What is the role of an anchor peer in a Fabric channel? A) To generate blocks for the orderer. B) To serve as a discovery point for other organizationsâ peers. C) To hold private data collections. D) To encrypt channel traffic. Answer: B Explanation: Anchor peers are designated peers that other orgs use to discover and communicate across the channel. Question 29. Which consensus mechanism is the default for the Fabric ordering service in recent releases?
Explanation: The âtest-networkâ example ships with the Fabric samples and can be launched via Docker-compose for functional tests. Question 32. To view chaincode logs when running in a Docker container, which command is appropriate? A) docker logs B) peer chaincode logs C) kubectl logs D) fabricctl logs --chaincode Answer: A Explanation: Chaincode runs in its own Docker container; âdocker logsâ fetches its stdout/stderr. Question 33. An MVCC conflict most commonly occurs when: A) Two transactions try to write to the same key in the same block. B) A transaction reads a key, and another transaction updates that key before the first commits. C) The endorsement policy is not satisfied. D) The orderer fails to deliver the block. Answer: B Explanation: The conflict arises because the version read during simulation no longer matches the ledgerâs current version at commit time. Question 34. Hyperledger Caliper is primarily used for: A) Deploying chaincode to the network. B) Measuring performance metrics such as throughput and latency of Fabric.
C) Generating connection profiles automatically. D) Managing MSP certificates. Answer: B Explanation: Caliper is a benchmark framework that runs workloads against Fabric and reports performance statistics. Question 35. Which of the following is NOT a valid reason to use a Private Data Collection? A) To keep personal data compliant with GDPR. B) To reduce the size of the public world state. C) To enable faster transaction endorsement. D) To share data only with a subset of organizations. Answer: C Explanation: Private data does not inherently speed up endorsement; it mainly provides confidentiality and can reduce public state size. Question 36. In chaincode, which function retrieves the clientâs MSP ID? A) GetMSPID() B) GetClientIdentity() C) GetCreator() D) GetMSPID() from client identity library Answer: D Explanation: Using the cid library, the function cid.GetMSPID(stub) returns the MSP ID of the invoking client.
Answer: B Explanation: âtlsCACertsâ points to the PEM-encoded root CA that signed the peerâs TLS certificate, enabling secure TLS handshake. Question 40. Which wallet implementation is best suited for production environments requiring persistence across restarts? A) InMemoryWallet B) FileSystemWallet C) NullWallet D) TemporaryWallet Answer: B Explanation: FileSystemWallet stores identities on disk, ensuring they survive application restarts. Question 41. What does the âsubmitTransactionâ method return after a successful transaction commit? A) The transaction ID only. B) The raw block data. C) The response payload returned by the chaincode function. D) A boolean indicating success. Answer: C Explanation: submitTransaction resolves with the byte array that the chaincodeâs transaction function returned. Question 42. Which event type provides information about every new block added to the ledger?
A) ContractEvent B) BlockEvent C) TransactionEvent D) ChaincodeEvent Answer: B Explanation: BlockEvent listeners receive notifications for each newly committed block. Question 43. In the Fabric lifecycle, what does the âsequenceâ number represent? A) The order in which peers endorse a transaction. B) A monotonically increasing counter for chaincode definition updates. C) The version string of the chaincode. D) The number of organizations that have approved the definition. Answer: B Explanation: Sequence is incremented each time a chaincode definition is changed, ensuring the network can detect newer definitions. Question 44. Which of the following is a valid reason for a transaction to be marked as âENDORSEMENT_POLICY_FAILUREâ during validation? A) The transactionâs read-set version is stale. B) The transactionâs proposer is not a member of the channel. C) The endorsements collected do not satisfy the defined endorsement policy. D) The orderer could not deliver the block. Answer: C
C) It is ignored; only successful returns are sent. D) As a block event with an error flag. Answer: B Explanation: Errors thrown during proposal simulation are returned in the proposal response; the SDK surfaces them immediately. Question 48. Which of the following best describes the purpose of the âtransient mapâ in a transaction proposal? A) To store permanent key-value pairs in the ledger. B) To provide temporary data that is not written to the ledger but can be used by chaincode. C) To configure TLS settings for the peer. D) To specify endorsement policies. Answer: B Explanation: The transient map carries sensitive data that chaincode can read but is omitted from the transactionâs read/write sets. Question 49. In the context of chaincode, what is a âcomposite keyâ? A) A key that combines multiple attributes to enable range queries. B) A key that is encrypted with a composite cipher. C) A key that references another key in the ledger. D) A key that is automatically generated by the Fabric runtime. Answer: A Explanation: Composite keys are created from multiple attribute values, allowing efficient queries and organization of related assets.
Question 50. Which of the following is a correct way to create a composite key in Go chaincode? A) stub.CreateCompositeKey("asset", []string{owner, assetID}) B) stub.NewCompositeKey("asset", owner, assetID) C) stub.GetCompositeKey("asset", owner, assetID) D) stub.SetCompositeKey("asset", []string{owner, assetID}) Answer: A Explanation: CreateCompositeKey(objectType, attributes) returns the composite key string. Question 51. What does the âqueryResultâ iterator returned by GetQueryResult() provide? A) Only the keys that match the query. B) The full key-value pairs of documents matching the CouchDB selector. C) The transaction IDs of matching writes. D) The history of each matching key. Answer: B Explanation: GetQueryResult returns an iterator over the full key-value records that satisfy the rich query. Question 52. Which of the following is NOT a valid endorsement policy syntax element? A) âANDâ B) âORâ C) âNOTâ