# 4.3 sendReceipt(1->1)

# Use cases

Creates a new transaction which tells the recipient that the document having the specified documentId and present inside the transaction with hash txHash has been properly seen.

proof optional proof of reading.

# Tools

The CommercioSDK, our own open source tool to format transactions to Commercio.network

# Functions and APIs

  • DocsHelper sendDocumentReceipt.

# Background

From Wikipedia:

A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes.

# Step by step sequence

  1. Share a document (Chapter 4.2);
  2. Save the transaction hash;
  3. Finally, execute the DocsHelper sendDocumentReceipt to send the receipt.

# Code Examples

Here's an example of the implemetation in all the available languages.

# Dart

final wallet = Wallet.derive(mnemonic, networkInfo);

final recipientWallet = Wallet.derive(recipientMnemonic, networkInfo);

final docRecipientDid = recipientWallet.bech32Address;

final docId = Uuid().v4();

final response = await DocsHelper.shareDocument(
  id: docId,
  contentUri: 'https://example.com/document',
  metadata: CommercioDocMetadata(
    contentUri: 'https://example.com/document/metadata',
    schema: CommercioDocMetadataSchema(
      uri: 'https://example.com/custom/metadata/schema',
      version: '1.0.0',
    ),
  ),
  recipients: [docRecipientDid],
  fees: [
    const StdCoin(
      denom: 'ucommercio',
      amount: '1000',
    )
  ],
  wallet: wallet,
);

final txHash = response.hash;

final receiptRecipientDid = wallet.bech32Address;

await DocsHelper.sendDocumentReceipt(
  recipient: receiptRecipientDid,
  txHash: txHash,
  documentId: docId,
  wallet: recipientWallet,
);
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

# Kotlin

val wallet = Wallet.derive(mnemonic = mnemonic, networkInfo = info)

val recipientWallet = Wallet.derive(recipientMnemonic, info)

val docRecipientDid = Did(recipientWallet.bech32Address)

val docId = UUID.randomUUID().toString()

val response = DocsHelper.shareDocument(
  id = docId,
  contentUri = "https://example.com/document",
  metadata = CommercioDoc.Metadata(
    contentUri = "https://example.com/document/metadata",
    schema = CommercioDoc.Metadata.Schema(
      uri = "https://example.com/custom/metadata/schema",
      version = "1.0.0"
    )
  ),
  recipients = listOf(docRecipientDid),
  fees = listOf(StdCoin(denom = "ucommercio", amount = "10000")),
  wallet = wallet
)

val txHash = (response as TxResponse.Successful).txHash

val receiptRecipientDid = Did(wallet.bech32Address)

DocsHelper.sendDocumentReceipt(
  recipient = receiptRecipientDid,
  txHash = txHash,
  documentId = docId,
  wallet = recipientWallet
)
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

# C#

var senderWallet = commercio.sacco.lib.Wallet.derive(senderMnemonic, networkInfo);

var recipientWallet = commercio.sacco.lib.Wallet.derive(recipientMnemonic, networkInfo);

var docRecipientDid = new List<string>();
docRecipientDid.Add(recipientWallet.bech32Address);
var docId = System.Guid.NewGuid().ToString();

var fees = new List<commercio.sacco.lib.StdCoin>();
fees.Add(new commercio.sacco.lib.StdCoin(denom: "ucommercio", amount: "1000"));

var res = commercio.sdk.DocsHelper.shareDocument(
 id: docId,
 contentUri: "https://example.com/document",
 metadata: new commercio.sdk.CommercioDocMetadata(
   contentUri: "https://example.com/document/metadata",
   schema: new commercio.sdk.CommercioDocMetadataSchema(
     uri: "https://example.com/custom/metadata/schema",
     version: "1.2.3"
   ),
   schemaType: ""
 ),
 recipients: docRecipientDid,
 fees: fees,
 wallet: senderWallet,
 aesKey: null,
 checksum: null,
 encryptedData: null
);

var txHash = res.GetHashCode().ToString();

var receiptRecipientDid = senderWallet.bech32Address;

var response = commercio.sdk.DocsHelper.sendDocumentReceipt(
 recipient: receiptRecipientDid,
 txHash: txHash,
 documentId: docId,
 wallet: recipientWallet
);
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