科技隨筆
科技隨筆

| 科技閱讀 | 程式語言 | 理財規劃 | 工具推薦 | 音樂盛宴 | 生活雜談 | 科技隨筆中,不只有科技! 在這裡,我會隨筆記下科技閱讀、程式語言、理財規劃、音樂饗宴以及生活雜談等等內容。 邀請您在過程中與我一同分享也一同成長。 讓我們在人生的旅途中不斷學習,努力成為更棒的人吧~ 在其他平臺關注我: https://linkby.tw/itechnote.co

[Dragon Boat Festival] My first decentralized picture! | Smart contract development plan #6

Here, we will analyze why the issuance of NFT needs to be done with IPFS. What is IPFS? And how to use Pinata's service to put files you want to upload on the IPFS network in action. Start here and start owning your first decentralized image!

Dragon Boat Festival NFT is fully open for reservations!

2022 quickly came to Q2. In January, I wrote about how to issue ERC-20 tokens. Finally, I actually issued my own "IT Coin (ITC)" on the Polygon main network and airdropped it to reader.

With the start of the new project, Tech Essay Opens Tech Coin holders to fill in the form to make an appointment to receive a free NFT airdrop. It doesn't matter if you don't have the previously airdropped Tech Coins, the form will be fully opened from 2022/05/19 00:00 Make an appointment! After the first round of ITC holders have filled in and checked their qualifications, there are 18 free NFTs remaining. If you want to claim them, you will need to follow any technology essay platform or join any technology essay community (I will check). The form will be ranked according to the filling time, and there will be no further notice when the quota is full!

Link to the form: https://forms.gle/fvk63YT3wcN2xvQCA

The first round of form filling has been checked and the list of eligible recipients has been announced in the group. Those who have not yet filled in the form should quickly fill it out.

Are NFT images safe?

Now common NFTs usually see a picture. If you have seen the size of the picture in the file manager, you should know that a picture is just a few MB, and the data space will be thousands of times more than the text. If we To upload pictures to the blockchain, it will require a huge handling fee to do it, which is a very impractical action. Therefore, almost all mainstream NFT projects now upload pictures to the Internet first, and then upload the website address. Copy it out and put it on the blockchain to save the cost of on-chain.

It seems that the URL behind the NFT corresponds to a place to store this NFT image! Then the question arises, is this URL reliable?

Taking my own website as an example, the URL of the selected pictures in this article is placed in the virtual host corresponding to the domain of Technote: https://itechnote.co/wp-content/uploads/2022/05/IPFS_Pinata .png , if you use this image URL to issue NFT, those secondary markets or wallets that can browse NFT will grab the image through the URL and display it to the user, and the NFT is done and looks fine.

But one day after N years, if the virtual host and domain are not rented, the web pages corresponding to the URLs starting with itechnote.co will naturally cease to exist, and it is even more impossible to issue NFTs with this URL. If you find the corresponding pattern again, it is worth thinking about whether it will become a crossed NFT of "404 not found".

If the image is placed in the cloud, it is also possible that the image URL has changed because the technology company has collapsed or they have made cloud business adjustments, and the NFT will not be able to find the corresponding pattern.

If there is a personal website or some centralized places, it is very likely that the data cannot be read due to service suspension or attack. Then we cannot guarantee that the picture corresponding to this NFT website will disappear in the next five or ten years. If It uses IPFS to store pictures. Because the data will generate a unique hash value when it is stored, and it will be stored in the hard disk nodes of miners. Compared with centralized or private storage, the storage method stored in IPFS is even more unnecessary. Worried about losing pictures (but still no guarantees that they won't be lost).

IPFS Interstellar File System

IPFS (InterPlanetary File System) is a decentralized file storage system. Similar to using cloud services, you do not know where your files are stored, but the difference from cloud services is that cloud services usually A super-large data center is required to store data, so it can be regarded as centralized storage, while IPFS is decentralized storage. Your data will be stored in many different nodes. The advantage is that data is not easy to lose (due to The mechanism of the system design cannot guarantee that the data will not be lost), but the disadvantage is that if the image file is large, it will be cut into multiple copies and stored separately in different nodes, which may lead to the time required for data reading. will be longer.

IPFS is like the HTTP we use every day. It is a network protocol in itself. When each data is stored, it will generate a unique hash value, which is unique like the IP in the domain.

In the use of the Internet, IP is very difficult to remember, so the IP domain will be converted to a URL through the Domain Name System ( DNS ). If you are not familiar with URLs, you can implement this example. If we want to connect to the Google homepage, we will mark "google.com" on the browser. You can try to see the IP "142.250.179.206" behind it on the browser. After entering it, you can also connect to the Google homepage. This is Because when we enter google.com, the browser will first go to DNS to find the IP corresponding to google.com (142.250.193.206), and then use this IP to connect to Google's server; IPFS also has the same domain name system ( IPNS ) in Do something similar to convert the hash value into a more understandable symbol to improve the efficiency of data reading.

Just like most people will use https network protocol services, people often don’t need to understand the principles behind them. In many cases, it is enough to learn how to use these new technologies. Next, we will focus on how to put ourselves We only need to know that IPFS is a decentralized storage network protocol, and the data on it is more secure than the general private or centralized storage methods, but it still cannot guarantee that the data will not be lost. Many more details of IPFS will be written in an article to introduce it in the future if there is a chance.

Normally, to use the IPFS interstellar file system to upload or download data, you must download, install and configure a new IPFS node on your computer to do this. We just want to upload a picture for NFT. , but it takes a lot of computer resources to deploy IPFS nodes. Is it a bit of a fuss? The complicated and redundant process of subordinate is completely ineffective, so we have to use a free tool to upload pictures to IPFS, it is "Pinata"!

Pinata

Pinata is a service that allows people to store data on IPFS. It provides 1GB of free storage space to use. For us who want to do NFT, this space is more than enough to store pictures.

The website URL is: https://www.pinata.cloud/

After entering, I saw a big slogan on the official website that read "Your Home For NFT Media. The cloud wasn't built for this. Pinata was. Managing your NFT media just got easier." It seems that using pinata for NFT should be the right choice. .

After entering the homepage, first register and log in as a Pinata member in the upper right corner of the "Try for free".

After the registration is completed and then re-login, you will enter this page. This page is the main screen of Pinata. Whether you want to upload data or query previously uploaded data, it works here.

The small yellow window in the upper right corner also reminds us that IPFS is an open network. As long as all the information posted on IPFS has the corresponding CID, anyone can browse it at will. Don't post your important information on it!

Upload my first decentralized image

Finally came to the protagonist of this article, after Pinata uploads the picture of us doing NFT.

There is a "+ Upload" button at the top left of the screen. After clicking it, there are three things that can be uploaded:

"Folder" can upload the entire folder.

"File" means uploading a file, whether it is a text file, a picture or a video, it is a file.

"CID" is something similar to a website on IPFS. All folders or files placed on it will generate a set of CIDs. The purpose of uploading a CID is probably to pin this CID again. In IPFS, due to the large amount of data on the Internet Many, if this CID is Pin, it is equivalent to telling IPFS that "this file is very important", allowing IPFS to retain this file in the node for a longer period of time, reducing the fact that the data is finally cleared by IPFS due to no access.

Here we have to select File, after selecting, you will see the following three steps:

Step 1: Upload a file from my computer, click "Select a file" to open the file manager and select the image to upload.
Step 2: Give this picture a file name (the default is the original file name).
Step 3: During uploading, the uploading process will take some time. If it is spinning in circles, please wait patiently for it to finish, and do not close the window.

If the upload is successful, you will see the name you just named appear on the home page, and a set of CIDs will be generated along with it, and the image has been successfully uploaded to IPFS.

Read decentralized pictures

As mentioned earlier, the CID of the file will be obtained after the successful upload. Through this CID, we can find it on IPFS. If you want to see the image just uploaded, there are quite a few methods. Here are two reading methods, and use the method I just uploaded. Take the CID obtained by uploading the Tech Essay Logo as an example (QmYHiLbYTK9hMpGwLdG9JZvStRGfBaFwv6XEW2JaENuBox) for everyone to try:

1. Read using IPFS

Type ipfs://{#yourCID} directly on a browser that supports IPFS.

This operation requires the use of a browser that supports IPFS. I currently use the Brave browser for testing. It is redeveloped using the Chrome browser as the bottom layer, so it is quite similar to Chrome. You can download it and try it out. URL : https://brave.com/ .

Just like the http:// or https:// of the general Internet connection, if you want to browse the IPFS network, you must start with ipfs://, then paste the CID on Pinata directly, you can see Just uploaded the picture.

Enter ipfs://QmYHiLbYTK9hMpGwLdG9JZvStRGfBaFwv6XEW2JaENuBox to see the pictures I uploaded before.

However, it should be noted that due to the large number of nodes in the IPFS network, the process of uploading files takes a lot of time, so the pictures just uploaded may not be found by querying directly using ipfs://. Come back and try it out, it may take a few minutes to display the image the first time you read it, hit enter and have a cup of coffee and come back to see the results.

2. Read using HTTP

Grab pictures directly through pinata's own gateway service https://gateway.pinata.cloud/ipfs/{#yourCID} .

Just click on the file name you just uploaded. In my example, click on the purple "ITechNote_Logo.png" under the Name, and you will be connected to https://gateway.pinata.cloud/ipfs/QmYHiLbYTK9hMpGwLdG9JZvStRGfBaFwv6XEW2JaENuBox .

You will find that this URL is actually https://gateway.pinata.cloud/ipfs/{#yourCID}. Since it starts with https://, all browsers can connect to pinata to see this picture.

Epilogue

The above is the method of uploading files to IPFS using Pinata. Congratulations to everyone for getting the first decentralized picture of yourself. Of course, you don’t have to upload pictures. You can upload text files, videos, and entire folders. If you think of any creative ways of using IPFS technology or various ideas, please come back to communicate with me.

Further reading

Article 1: [New Year's Plan] Red Packet Coins for Chinese New Year | Smart Contract Development Plan #1
Previous: [Dragon Boat Festival] Six Essential Knowledges for Issuing NFT | Smart Contract Development Plan #5


Finally, thank you for taking time out of your busy schedule to take the time to read my articles. If you still like these content, I hope to get your follow-up and small sponsorship support, which will give me more motivation to continue writing, and welcome to click This link finds me on other platforms .

See you next time o((>ω< ))o~

Original link ITechNote technology essay

CC BY-NC-ND 2.0

Like my work?
Don't forget to support or like, so I know you are with me..

Loading...
Loading...

Comment