0Pricing
Web3 & DApp Development Fundamentals · 강의

DApp 자산 저장

탈중앙화를 위해 IPFS를 사용하여 DApp 프런트엔드 자산, NFT 메타데이터 및 기타 파일을 업로드하고 가져오는 방법을 배웁니다.

DApp 자산 저장은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 3개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 3개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why Decentralize DApp Assets?

Traditional web applications host their front-ends (like HTML, CSS, and JavaScript files) on centralized servers. This means if that server goes down or is censored, the application becomes inaccessible.

Decentralized Applications (DApps) aim for full decentralization, but if your smart contract is on a blockchain while your user interface (UI) is on a single cloud server, is it truly decentralized? This lesson explores how IPFS helps.

Hosting Your DApp's UI on IPFS

IPFS provides a robust solution for hosting your entire DApp front-end. This includes all your static files: HTML pages, CSS stylesheets, JavaScript code, and images.

  • Once uploaded, the entire DApp content (or individual files) receives a unique Content Identifier (CID).
  • Users can then access your DApp directly via an IPFS gateway URL, making it highly censorship-resistant and always available, as long as it's pinned on the network.

CIDs: Content's Digital Fingerprint

As you learned in the previous lesson, IPFS uses Content Identifiers (CIDs) instead of location-based addresses.

  • A CID is a cryptographic hash of the content itself. This means if even a single byte of the content changes, its CID will also change.
  • This content addressing ensures data integrity and immutability. You can always verify that you are accessing the exact file you expect, free from tampering.

Uploading Assets to IPFS

To place your files onto the IPFS network, you typically use the IPFS command-line interface (CLI) or a client library in your code.

The ipfs add command is commonly used. It takes a file or a directory and returns its unique CID.

For example, to upload a folder containing your DApp's front-end:

ipfs add my_dapp_folder/

This command would process your folder and output a CID that represents its entire content.

Ensuring Data Stays Available (Pinning)

When you use ipfs add, your content is initially stored only on your local IPFS node. For others to reliably access it, that content needs to be "pinned."

  • Pinning is the process of telling an IPFS node to keep a copy of specific content indefinitely, preventing it from being garbage collected.
  • You can pin content to your own IPFS node, or more commonly for DApps, use a third-party "pinning service."
  • Pinning services provide dedicated infrastructure to host your content, ensuring high availability and uptime for your DApp's assets.

Decentralizing NFT Metadata

Non-Fungible Tokens (NFTs) often represent unique digital assets like images, videos, or audio. The NFT smart contract itself doesn't store the asset directly.

Instead, the smart contract typically stores a URI (Uniform Resource Identifier) that points to the asset's metadata. Storing this metadata (and often the asset itself) on IPFS is crucial:

  • It prevents the metadata from being altered or disappearing if a centralized server hosting it goes offline.
  • It ensures the NFT's value is tied to a persistent, verifiable piece of data.

Anatomy of NFT Metadata (JSON)

NFT metadata is typically a JSON (JavaScript Object Notation) file that provides descriptive information about the digital asset.

It usually includes details such as the asset's name, description, and a link to the actual media file (which is often also stored on IPFS).

Here's a common example structure:

{
  "name": "My Awesome NFT",
  "description": "A unique digital collectible.",
  "image": "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26h7y3g7o...",
  "attributes": [
    { "trait_type": "Background", "value": "Blue" }
  ]
}

The image field, for instance, uses an ipfs:// URI scheme to point directly to the asset's CID on IPFS.

How Users Access IPFS Content

Most end-users don't run their own IPFS nodes. So, how do they access content stored on IPFS?

  • They access it through "IPFS Gateways."
  • An IPFS gateway is a regular web server that acts as a bridge. It fetches content from the IPFS network on demand and serves it over standard HTTP to web browsers.
  • Popular public gateways include https://cloudflare-ipfs.com/ipfs/<your-CID> or https://ipfs.io/ipfs/<your-CID>.

DApps Retrieving IPFS Data

Your DApp's front-end code (typically written in JavaScript) can easily retrieve content from IPFS using CIDs and gateways.

  • The DApp constructs a standard web URL using the IPFS gateway address and the content's CID.
  • It then uses standard web requests (like the JavaScript fetch API) to retrieve the content, just like any other web resource.

Here's a conceptual JavaScript example:

const cid = "bafybeigdyrzt5sfp7udm7hu...";
const gatewayUrl = `https://ipfs.io/ipfs/${cid}`;

fetch(gatewayUrl)
  .then(response => response.json())
  .then(data => console.log("NFT Metadata:", data))
  .catch(error => console.error("Error fetching data:", error));

IPFS Storage Check

When building a DApp, why is it beneficial to store your front-end assets (like HTML, CSS, JavaScript) and NFT metadata on IPFS instead of a traditional centralized web server?

Recap: Storing DApp Assets

You've successfully learned how IPFS provides a decentralized and robust way to store critical DApp components, including front-end assets and NFT metadata.

  • We covered the practical aspects of uploading files using ipfs add and the crucial role of pinning services for content persistence.
  • You now understand how CIDs ensure immutability and how IPFS gateways enable users to access this decentralized content via standard web browsers.
  • This knowledge is fundamental to building DApps that are resilient, censorship-resistant, and truly decentralized.

Next, we'll explore Filecoin, which builds upon IPFS to offer an incentivized and verifiable layer for long-term, persistent storage solutions.

자주 묻는 질문

“DApp 자산 저장” 강의는 무료인가요?

네 — “DApp 자산 저장” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 3개의 강의가 포함되어 있습니다.

“DApp 자산 저장”에서 뭘 배우나요?

탈중앙화를 위해 IPFS를 사용하여 DApp 프런트엔드 자산, NFT 메타데이터 및 기타 파일을 업로드하고 가져오는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 3개 중 2번째 강의입니다.

“DApp 자산 저장” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. IPFS 입문
  2. DApp 자산 저장
  3. Filecoin 및 탈중앙화 스토리지
← Web3 & DApp Development Fundamentals(으)로 돌아가기