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.
Optionally send proof of reading.
The Commercio SDK, our own open source tool to format transactions to Commercio.network
- DocsHelper sendDocumentReceipt.
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.
- Share a document (Chapter 4.2);
- Save the transaction hash;
- Finally, execute the DocsHelper sendDocumentReceipt to send the receipt.
Here's an example of the implemetation in all the available languages.
final wallet = Wallet.derive(mnemonic, networkInfo);
final recipientWallet = Wallet.derive(recipientMnemonic, networkInfo);
final docId = Uuid().v4();
final response = await DocsHelper.shareDocument(
id: docId,
...,
recipients: [recipientWallet.bech32Address],
wallet: wallet,
...,
);
final hash = response.hash;
await DocsHelper.sendDocumentReceipt(
recipient: wallet.bech32Address,
txHash: hash,
documentId: docId,
wallet: recipientWallet,
);
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 fee = StdFee(gas = "200000", amount = listOf(StdCoin(denom = "ucommercio", amount = "10000"))) // optional
val mode = TxHelper.BroadcastingMode.BLOCK // optional
val response = DocsHelper.shareDocument(
id = docId,
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),
wallet = wallet,
contentUri = "https://example.com/document" // optional
)
if (response is TxResponse.Successful) {
val txHash = response.txHash
val receiptRecipientDid = Did(wallet.bech32Address)
DocsHelper.sendDocumentReceipt(
recipient = receiptRecipientDid,
txHash = txHash,
documentId = docId,
wallet = recipientWallet,
fee = fee, // optional
mode = mode // optional
)
}
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: "10000"));
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
);