The attachment is referenced in building a transaction:
val txBuilder = TransactionBuilder(notary)
.addOutputState(agreementState, AGREEMENT_CONTRACT_ID)
.addCommand(agreeCmd, agreeCmdRequiredSigners)
.addAttachment(untrustedPartiesAttachment)
Once it is added to the transaction, it can be referenced within the contract:
val attachmentJar = attachment.openAsJAR()
while (attachmentJar.nextEntry.name != "blacklist.txt") {
// Calling `attachmentJar.nextEntry` causes us to scroll through the JAR.
}
val blacklistedCompanies = mutableListOf<String>()
val bufferedReader = attachmentJar.bufferedReader()
var company = bufferedReader.readLine()
while (company != null) {
blacklistedCompanies.add(company)
company = bufferedReader.readLine()
}
You could also extend the client to download the attachment via RPC. See the downloadAttachment method.