Edit: while my old answer worked, it only was a workaround and complete bs.. the following should be the correct way of creating credential schema, credential definition and revocation registry definition.
// Create Credential Schema
String name = "schema_name";
String schemaAttrs = new JSONArray().put("name").put("age").toString();
AnoncredsResults.IssuerCreateSchemaResult schema =
Anoncreds.issuerCreateSchema(verinym, name, "1.0", schemaAttrs).get();
String schemaId = schema.getSchemaId();
String schemaJson = schema.getSchemaJson();
JSONObject schemaRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildSchemaRequest(verinym, schemaJson).get()
).get());
int schemaSeqNo = schemaRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
schemaJson = new JSONObject(schemaJson).put("seqNo", schemaSeqNo).toString();
// Create Credential Definition
AnoncredsResults.IssuerCreateAndStoreCredentialDefResult credDef =
Anoncreds.issuerCreateAndStoreCredentialDef(
wallet, verinym, schemaJson, "tag", null,
new JSONObject().put("support_revocation", true).toString()
).get();
// creating credDef req and sending it to the ledger
JSONObject credDefRes = new JSONObject(
Ledger.signAndSubmitRequest(
PoolUtils.getInstance(), wallet, verinym,
Ledger.buildCredDefRequest(verinym, credDef.getCredDefJson()).get()
).get()
);
int credSeqNo = credDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
// Create Revocation Registry Definition
String tailsWriterConfig = new JSONObject().put("base_dir", "/tmp/indy_tails").put("uri_pattern", "").toString();
BlobStorageWriter tails = BlobStorageWriter.openWriter("default", tailsWriterConfig).get();
AnoncredsResults.IssuerCreateAndStoreRevocRegResult revocRegDef = Anoncreds.issuerCreateAndStoreRevocReg(
wallet, verinym, null, "contractDef", credDefId,
"{}", tails
).get();
JSONObject revocRegDefRes = new JSONObject(
Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegDefRequest(verinym, revocRegDef.getRevRegDefJson()).get()
).get());
revocRegDefSeqNo = revocRegDefRes.getJSONObject("result").getJSONObject("txnMetadata").getInt("seqNo");
The learning is that the ledger returns important values for the creation of definition
Furthermore, nowhere was mentioned that you need to create an initial revocation registry entry:
// Create initial revocation entry
JSONObject revocRegEntryRes = new JSONObject(Ledger.signAndSubmitRequest(PoolUtils.getInstance(), wallet, verinym,
Ledger.buildRevocRegEntryRequest(verinym, revocRegDef.getRevRegId(),
"CL_ACCUM", revocRegDef.getRevRegEntryJson()).get()).get());