forked from webaverse/app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockchain-manager.js
More file actions
29 lines (27 loc) · 844 Bytes
/
blockchain-manager.js
File metadata and controls
29 lines (27 loc) · 844 Bytes
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
import * as ethers from 'ethers';
// window.ethers = ethers;
const infuraProjectId = 'f6d37ed423e143feb2b0a331e7899aaf';
const infuraProjectSecret = '';
class BlockchainManager {
constructor() {
// this.provider = ethers.getDefaultProvider();
this.provider = new ethers.providers.InfuraProvider('homestead', {
projectId: infuraProjectId,
// projectSecret: infuraProjectSecret
});
}
async getEnsName(address) {
return await this.provider.lookupAddress(address);
}
async getAvatarUrl(ensName) {
const resolver = await this.provider.getResolver(ensName);
const avatar = await resolver.getAvatar();
if (avatar) {
return avatar.url;
} else {
return null;
}
}
}
const blockchainManager = new BlockchainManager();
export default blockchainManager;