View Categories

Lookup IPFS website

1 min read

The @web3yak/web3domain package can also be used to find the IPFS hash for a decentralized website. IPFS (InterPlanetary File System) is a peer-to-peer protocol that allows you to store and retrieve files and websites in a decentralized manner.

When you register a web3 domain name, you can also associate it with an IPFS hash, which points to the content of your website. This way, when someone visits your domain name, they are directed to the content stored on IPFS, rather than a centralized server.

getWeb function

var w3d = require("@web3yak/web3domain");
    const settings = {
      matic_rpc_url: "https://polygon-mainnet.g.alchemy.com/v2/..........",  //Get your own RPC free URL
      eth_rpc_url: "https://eth-mainnet.g.alchemy.com/v2/................" //Get your own RPC free URL
    };
    let resolve = new w3d.Web3Domain(settings);

//Retrieve website address from Web3Domain
  resolve.getWeb("jack.demo").then(x => {
    console.log("jack.demo website url is: " + x);
  }).catch(console.error);

    //Retrieve website address from UnstoppableDomain
    resolve.getWeb("brad.crypto").then(x => {
        console.log("brad.crypto website url is: " + x);
      }).catch(console.error);

Above script will search for the decentralized website associated with it. The output is as below.

brad.crypto website url is:
https://gateway.ipfs.io/ipfs/QmTiqc12wo2pBsGa9XsbpavkhrjFiyuSWsKyffvZqVGtut
jack.demo website url is:
https://gateway.ipfs.io/ipfs/bafkreif6fr5oapdrsrv7ccdonuaqa5ysijubsoqzy323ocrr4gobbegg4i