This guide covers the Ethereum mainnet blockchain anchor client integration for TrustWeave. The Ethereum adapter provides production-ready anchoring for Ethereum mainnet and Sepolia testnet.
Overview
The chains/plugins/ethereum module provides a complete implementation of TrustWeave’s BlockchainAnchorClient interface using Ethereum mainnet. This integration enables you to:
Anchor credential digests on Ethereum mainnet
Support Sepolia testnet for development and testing
Use EVM-compatible transaction data storage
Leverage Ethereum’s security and decentralization
Installation
Add the Ethereum adapter module to your dependencies:
1
2
3
4
5
6
7
8
9
dependencies{implementation("org.trustweave:anchors-plugins-ethereum:0.6.0")implementation("org.trustweave:anchors-anchor-core:0.6.0")implementation("org.trustweave:common:0.6.0")implementation("org.trustweave:distribution-all:0.6.0")// Web3j for Ethereum blockchainimplementation("org.web3j:core:5.0.1")}
Configuration
Basic Configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
importorg.trustweave.anchor.*importorg.trustweave.anchor.ethereum.*// Create Ethereum anchor client for mainnetvaloptions=mapOf("rpcUrl"to"https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY","privateKey"to"0x..."// Optional: for signing transactions)valclient=EthereumBlockchainAnchorClient(EthereumBlockchainAnchorClient.MAINNET,options)
importorg.trustweave.anchor.ethereum.*// Auto-discover and register (returns EthereumIntegrationResult with registry + registeredChains)valresult=EthereumIntegration.discoverAndRegister(options=mapOf("rpcUrl"to"https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"))// Or manually setup specific chainsvalsetup=EthereumIntegration.setup(chainIds=listOf(EthereumBlockchainAnchorClient.SEPOLIA),options=mapOf("rpcUrl"to"https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY"))
importorg.trustweave.anchor.*importorg.trustweave.anchor.ethereum.*importkotlinx.serialization.json.*importorg.trustweave.core.json.jsonDatavalclient=EthereumBlockchainAnchorClient(EthereumBlockchainAnchorClient.SEPOLIA,mapOf("rpcUrl"to"https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY","privateKey"to"0x..."))// Anchor a JSON payloadvalpayload=jsonData{"digest"to"uABC123...""timestamp"toSystem.currentTimeMillis()}valresult=client.writePayload(payload,"application/json")println("Anchored to: ${result.ref.txHash}")
Reading Anchored Data
1
2
3
// Read anchored data — readPayload takes the AnchorRef returned by writePayloadvalreadResult=client.readPayload(result.ref)println("Retrieved: ${readResult.payload}")