telos docs
Search…
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_name
content
sectiona
Text here
sectionb
More text here
sectionc
A 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 Name
Type
Example
Description
title
string
"Doc1"
The title of the document
subtitle
string
"A small example document"
The subtitle of the document
document_name
name
doc1
The name identifier for the document
author
name
testaccount1
The telos account of the author
initial_sections
map<name, string>
{ sectiona : "Text here", sectionb: "More text here", sectionc: "A little more text" } ...
The document broken down into a mapping of section names to section content.
Cleos
eosjs
1
cleos push action amend.decide newdocument '{ ... }' -p author
Copied!
1
(async () => {
2
const result = await api.transact({
3
actions: [{
4
account: 'amend.decide',
5
name: 'newdocument',
6
authorization: [{
7
actor: '...',
8
permission: 'active',
9
}],
10
data: {
11
title: 'Doc1',
12
subtitle: 'A small example document',
13
document_name: 'doc1',
14
author: 'testaccount1',
15
initial_sections: [
16
{
17
"key": "sectiona",
18
"value": "Text here"
19
},
20
{
21
"key": "sectionb",
22
"value": "More text here"
23
},
24
{
25
"key": "sectionc",
26
"value": "A little more text"
27
}
28
]
29
},
30
}]
31
}, {
32
blocksBehind: 3,
33
expireSeconds: 30,
34
});
35
console.dir(result);
36
})();
Copied!

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 Name
Type
Example
Description
document_name
name
doc1
The name of the document header to edit.
new_title
string
"New Title"
The new document title.
new_subtitle
string
"New Subtitle"
The new document subtitle.
Cleos
eosjs
1
cleos push action amend.decide editheader '{ ... }' -p author
Copied!
1
(async () => {
2
const result = await api.transact({
3
actions: [{
4
account: 'amend.decide',
5
name: 'editheader',
6
authorization: [{
7
actor: '...',
8
permission: 'active',
9
}],
10
data: {
11
document_name: 'doc1',
12
new_title: 'New Title',
13
new_subtitle: 'New Subtitle'
14
},
15
}]
16
}, {
17
blocksBehind: 3,
18
expireSeconds: 30,
19
});
20
console.dir(result);
21
})();
Copied!

Changing Authors

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

ACTION updateauthor

Parameter Name
Type
Example
Description
document_name
name
doc1
The name of the document to change the author for.
new_author
name
newauthor1
The name of the Telos account of the new author.
Cleos
eosjs
1
cleos push action amend.decide updateauthor '{ ... }' -p author
Copied!
1
(async () => {
2
const result = await api.transact({
3
actions: [{
4
account: 'amend.decide',
5
name: 'updateauthor',
6
authorization: [{
7
actor: '...',
8
permission: 'active',
9
}],
10
data: {
11
document_name: 'doc1',
12
new_author: 'newauthor1'
13
},
14
}]
15
}, {
16
blocksBehind: 3,
17
expireSeconds: 30,
18
});
19
console.dir(result);
20
})();
Copied!

Last modified 1yr ago