Writing Consented Data
Understand how, after consent is given, new credentials or data can be provided to a user or recorded about them by authorized parties (like contract owners or automated systems). This covers the rules and methods for data delivery based on established consent.
The send Method with Contract Integration (Recommended)
send Method with Contract Integration (Recommended)The simplest way to write credentials while respecting consent flows is using the send method with a contractUri. This method automatically routes through consent terms when the recipient has consented.
const result = await learnCard.invoke.send({
type: 'boost',
recipient: 'recipient-profile-id',
templateUri: 'urn:lc:boost:abc123',
contractUri: 'urn:lc:contract:xyz789', // Optional: routes via consent if applicable
});When you provide a contractUri:
Automatic routing: If the recipient has consented to the contract, the credential routes through the consent flow
Boost-contract relationship: When creating a new boost on-the-fly, a
RELATED_TOrelationship is established between the boost and the contractPermission verification: The system verifies you have permission to write in the credential's category
Fallback behavior: If the recipient hasn't consented to the contract, the credential is still sent normally—the contract integration is additive, not blocking.
For more details on the send method, see the Send Credentials How-To Guide.
Writing Credentials to Contracts (Direct)
For more granular control, contract owners can write credentials directly to profiles that have consented using:
writeCredentialToContract: Direct credential writingwriteCredentialToContractViaSigningAuthority: Using a signing authority
The system verifies:
The recipient has consented to the contract
The contract owner has permission to issue the boost
The contract terms allow writing in the boost's category
Credential Syncing
Consented users can sync their existing credentials to a contract using syncCredentialsToContract.
Credential syncing allows:
Sharing existing credentials with contract owners
Organizing credentials by categories defined in the contract
Controlling exactly which credentials are shared
The sync process:
Verify the terms exist and belong to the requesting user
Ensure terms are still live (not withdrawn or expired)
Update the terms by adding the synced credentials to the shared arrays
Create a 'sync' transaction with the categorized credentials
Notify the contract owner
Last updated
Was this helpful?