This guide covers the did:sol method integration for TrustWeave. The did:sol plugin provides Solana DID resolution with account-based storage on Solana blockchain.
Overview
The did/plugins/sol module provides an implementation of TrustWeave’s DidMethod interface using the Solana blockchain. This integration enables you to:
Create and resolve DIDs on Solana blockchain
Store DID documents in Solana program accounts
Support Solana mainnet, devnet, and testnet
Use Ed25519 keys (native to Solana)
Fast, low-cost transactions on Solana
Installation
Add the did:sol module to your dependencies:
1
2
3
4
5
6
7
8
9
10
dependencies{implementation("com.trustweave.did:sol:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-did:1.0.0-SNAPSHOT")implementation("com.trustweave.did:base:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-anchor:1.0.0-SNAPSHOT")implementation("com.trustweave:trustweave-common:1.0.0-SNAPSHOT")// HTTP client for Solana RPCimplementation("com.squareup.okhttp3:okhttp:4.12.0")}
When the module is on the classpath, did:sol is automatically available:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
importcom.trustweave.did.*importjava.util.ServiceLoader// Discover did:sol providervalproviders=ServiceLoader.load(DidMethodProvider::class.java)valsolProvider=providers.find{it.supportedMethods.contains("sol")}// Create method with required optionsvaloptions=didCreationOptions{property("rpcUrl","https://api.devnet.solana.com")property("network","devnet")}valmethod=solProvider?.create("sol",options)
Usage Examples
Creating a did:sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
valconfig=SolDidConfig.devnet("https://api.devnet.solana.com")valanchorClient=InMemoryBlockchainAnchorClient("solana:devnet")valkms=InMemoryKeyManagementService()valmethod=SolDidMethod(kms,anchorClient,config)// Create DID (uses Ed25519 for Solana compatibility)valoptions=didCreationOptions{algorithm=KeyAlgorithm.ED25519purpose(KeyPurpose.AUTHENTICATION)purpose(KeyPurpose.ASSERTION)}valdocument=method.createDid(options)println("Created: ${document.id}")// did:sol:devnet:7xK... or did:sol:7xK...
importcom.trustweave.TrustWeaveimportcom.trustweave.soldid.*importcom.trustweave.anchor.*importcom.trustweave.testkit.anchor.InMemoryBlockchainAnchorClientvalconfig=SolDidConfig.devnet("https://api.devnet.solana.com")valanchorClient=InMemoryBlockchainAnchorClient("solana:devnet")valTrustWeave=TrustWeave.create{kms=InMemoryKeyManagementService()blockchains{register("solana:devnet",anchorClient)}didMethods{+SolDidMethod(kms!!,anchorClient,config)}}// Use did:solvaldid=TrustWeave.createDid("sol"){algorithm=KeyAlgorithm.ED25519}.getOrThrow()valresolved=TrustWeave.resolveDid(did.id).getOrThrow()
Error Handling
Common errors and solutions:
Error
Cause
Solution
rpcUrl is required
Missing RPC endpoint
Provide Solana RPC URL
did:sol requires Ed25519
Wrong algorithm
Use Ed25519 algorithm
DID document not found
Account not found
Create DID first or check address
Failed to get account data
RPC error
Check network connectivity and RPC URL
Testing
For testing without actual Solana:
1
2
3
4
5
6
7
8
9
importcom.trustweave.testkit.anchor.InMemoryBlockchainAnchorClientvalconfig=SolDidConfig.devnet("https://api.devnet.solana.com")valanchorClient=InMemoryBlockchainAnchorClient("solana:devnet")valmethod=SolDidMethod(kms,anchorClient,config)// Create and resolve (stored in memory)valdocument=method.createDid(options)valresult=method.resolveDid(document.id)
Best Practices
Use devnet for development: Solana devnet for testing
Ed25519 keys: Always use Ed25519 for Solana compatibility
Account management: Understand Solana account model
Transaction costs: Solana has very low transaction fees
Fast confirmations: Solana has fast block times (~400ms)
Solana RPC
This implementation uses Solana JSON-RPC API:
getAccountInfo: Retrieve account data containing DID document
sendTransaction: Submit transactions to update DID documents