Skip to main content

Create a Document

Create a New Document

Documents are broken down into named sections which hold the contents of the document. Sections can be raw text, IPFS links, API links, or any combination thereof. A document can be roughly visualized with the layout below:

Document Title

Document Subtitle

section_namecontent
sectionaText here
sectionbMore text here
sectioncA little more text

To begin, the document author must call the newdocument action on the amend.decide contract.

ACTION newdocument

Fee: 50.000 TLOS

Parameter NameTypeExampleDescription
titlestring"Doc1"The title of the document
subtitlestring"A small example document"The subtitle of the document
document_namenamedoc1The name identifier for the document
authornametestaccount1The telos account of the author
initial_sectionsmap<name, string>{sectiona: "Text here", sectionb: "More text here", sectionc: "A little more text"} ...The document is broken down into a mapping of section names to section content.
cleos push action amend.decide newdocument '{ ... }' -p author
(async () => {
const result = await api.transact({
actions: [{
account: 'amend.decide',
name: 'newdocument',
authorization: [{
actor: '...',
permission: 'active',
}],
data: {
title: 'Doc1',
subtitle: 'A small example document',
document_name: 'doc1',
author: 'testaccount1',
initial_sections: [
{
"key": "sectiona",
"value": "Text here"
},
{
"key": "sectionb",
"value": "More text here"
},
{
"key": "sectionc",
"value": "A little more text"
}
]
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.dir(result);
})();

Editing Title and Subtitle

At any time, the author may alter the document title or the subtitle. To do so, the author must call the editheader action on the amend.decide contract. To leave a title or subtitle the same, simply copy the existing text into the appropriate parameter.

ACTION editheader

Parameter NameTypeExampleDescription
document_namenamedoc1The name of the document header to edit.
new_titlestring"New Title"The new document title.
new_subtitlestring"New Subtitle"The new document subtitle.
cleos push action amend.decide editheader '{ ... }' -p author
(async () => {
const result = await api.transact({
actions: [{
account: 'amend.decide',
name: 'editheader',
authorization: [{
actor: '...',
permission: 'active',
}],
data: {
document_name: 'doc1',
new_title: 'New Title',
new_subtitle: 'New Subtitle'
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.dir(result);
})();

Changing Authors

A document author may relinquish authorship to another account with the updateauthor action.

ACTION updateauthor

Parameter NameTypeExampleDescription
document_namenamedoc1The name of the document to change the author for.
new_authornamenewauthor1The name of the Telos account of the new author.
cleos push action amend.decide updateauthor '{ ... }' -p author
(async () => {
const result = await api.transact({
actions: [{
account: 'amend.decide',
name: 'updateauthor',
authorization: [{
actor: '...',
permission: 'active',
}],
data: {
document_name: 'doc1',
new_author: 'newauthor1'
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.dir(result);
})();