1.0.7 • Published 2 years ago

astrdomaints-ethers v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Astar Web3 Domains TS

Nodejs SDK for interacting with astr domains

Npm: https://www.npmjs.com/package/astrdomaints-ethers

Github: https://github.com/masafumimori/astrdomaints-ethers

Installation

npm install astrdomaints-ethers
yarn add astrdomaints-ethers

Usage

import { ethers } from 'ethers';
import React, { useEffect, useState } from 'react';

import { getAstrDomainSDK, Address, ConfigType } from 'astrdomaints-ethers';

// this is optional
const config: ConfigType = {
  testnet: {
    rpcUrl: undefined,
    contractAddress: undefined,
  },
  mainnet: {
    rpcUrl: 'https://rpc.astar.network:8545',
    contractAddress: '0xA1019535E6b364523949EaF45F4B17521c1cb074',
  },
  defaultNetwork: 'mainnet',
};

export const AstarDomain = () => {
  const [domain, setDomain] = useState('');
  const [owner, setOwner] = useState('');

  useEffect(() => {
    const load = async () => {
      const sdk = await getAstrDomainSDK(config);

      const domain = await sdk.getDomain('0x...');
      setEns(domain ?? '');

      const ownerInfo = await sdk.getOwner({ domain });
      setOwner(ownerInfo.owner);
    };
    load();
  }, [account]);

  return (
    <>
      <p>{domain || `No Astar domain detected`}</p>
      <p>{owner || `No Owner found`}</p>
    </>
  );
};

Other available methods can be found in the src/methods directory.

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago