Duty
Represents a single obligation that must be fulfilled.
Duties are obligations that must be satisfied to exercise a 'permit' rule. They define what the user must do or provide in exchange for permission. Duties can only be attached to 'permit' rules, not 'prohibit' rules.
Per the PD-REL v1.0 specification: "An obligation that must be fulfilled by the assignee as a condition of exercising a permit Rule. Duties define the 'must' conditions of a policy (e.g., 'must pay a fee,' 'must attribute the creator')."
Examples
// Payment duty requiring a one-time fee
const paymentDuty: Duty = {
type: 'PAYMENT',
value: {
amount: '10.00',
currency: 'USD',
recipient: '0xABC123...'
}
};
// Royalty duty for downstream usage
const royaltyDuty: Duty = {
type: 'ROYALTY',
value: {
basisPoints: 250, // 2.5%
recipient: '0xDEF456...'
}
};
// Attribution duty requiring credit
const attributionDuty: Duty = {
type: 'ATTRIBUTION',
value: 'Original artwork by Jane Doe, licensed under PD-REL'
};
// Custom duty using a URI
const customDuty: Duty = {
type: 'https://example.com/duties/carbon-offset',
value: {
tons: 0.5,
provider: 'GreenCredits Inc.'
}
};
Definition
interface Duty {
/**
* The type of duty, from the core vocabulary or a custom URI. Use predefined types from DutyType for standard obligations, or provide a fully-qualified URI for custom duty types.
*/
type: string;
/**
* The value of the duty, which can be a primitive or an object. The structure of the value depends on the duty type: - PAYMENT: `{ amount: string, currency: string, recipient: string }` - ROYALTY: `{ basisPoints: number, recipient: string }` - ATTRIBUTION: `string` (attribution text) - SHARE_ALIKE: `string` (policy URI) or object with policy details - Custom types: Any valid JSON value
*/
value: any;
}
Properties
type
The type of duty, from the core vocabulary or a custom URI.
Use predefined types from DutyType for standard obligations, or provide a fully-qualified URI for custom duty types.
Type: string
Examples
type: 'PAYMENT' // Predefined type
type: 'https://myorg.com/duties/environmental-report' // Custom URI
value
The value of the duty, which can be a primitive or an object.
The structure of the value depends on the duty type:
- PAYMENT:
{ amount: string, currency: string, recipient: string } - ROYALTY:
{ basisPoints: number, recipient: string } - ATTRIBUTION:
string(attribution text) - SHARE_ALIKE:
string(policy URI) or object with policy details - Custom types: Any valid JSON value
Type: any
See Also
-
- DutyType for predefined duty types
- Rule for how duties are attached to permit rules
- RuleBuilder.withDuty for adding duties to rules
Since
Version 1.0.0