sdk-document-anchor 0.9.0-alpha → 0.9.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.mjs +41 -41
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Hardkas } from "@hardkas/sdk";
|
|
2
|
-
|
|
3
|
-
async function run() {
|
|
4
|
-
const hardkas = await Hardkas.create({
|
|
5
|
-
network: "simulated",
|
|
6
|
-
autoBootstrap: true,
|
|
7
|
-
logger: console
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
console.log("Document Anchor initialized.");
|
|
11
|
-
console.log("Funding notary account...");
|
|
12
|
-
await hardkas.accounts.fund("notary");
|
|
13
|
-
|
|
14
|
-
const documentHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
15
|
-
console.log(`Anchoring document hash: ${documentHash}`);
|
|
16
|
-
|
|
17
|
-
// Note: Since amount 0 is not permitted yet for metadata flows, we use amount 1
|
|
18
|
-
const plan = await hardkas.tx.plan({
|
|
19
|
-
from: "notary",
|
|
20
|
-
to: "notary",
|
|
21
|
-
amount: 1
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const signed = await hardkas.tx.sign(plan);
|
|
25
|
-
const receipt = await hardkas.tx.send(signed);
|
|
26
|
-
|
|
27
|
-
console.log(`Document anchored successfully in txId: ${receipt.txId}`);
|
|
28
|
-
|
|
29
|
-
// We write an arbitrary artifact to represent the document mapping to the tx
|
|
30
|
-
const docReceipt = await hardkas.artifacts.write({
|
|
31
|
-
schema: "hardkas.example.documentAnchor.v1",
|
|
32
|
-
version: 1,
|
|
33
|
-
contentHash: documentHash,
|
|
34
|
-
txId: receipt.txId,
|
|
35
|
-
networkId: "simulated"
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
console.log(`Anchor metadata saved to artifact: ${docReceipt.absolutePath}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
run().catch(console.error);
|
|
1
|
+
import { Hardkas } from "@hardkas/sdk";
|
|
2
|
+
|
|
3
|
+
async function run() {
|
|
4
|
+
const hardkas = await Hardkas.create({
|
|
5
|
+
network: "simulated",
|
|
6
|
+
autoBootstrap: true,
|
|
7
|
+
logger: console
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
console.log("Document Anchor initialized.");
|
|
11
|
+
console.log("Funding notary account...");
|
|
12
|
+
await hardkas.accounts.fund("notary");
|
|
13
|
+
|
|
14
|
+
const documentHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
15
|
+
console.log(`Anchoring document hash: ${documentHash}`);
|
|
16
|
+
|
|
17
|
+
// Note: Since amount 0 is not permitted yet for metadata flows, we use amount 1
|
|
18
|
+
const plan = await hardkas.tx.plan({
|
|
19
|
+
from: "notary",
|
|
20
|
+
to: "notary",
|
|
21
|
+
amount: 1
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const signed = await hardkas.tx.sign(plan);
|
|
25
|
+
const receipt = await hardkas.tx.send(signed);
|
|
26
|
+
|
|
27
|
+
console.log(`Document anchored successfully in txId: ${receipt.txId}`);
|
|
28
|
+
|
|
29
|
+
// We write an arbitrary artifact to represent the document mapping to the tx
|
|
30
|
+
const docReceipt = await hardkas.artifacts.write({
|
|
31
|
+
schema: "hardkas.example.documentAnchor.v1",
|
|
32
|
+
version: 1,
|
|
33
|
+
contentHash: documentHash,
|
|
34
|
+
txId: receipt.txId,
|
|
35
|
+
networkId: "simulated"
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
console.log(`Anchor metadata saved to artifact: ${docReceipt.absolutePath}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
run().catch(console.error);
|