For the complete documentation index, see llms.txt. This page is also available as Markdown.

Consent

The YieldFi SDK provides comprehensive APIs for managing user consent records. Consent records are immutable for audit compliance - once recorded, they cannot be deleted or revoked.

The SDK supports the following consent types:

  • TERMS_OF_SERVICE - User acceptance of terms of service (required)

  • PRIVACY_POLICY - User acceptance of privacy policy (required)

  • MARKETING - User consent for marketing communications (optional)

  • ANALYTICS - User consent for analytics tracking (optional)

  • COOKIES - User consent for cookie usage (optional)

Record user consent when they accept terms, policies, or opt-in to features:

import { YieldFiSDK, ConsentType } from "yieldfi-sdk";

const sdk = await YieldFiSDK.create({
  gatewayUrl: "https://gw.yield.fi",
});

const accessToken = localStorage.getItem("accessToken");

// Record terms of service acceptance
const consent = await sdk.auth.recordConsent(accessToken, {
  consentType: ConsentType.TERMS_OF_SERVICE,
  version: "1.0",
  granted: true,
  metadata: {
    documentHash: "0xabc123...",
    sourceUrl: "https://yield.fi/terms",
  },
});

console.log(`Consent recorded: ${consent.consent.id}`);

Get a specific consent record by type and optional version:

Get All User Consents

Get the complete audit trail of all consent records:

Get the latest status for each consent type:

Here's a complete example of implementing a consent flow:

Important Notes

  1. Immutability: Consent records cannot be deleted or revoked once created. This ensures audit compliance.

  2. Versioning: Each consent type can have multiple versions (e.g., Terms v1.0, v2.0). Always record consent for the current version.

  3. Audit Trail: All consent records include:

    • Timestamp

    • IP address

    • User agent

    • Metadata (document hash, source URL, etc.)

  4. Authentication Required: All consent APIs require a valid access token.

  5. Required Consents: Terms of Service and Privacy Policy are typically required before users can use the platform.

Next Steps

  • API Reference - Explore all available APIs

  • Examples - See complete examples

Last updated