Indy VDR
Hyperledger Indy VDR, Verifiable Data Registry, can be used to connect to one or more Indy Node ledger pools given sets of genesis transactions. Methods are provided to construct ledger requests and send them to the validators, collecting the results and ensuring that there is a consensus between the nodes. In the context of Credo, we mainly leverage it to register, and resolve, schemas, credential definitions and DIDs.
Installing Indy VDR
When using Credo with Indy VDR, there are a few extra dependencies that need to be installed. We need to install the @hyperledger/indy-vdr
, which contains all the functionality to register objects on an Hyperledger Indy VDR. Secondly, we need to add native bindings for the specific platform @hyperledger/indy-vdr-<platform>
. Currently there are bindings for Node.js, as @hyperledger/indy-vdr-nodejs
, and React Native as @hyperlegder/indy-vdr-react-native
.
- Node.js
- React Native
yarn add @credo-ts/indy-vdr@^0.5.3 @hyperledger/indy-vdr-nodejs@^0.2.2
yarn add @credo-ts/indy-vdr@^0.5.3 @hyperledger/indy-vdr-react-native@^0.2.2
Adding Indy VDR to the agent
After installing the dependencies, we can register the Indy VDR module on the agent.
- Node.js
- React Native
import { Agent } from '@credo-ts/core'
import { agentDependencies } from '@credo-ts/node'
import { AskarModule } from '@credo-ts/askar'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@credo-ts/indy-vdr'
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'
import { AnonCredsModule } from '@credo-ts/anoncreds'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
const agent = new Agent({
config,
dependencies: agentDependencies,
modules: {
indyVdr: new IndyVdrModule({
indyVdr,
networks: [
{
isProduction: false,
indyNamespace: 'bcovrin:test',
genesisTransactions: '<genesis_transactions>',
connectOnStartup: true,
},
],
}),
anoncreds: new AnonCredsModule({
registries: [new IndyVdrAnonCredsRegistry()],
anoncreds,
}),
// Indy VDR can optionally be used with Askar as wallet and storage implementation
askar: new AskarModule({
ariesAskar,
}),
},
})
import { Agent } from '@credo-ts/core'
import { agentDependencies } from '@credo-ts/react-native'
import { AskarModule } from '@credo-ts/askar'
import { ariesAskar } from '@hyperledger/aries-askar-react-native'
import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@credo-ts/indy-vdr'
import { indyVdr } from '@hyperledger/indy-vdr-react-native'
import { AnonCredsModule } from '@credo-ts/anoncreds'
import { anoncreds } from '@hyperledger/anoncreds-react-native'
const agent = new Agent({
config,
dependencies: agentDependencies,
modules: {
indyVdr: new IndyVdrModule({
indyVdr,
networks: [
{
isProduction: false,
indyNamespace: 'bcovrin:test',
genesisTransactions: '<genesis_transactions>',
connectOnStartup: true,
},
],
}),
anoncreds: new AnonCredsModule({
registries: [new IndyVdrAnonCredsRegistry()],
anoncreds,
}),
// Indy VDR can optionally be used with Askar as wallet and storage implementation
askar: new AskarModule({
ariesAskar,
}),
},
})
Configuration
As you can see below, the Indy VDR module takes the native bindings and a list of networks. This list of networks will be used to resolve and register objects on.
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'
import { IndyVdrModule } from '@credo-ts/indy-vdr'
const modules = {
indyVdr: new IndyVdrModule({
indyVdr,
networks: [
{
indyNamespace: 'bcovrin:test',
isProduction: false,
genesisTransactions: '<genesis_transactions>',
connectOnStartup: true,
},
],
}),
}
indyVdr
Type: IndyVdr
the indyVdr
key takes a class that implements all the native bindings for Indy VDR. This can be imoprted from the @hyperledger/indy-vdr-nodejs
package or the @hyperledger/indy-vdr-react-native
package.
networks
Type: IndyVdrPoolConfig[]
An array of indy networks to connect to. The list can contain the following object and it must genesisTransactions
.
indyNamespace
Type: string
The Indy namespace aka the name identifying the name of the network connecting to. See also indy did method identifiers
isProduction
Type: boolean
Whether the ledger is a production ledger. This is used for detecting which ledger to use in case of unqualified identifiers as production ledgers have priority.
genesisTransactions
Type: string
Stringified JSON object of the transaction.
connectOnStartup
Type: boolean
Whether to connect to the ledger on startup. Defaults to false
.
transactionAuthorAgreement
Type: TransactionAuthorAgreement
JSON representation specifying the version and acceptance mechanism. The version is the unique version of the transaction author agreement acceptance mechanism list (AML). The acceptance mechanism refers to the acceptance mechanism label of the item in the AML. For more details you may consult the indy-node docs on AML
transactionAuthorAgreement.version
Type: string
The version of the AML acceptance mechanism. This is a string representation of a version number e.g. '1' or '1.4'
transactionAuthorAgreement.acceptanceMechanism
Type: string
The acceptance mechanism to choose. This must be one of the available labels of the acceptance mechanisms key-value pairs in the AML e.g. 'EULA'.