-
Notifications
You must be signed in to change notification settings - Fork 5
/
document-submit.js
34 lines (28 loc) · 1.05 KB
/
document-submit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/submit-documents.html
const setupDashClient = require('../setupDashClient');
const client = setupDashClient();
const submitNoteDocument = async () => {
const { platform } = client;
const identity = await platform.identities.get(process.env.IDENTITY_ID); // Your identity ID
const docProperties = {
message: `Tutorial Test @ ${new Date().toUTCString()}`,
};
// Create the note document
const noteDocument = await platform.documents.create(
'tutorialContract.note',
identity,
docProperties,
);
const documentBatch = {
create: [noteDocument], // Document(s) to create
replace: [], // Document(s) to update
delete: [], // Document(s) to delete
};
// Sign and submit the document(s)
await platform.documents.broadcast(documentBatch, identity);
return noteDocument;
};
submitNoteDocument()
.then((d) => console.log(d.toJSON()))
.catch((e) => console.error('Something went wrong:\n', e))
.finally(() => client.disconnect());