Skip to main content
Terms of use are stored against the market’s contract address, not against an instance. Every instance that holds the market reads the same document, including the instance that deployed it. Saving is a database write, not a transaction: nothing is signed and nothing goes on chain, so none of these methods takes a signer.
Nothing on chain enforces terms of use. A market without published terms still lends: loan builds there carry a TERMS_NOT_PUBLISHED warning, and the decision to stop is yours. Check for published terms before you offer a borrow.

Publish terms

Authority is read from the chain at the moment of the save. One of your instance’s verified wallets must be the lender of record recorded on the factory, or hold the market’s admin or issuer role. Before a lender of record takes the market nobody qualifies, and every save is refused with NOT_CURATOR.
content is markdown, stored as written apart from Windows line endings, which become \n. The SDK refuses content over 262,144 bytes of UTF-8 and control characters other than tab, newline and carriage return before any request. title takes at most 200 characters. Every save that changes something writes a new version and keeps the old ones. A save identical to the current record writes nothing and answers changed: false. authority on the result says which role the save was made under. To bind a template from your instance’s terms library instead, send templateId. The template’s current version is saved and content is ignored. Only the instance that authored a template can bind it, and an archived template is refused with TEMPLATE_ARCHIVED.

Stage a draft

published: false saves a draft. While published terms exist, the draft is staged beside them as the next version, and the published terms stay what borrowers are shown. The result then carries draft: true, the liveVersion still served, and a notice. Publish a version with a later save that sends published: true.
A draft is not private to your instance. Every instance that holds the market can list it with versions and read it with version, because terms are stored against the market’s address.

Show terms to a borrower

get returns the published terms only, as markdown (the default, with content and plainText) or html. A market without published terms answers TERMS_NOT_PUBLISHED, which is a 404 that means “no terms to show”, not a missing market.
version and contentHash identify exactly which text was shown. binding reports whether the terms follow a template from the library and whether that template has a newer version since.

Read every version

versions lists the history newest first, without the document bodies. current is the live version, or null when the terms are offline. limit runs from 1 to 100 and defaults to 25.
version returns one saved version in full, whether or not it was published and whether or not the terms are live today. Each entry in versions keeps published as the record of how it was saved, and live marks the one served now.

Take terms offline

Nothing is deleted. The text stays stored, every version stays readable, and no new version is written. From then on get answers TERMS_NOT_PUBLISHED for every instance, and loan builds on the market carry the warning. A later save with published: true puts the terms back online as a new version. The same authority check as for saving applies.

Export a copy for the record

An instance that can author the terms exports its current record even when it is a draft or offline. The PDF then still prints a Published line, filled from the last write. Before filing such an export as the published text, check that get returns the same contentHash.
export returns the file itself: bytes, its contentType and the filename the API suggests. format is pdf (the default), text or markdown. The SDK allows the call up to two minutes.
The PDF header carries the market and collateral token addresses, the version and the content hash, so a printed copy can be checked against the API. Its eligibility lines are read live from the market. When the market’s registers cannot be read, no PDF is produced and the call answers IDENTITY_GATES_UNREADABLE, a 503 worth retrying. The text and markdown formats do not read them. The Lender of record line prints the wallet that saved the version. That can be a wallet holding the market’s admin or issuer role rather than the lender of record’s own.

Terms library

Available from @trusset/sdk 0.7.0.
The terms library keeps your instance’s terms of use as templates: written once, bound to many markets with save and templateId, and published at adoption by a standing policy. Any key of the instance can read the library. Writing it needs an account Trusset approved as a lender of record, which canAuthor reports. Any other account is refused with CURATOR_NOT_APPROVED.
templates leaves archived templates out unless includeArchived is true, and returns no text. template returns one in full: content, the versions newest first (at most 100, without their text) and the markets bound to it, each with its binding status.

Write templates

title takes 1 to 200 characters. content follows the rules of save: the SDK refuses content over 262,144 bytes of UTF-8, blank content and control characters other than tab, newline and carriage return before any request. updateTemplate needs at least one of title, content and archived. A change to the title or the text writes a new template version and answers changed: true. Markets bound to the template keep the version they published until they are bound again with save and the same templateId. Until then their binding reads TEMPLATE_OUTDATED.

Archive a template

archiveTemplate archives a template, and updateTemplate with archived: false restores it. Archiving writes no version, so changed is false. An archived template stays readable and cannot be bound any more.
A template still bound to a published, non-customised market, or to any standing policy whether switched on or off, cannot be archived: the call answers TEMPLATE_IN_USE, and details names the markets and policies. Bind those markets to another template, or customise their terms, and bind those policies to another template or to none with policies.update, then archive again. See Archive Terms Template.

Methods and endpoints