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("com.trustweave.chains:ethereum:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-anchor:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-json:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-core:1.0.0-SNAPSHOT")// 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
importcom.trustweave.anchor.*importcom.trustweave.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)
importcom.trustweave.ethereum.*// Auto-discover and registervalresult=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"))
importcom.trustweave.anchor.*importcom.trustweave.ethereum.*importkotlinx.serialization.json.*valclient=EthereumBlockchainAnchorClient(EthereumBlockchainAnchorClient.SEPOLIA,mapOf("rpcUrl"to"https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY","privateKey"to"0x..."))// Anchor a JSON payloadvalpayload=buildJsonObject{put("digest","uABC123...")put("timestamp",System.currentTimeMillis())}valresult=client.writePayload(payload,"application/json")println("Anchored to: ${result.ref.txHash}")