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 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:

  1. Automatic routing: If the recipient has consented to the contract, the credential routes through the consent flow

  2. Boost-contract relationship: When creating a new boost on-the-fly, a RELATED_TO relationship is established between the boost and the contract

  3. Permission verification: The system verifies you have permission to write in the credential's category

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 writing

  • writeCredentialToContractViaSigningAuthority: Using a signing authority

The system verifies:

  1. The recipient has consented to the contract

  2. The contract owner has permission to issue the boost

  3. 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:

  1. Sharing existing credentials with contract owners

  2. Organizing credentials by categories defined in the contract

  3. Controlling exactly which credentials are shared

The sync process:

  1. Verify the terms exist and belong to the requesting user

  2. Ensure terms are still live (not withdrawn or expired)

  3. Update the terms by adding the synced credentials to the shared arrays

  4. Create a 'sync' transaction with the categorized credentials

  5. Notify the contract owner

Last updated

Was this helpful?