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("org.trustweave:did-plugins-sol:0.6.0")implementation("org.trustweave:did-did-core:0.6.0")implementation("org.trustweave:did-plugins-base:0.6.0")implementation("org.trustweave:anchors-anchor-core:0.6.0")implementation("org.trustweave:common:0.6.0")// 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
importorg.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...
Resolving a did:sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
importorg.trustweave.did.identifiers.Didimportorg.trustweave.did.resolver.DidResolutionResultvaldid=Did("did:sol:7xK...")valresult=method.resolveDid(did)when(result){isDidResolutionResult.Success->{println("Resolved: ${result.document.id}")println("Verification methods: ${result.document.verificationMethod.size}")}isDidResolutionResult.Failure.NotFound->{println("DID not found: ${result.did.value}")}else->println("Resolution failed")}
importorg.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