-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
29 lines (22 loc) · 903 Bytes
/
test.js
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
const Name = require("w3name");
const fs = require("fs");
async function doThings() {
let name = await Name.create();
const value =
"/ipfs/bafkreiem4twkqzsq2aj4shbycd4yvoj2cx72vezicletlhi7dijjciqpui";
let revision = await Name.v0(name, value);
await Name.publish(revision, name.key);
// await fs.promises.writeFile("priv.key", name.key.bytes);
var bytesVar = name.key.bytes;
// later
// const bytes = await fs.promises.readFile("priv.key");
name2 = await Name.from(bytesVar);
const nextValue =
"/ipfs/bafybeiauyddeo2axgargy56kwxirquxaxso3nobtjtjvoqu552oqciudrm";
let revision0 = await Name.resolve(name);
// Make a revision to the current record (increments sequence number and sets value)
const nextRevision = await Name.increment(revision0, nextValue);
await Name.publish(nextRevision, name2.key);
console.log("Name:", name2.toString());
}
doThings();