var nem = require("nem-sdk").default;
const password = '';
const privateKey = '';
const common = nem.model.objects.create('common')(password, privateKey);
const fileName = "sample.txt";
const content = "Apostille is awesome !";
const tag = "Test Apostille";
var fileContent = nem.crypto.js.enc.Utf8.parse(content);
var endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultMainnet, nem.model.nodes.defaultPort);
var apostille = nem.model.apostille.create(common, "Test.txt", fileContent, tag, nem.model.apostille.hashing["SHA256"], false, {}, true, nem.model.network.data.mainnet.id);
async function main() {
nem.model.transactions.send(common, apostille.transaction, endpoint).then(function(res){
// If code >= 2, it's an error
if (res.code >= 2) {
console.error(res.message);
} else {
console.log("\nTransaction: " + res.message);
console.log("\nCreate a file with the fileContent text and name it:\n" + apostille.data.file.name.replace(/\.[^/.]+$/, "") + " -- Apostille TX " + res.transactionHash.data + " -- Date DD/MM/YYYY" + "." + apostille.data.file.name.split('.').pop());
console.log("When transaction is confirmed the file should audit successfully in Nano");
console.log("\nYou can also take the following hash: " + res.transactionHash.data + " and put it into the audit.js example");
}
}, function(err) {
console.error(err);
});
}
main();
$ node apostille.js
Transaction: SUCCESS
Create a file with the fileContent text and name it:
Test — Apostille TX 22817314fc9e51742ce6a5836e1ad7bb622cf32289d546831d1ab99224618c2f — Date DD/MM/YYYY.txt
When transaction is confirmed the file should audit successfully in Nano
You can also take the following hash: 22817314fc9e51742ce6a5836e1ad7bb622cf32289d546831d1ab99224618c2f and put it into the audit.js example
おおおおおお、完全に理解した。
### apostilleのcheck
var nem = require("nem-sdk").default;
const content = "Apostille is awesome !";
var fileContent = nem.crypto.js.enc.Utf8.parse(content);
var endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultMainnet, nem.model.nodes.defaultPort);
var txHash = "22817314fc9e51742ce6a5836e1ad7bb622cf32289d546831d1ab99224618c2f"
async function main() {
nem.com.requests.transaction.byHash(endpoint, txHash).then(function(res) {
// Verify
if (nem.model.apostille.verify(fileContent, res.transaction)) {
console.log("Apostille is valid");
} else {
console.log("Apostille is invalid");
}
}, function(err) {
console.log("Apostille is invalid");
console.log(err);
});
}
main();
$ node confirm.js
Apostille is valid
すげええええええええ
これを実装する


よっしゃあああああああああああああああああああああああ
あとはNEMの価格を取得して表示するのみ