-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathens.ts
More file actions
66 lines (58 loc) · 1.66 KB
/
ens.ts
File metadata and controls
66 lines (58 loc) · 1.66 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import {
Client,
ClientConfigBuilder,
} from "@polywrap/client-js";
import { Uri } from "@polywrap/core-js";
import {
ethereumWalletPlugin,
Connection,
Connections,
} from "@polywrap/ethereum-wallet-js";
const main = async () => {
const { uri: ethereumWalletUri } = Uri.from(
"wrapscan.io/polywrap/ethereum-wallet@1.0"
);
const builder = new ClientConfigBuilder();
builder.addBundle("sys");
const ethereumWalletPackage = ethereumWalletPlugin({
connections: new Connections({
networks: {
mainnet: new Connection({
provider:
"https://mainnet.infura.io/v3/f1f688077be642c190ac9b28769daecf",
}),
},
}),
});
builder.setPackage(ethereumWalletUri, ethereumWalletPackage);
const client = new Client(builder.build());
const resolverAddress = await client.invoke<String>({
uri: "wrapscan.io/polywrap/ens@1.0.0",
method: "getResolver",
args: {
registryAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
domain: "vitalik.eth",
},
});
if (!resolverAddress.ok) {
throw Error("Error getting resolver: " + resolverAddress.error);
}
console.log("Resolver address: " + resolverAddress.value);
const contentHash = await client.invoke<String>({
uri: "wrapscan.io/polywrap/ens@1.0.0",
method: "getContentHash",
args: {
resolverAddress: resolverAddress.value,
domain: "vitalik.eth",
},
});
if (!contentHash.ok) {
throw Error("Error getting resolver: " + contentHash.error);
}
console.log("Content hash of vitalik.eth: " + contentHash.value);
};
main()
.then()
.catch((e) => {
console.error("Error in Ethereum example: ", e);
});