Learn the intricacies of Fragment relationships
Fragment
is a contract that can be assigned to an Assignee
contract. The assignment and associated behaviors can be configured in a number of ways. Fragments assignments are referenced using the Patchwork-primitive type LiteRef
.
Type | Description |
---|---|
SingleAssignable | May be assigned to only one assignee at a time |
MultiAssignable | May be assigned to multiple assignees simultaneously |
SingleAssignable
fragment will exhibit the following behavior:
MultiAssignable
can be assigned to many different assignees. They do not change ownership based on behavior and have a different API to reflect their assignment model.
Example:
An emoji library is created as MultiAssignable. A “happy” emoji is assigned to thousands of different assignees. The “happy” emoji is always owned by the original content creator.
LiteRef
is a 64 bit value with a layout of:
PatchworkLiteRef
contract. The Reference Address ID is determined by a call to registerReferenceAddress(address addr)
on the Assignee as described in the workflow below. The token ID is the token ID of the fragment.
registerReferenceAddress(fragmentAddress)
Once registered, assignments should always be performed through PatchworkProtocol
. The protocol enforces data integrity between contracts and also tracks assignments that will be visible in the patchwork explorer.
Assignment functions:
literef
added to the metadata schema.
LiteRefs may be single values, static or dynamic arrays.
Static arrays are most useful when a contract needs to inspect and react to the entire composition of fragments.
Dynamic arrays are most useful when a large, unknown number of assignments will be made and there is no requirement for the contract to read all of the values in a single transaction.
allowAssignment()