AbstractBlockchainAnchorClient
Abstract base class for blockchain anchor client implementations.
Provides common functionality shared across blockchain adapters:
Strictly opt-in in-memory test fallback (see OPTION_IN_MEMORY_TEST_MODE)
Common error handling patterns
AnchorRef construction helpers
Transaction hash generation utilities
Fail-closed behavior: when the client has no usable chain credentials/connection (canSubmitTransaction returns false) and inMemoryTestMode is not enabled, writePayload throws BlockchainException.ConfigurationFailed instead of fabricating a transaction hash. The in-memory fallback is ONLY active when the caller explicitly opts in via options["inMemoryTestMode"] = true — it is intended for tests and demos, never production: payloads are NOT anchored on any chain.
Subclasses should implement:
canSubmitTransaction: Check if credentials are available for real transactions
submitTransactionToBlockchain: Submit transaction to actual blockchain
readTransactionFromBlockchain: Read transaction from actual blockchain
getContractAddress: Get contract address from options (if applicable)
buildExtraMetadata: Build extra metadata for AnchorRef
generateTestTxHash: Generate test transaction hash for in-memory test mode
Functions
Estimate the native-token fee that an operation would cost on this chain. Plugins compute this from the chain's native API (eth_feeHistory, Algorand suggested params, Cardano protocol params, Bitcoin estimatesmartfee, …). The default returns TokenAmount.unknown for plugins that have not yet implemented the payment plane.
Reads a payload from the blockchain using an anchor reference.
Boolean verification. An anchor served from the in-memory test fallback is NOT chain evidence, so it only counts as verified when this client was explicitly constructed with inMemoryTestMode = true (tests/demos, where memory is the only store). A client without explicit test mode can never serve from memory, and a testMode-flagged result that reaches it anyway (foreign ref) yields false. Use verifyAnchorDetailed to see the testMode flag.
Same result as BlockchainAnchorClient.verifyAnchorDetailed; additionally calls onLegacyDigestAccepted, once per client instance, when a legacy (non-JCS) digest envelope was accepted (see OPTION_REQUIRE_CANONICAL_ENVELOPE).
Writes a payload to the blockchain and returns an anchor reference.
Payment-aware write. Plugins that opt into the payment plane override this; the default delegates to the legacy writePayload so existing implementations keep compiling.