# Commercio Doc Helper
Commercio Doc Helper allows to easily create a Commercio Doc.
# Provide Operations
- Creates a - CommercioDocfrom the given- wallet, the list of recipients- recipients, an unique document- id(UUID v4 format) and document- metadata. Optionally- contentUri,- checksum,- doSign,- encryptedData,- aesKeycan be provided. If- doSignis provided then also the- checksumfield is required.- suspend fun fromWallet( id: String, metadata: CommercioDoc.Metadata, recipients: List<Did>, wallet: Wallet, doSign: CommercioDoc.CommercioDoSign? = null, checksum: CommercioDoc.Checksum? = null, aesKey: SecretKey = KeysHelper.generateAesKey(), encryptedData: List<EncryptedData> = listOf(), contentUri: String = "" ): CommercioDoc1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
# Usage examples
   // Configure the blockchain network
   val info = NetworkInfo(
       bech32Hrp = "did:com:",
       lcdUrl = "http://localhost:1317"
   )
   // Derive the sender wallet from her mnemonics
   val userMnemonic = listOf(
       "will",
       "hard",
       "topic",
       "spray",
       "beyond",
       "ostrich",
       "moral",
       "morning",
       "gas",
       "loyal",
       "couch",
       "horn",
       "boss",
       "across",
       "age",
       "post",
       "october",
       "blur",
       "piece",
       "wheel",
       "film",
       "notable",
       "word",
       "man"
   )
   val senderWallet = Wallet.derive(mnemonic = userMnemonic, networkInfo = info)
   
   // Get the recipient(s) wallet address
   val docRecipientDid = Did("did:com:14ttg3eyu88jda8udvxpwjl2pwxemh72w0grsau")
   
   // Generate a random UUID (or use a meaningful one)
   val docId = UUID.randomUUID().toString()
   
   // URI location of the shared document
   val contentUri = "https://example.com/document"
   
   // Let's assume that we want to encrypt the CONTENT_URI field to hide the document location in the resulting transaction
   val encryptedData = listOf(EncryptedData.CONTENT_URI)
   
   // Let's assume that we have computed the document checksum in SHA256
   val checksum = CommercioDoc.Checksum(
       value = "a00ab326fc8a3dd93ec84f7e7773ac2499b381c4833e53110107f21c3b90509c",
       algorithm = CommercioDoc.Checksum.Algorithm.SHA256
   )
   
   // Let's assume that we want to digitally sign
   val doSign = CommercioDoc.CommercioDoSign(
       storageUri = "http://www.commercio.network",
       signerIstance = "did:com:1cc65t29yuwuc32ep2h9uqhnwrregfq230lf2rj",
       sdnData = listOf(
           CommercioDoc.CommercioDoSign.CommercioSdnData.COMMON_NAME,
           CommercioDoc.CommercioDoSign.CommercioSdnData.SURNAME
       ),
       vcrId = "xxxxx",
       certificateProfile = "xxxxx"
   )
   
   val metadata = CommercioDoc.Metadata(
       contentUri = "https://example.com/document/metadata",
       schema = CommercioDoc.Metadata.Schema(
           uri = "https://example.com/custom/metadata/schema",
           version = "1.0.0"
       )
   )
   
   try {
       val commercioDoc = CommercioDocHelper.fromWallet(
           id = docId,
           recipients = listOf(docRecipientDid),
           wallet = senderWallet,
           doSign = doSign,
           checksum = checksum,
           encryptedData = encryptedData,
           contentUri = "https://example.com/document",
           metadata = metadata
       )
   
       // Send the derived CommercioDoc to the blockchain
       val txResult = DocsHelper.shareDocumentsList(
           listOf(commercioDoc),
           senderWallet
       )
   
   } catch (e: Exception) {
       throw e
   }
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94