Create a simple static site
All you need is a simple static HTML page, as long as ALL the links are relative. For the purposes of this tutorial, I have put a simple hello world here
Save these files in a folder named site.
Add to BTFS
Next, you need to add the site to BTFS.
$ btfs add -r site/
You should see something like this:
added QmaL9R8Mxpgn7gxiqYytccM3BWX1FZfSRNGPJChu62Xe2B site/index.html
added QmazEzEvcnQ6QRdMCMYPMFphen85G93x7qKpxgeCH2FFmu site/style.css
added QmeYMHYf9Sor9q8aUgHwSL466BQQ5WK12AadV7BApDEFPU site
The hash on the last line is the root of your site, you can visit is by opening http://localhost:8080/btfs/<your hash here>.
You can also view the website from the public BTFS gateway, but the website may take minutes to be available on the public gateway.
Publish to IPNS
Now you have a simple static site hosted on BTFS. The problem is, whenever you update your site, the hash will change, and any links you have shared will continue pointing to the old version.
You need a way to always share the latest hash. That’s where IPNS comes in. It allows you to store a reference to an BTFS hash under the namespace of your peerID (hash of your public key).
If you want to know more about IPNS and How it Works, head here.
$ btfs name publish <your site hash>
This may take a few minutes. We will see how to do this faster using DNSLink below.
You will see something link this after your website has been published using IPNS.
Published to QmeYMHYf9Sor9q8aUgHwSL466BQQ5WK12AadV7BApDEFPU: /btfs/QmQToNGFsGMkQe76mRirCvRykJSiRB1JPpRLumyMN7N67T
That will return your peerID(the bold text above) and the hash you are publishing to it. You can confirm by running:
$btfs name resolve <peerId>
This will also a few minutes. After this is executed, you will see something like this:
or you can view https://gateway.btfssoter.io/ipns/<peerID> (notice the directory is ipns not ipfs). This will also a few minutes.
After a few minutes, you will be able to see your website:
IPNS forgets(Time to Live System) published names after about 12 hours. You might want to run a cron job to republish within 12 hours.
C-Virus aims to raise fund from this game for the real battle against the real COVID-19 virus. Access the game at c-virus.org The Tron network ke...
Making a passive income through a blockchain network is the ‘holy grail’ to making money and can be something that’s not really attainable. With that...
This is the Tron smart contract written in Solidity for the game Loe Dei. I hope this will bring transparency to my betting dapp. Please try to play ...
TECHNICAL DEVELOPMENT Technological progress this week • Architecture:Optimized database storage; • Mechanism: Increased anonymous transac...