Ver3.0 ๐ ๋ผ๋ผ๋ฒจ๊ณผ web3.js๋ก ๋ธ๋ก์ฒด์ธ CMS ํตํฉํ๊ธฐ

๐ ๋ผ๋ผ๋ฒจ๊ณผ web3.js๋ก ๋ธ๋ก์ฒด์ธ CMS ํตํฉํ๊ธฐ
์ ํต์ ์ธ ์น๊ณผ ํ์ค์ํ ์ธ๊ณ๋ฅผ ์ฐ๊ฒฐํ๋ ์ค์ ๊ฐ์ด๋
์๋
! ์ค๋์ ์ ๋ง ํฅ๋ฏธ๋ก์ด ์ฃผ์ ๋ฅผ ๊ฐ์ง๊ณ ์์ด. ๋ฐ๋ก ๋ผ๋ผ๋ฒจ(Laravel)์ด๋ผ๋ PHP ํ๋ ์์ํฌ์ web3.js๋ฅผ ๊ฒฐํฉํด์ ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฅ์ ๊ฐ์ง CMS(์ฝํ
์ธ ๊ด๋ฆฌ ์์คํ
)๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ด์ผ. ๐ฏ
"์ ๊ตณ์ด ์ ํต์ ์ธ ์น ํ๋ ์์ํฌ์ ๋ธ๋ก์ฒด์ธ์ ๋ถ์ฌ?" ๋ผ๊ณ ์๊ฐํ ์๋ ์๋๋ฐ, ์ค์ ๋ก ์ด ์กฐํฉ์ ์์ฒญ๋ ์๋์ง๋ฅผ ๋ง๋ค์ด๋ด. ๋ผ๋ผ๋ฒจ์ ๊ฐ๋ ฅํ ๋ฐฑ์๋ ๊ธฐ๋ฅ๊ณผ ๋ธ๋ก์ฒด์ธ์ ํฌ๋ช
์ฑ, ๋ถ๋ณ์ฑ์ ๊ฒฐํฉํ๋ฉด ์์ ํ ์๋ก์ด ์ฐจ์์ ์ฝํ
์ธ ๊ด๋ฆฌ ์์คํ
์ ๊ตฌ์ถํ ์ ์๊ฑฐ๋ ! ๐ก
๐ช ์ ๋ผ๋ผ๋ฒจ๊ณผ web3.js๋ฅผ ํจ๊ป ์ฌ์ฉํ ๊น?
๋จผ์ ์ด ๋ ๊ธฐ์ ์ ์ ํจ๊ป ์ฌ์ฉํ๋์ง๋ถํฐ ์ดํดํด๋ณด์. ๊ฐ๊ฐ์ ๊ฐ์ ์ ์ดํด๋ณด๋ฉด ๋ต์ด ๋ณด์ฌ!
๐ฅ ๋ผ๋ผ๋ฒจ์ ๊ฐ์
๋ผ๋ผ๋ฒจ์ PHP ์ํ๊ณ์์ ๊ฐ์ฅ ์ธ๊ธฐ ์๋ ํ๋ ์์ํฌ ์ค ํ๋์ผ. Eloquent ORM์ผ๋ก ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์
์ด ์ ๋ง ์ฝ๊ณ , ๋ผ์ฐํ
, ๋ฏธ๋ค์จ์ด, ์ธ์ฆ ์์คํ
์ด ์ด๋ฏธ ์ ๊ตฌ์ถ๋์ด ์์ด์ ๋น ๋ฅด๊ฒ ์น ์ ํ๋ฆฌ์ผ์ด์
์ ๋ง๋ค ์ ์์ง.
ํนํ CMS๋ฅผ ๋ง๋ค ๋๋ ์ฌ์ฉ์ ๊ด๋ฆฌ, ๊ถํ ์ ์ด, ํ์ผ ์
๋ก๋, ์บ์ฑ ๊ฐ์ ๊ธฐ๋ฅ๋ค์ด ํ์์ธ๋ฐ, ๋ผ๋ผ๋ฒจ์ ์ด๋ฐ ๊ฒ๋ค์ ๊ธฐ๋ณธ์ผ๋ก ์ ๊ณตํด. ๊ฒ๋ค๊ฐ php artisan ๋ช
๋ น์ด๋ก ์ฝ๋ ์์ฑ๋ ์๋ํํ ์ ์์ด์ ๊ฐ๋ฐ ์๋๊ฐ ์์ฒญ ๋นจ๋ผ! โก
โ๏ธ web3.js์ ๊ฐ์
web3.js๋ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ์ํธ์์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. ์ค๋งํธ ์ปจํธ๋ํธ๋ฅผ ํธ์ถํ๊ณ , ํธ๋์ญ์
์ ์ ์กํ๊ณ , ๋ธ๋ก์ฒด์ธ ๋ฐ์ดํฐ๋ฅผ ์ฝ์ด์ฌ ์ ์์ด.
๋ธ๋ก์ฒด์ธ์ ํต์ฌ ๊ฐ์น๋ ํ์ค์ํ์ ๋ถ๋ณ์ฑ์ด์ผ. ํ๋ฒ ๊ธฐ๋ก๋ ๋ฐ์ดํฐ๋ ๋๊ตฌ๋ ์์๋ก ์์ ํ ์ ์๊ณ , ๋ชจ๋ ๊ฑฐ๋ ๋ด์ญ์ด ํฌ๋ช
ํ๊ฒ ๊ณต๊ฐ๋ผ. ์ด๋ฐ ํน์ฑ์ CMS์ ์ ์ฉํ๋ฉด ์ฝํ
์ธ ์ ์๋ณธ ์ฆ๋ช
, ์ ์๊ถ ๋ณดํธ, ํฌ๋ช
ํ ์์ต ๋ถ๋ฐฐ ๊ฐ์ ํ์ ์ ์ธ ๊ธฐ๋ฅ์ ๊ตฌํํ ์ ์์ด! ๐จ
๐๏ธ ์์คํ ์ํคํ ์ฒ ์ค๊ณํ๊ธฐ
๋ณธ๊ฒฉ์ ์ผ๋ก ์์ํ๊ธฐ ์ ์ ์ ์ฒด ์์คํ ๊ตฌ์กฐ๋ฅผ ์ดํดํ๋ ๊ฒ ์ค์ํด. ์ฐ๋ฆฌ๊ฐ ๋ง๋ค ๋ธ๋ก์ฒด์ธ CMS๋ ํฌ๊ฒ ์ธ ๊ฐ์ง ๋ ์ด์ด๋ก ๊ตฌ์ฑ๋ผ:
๐ 1. ํ๋ ์ ํ ์ด์ ๋ ์ด์ด (Frontend)
์ฌ์ฉ์๊ฐ ์ง์ ๋ณด๊ณ ์ํธ์์ฉํ๋ ๋ถ๋ถ์ด์ผ. ๋ผ๋ผ๋ฒจ์ Blade ํ
ํ๋ฆฟ ์์ง์ ์ฌ์ฉํ๊ฑฐ๋, Vue.js๋ React ๊ฐ์ ํ๋ก ํธ์๋ ํ๋ ์์ํฌ๋ฅผ ์ฐ๋ํ ์ ์์ด. ์ฌ๊ธฐ์ web3.js๋ฅผ ์ฌ์ฉํด์ ๋ฉํ๋ง์คํฌ ๊ฐ์ ์ง๊ฐ๊ณผ ์ฐ๊ฒฐํ๊ณ , ๋ธ๋ก์ฒด์ธ ํธ๋์ญ์
์ ๋ฐ์์์ผ.
์ค์ํ ๊ฑด ์ฌ์ฉ์ ๊ฒฝํ(UX)์ด์ผ. ๋ธ๋ก์ฒด์ธ ๊ธฐ์ ์ด ๋ณต์กํ๋๋ผ๋ ์ฌ์ฉ์๋ ๊ฐ๋จํ๊ฒ ๋ฒํผ ํด๋ฆญ ๋ช ๋ฒ์ผ๋ก ๋ชจ๋ ๊ฑธ ์ฒ๋ฆฌํ ์ ์์ด์ผ ํด. ๊ฐ์ค๋น ์์, ํธ๋์ญ์
์ํ ํ์, ์๋ฌ ํธ๋ค๋ง ๊ฐ์ ๋ถ๋ถ์ ์ ๊ฒฝ ์จ์ผ ํด! ๐ฏ
โ๏ธ 2. ์ ํ๋ฆฌ์ผ์ด์ ๋ ์ด์ด (Backend)
๋ผ๋ผ๋ฒจ์ด ๋ด๋นํ๋ ํต์ฌ ๋น์ฆ๋์ค ๋ก์ง ์์ญ์ด์ผ. ์ฌ์ฉ์ ์ธ์ฆ, ์ฝํ
์ธ CRUD(์์ฑ, ์ฝ๊ธฐ, ์์ , ์ญ์ ), ํ์ผ ๊ด๋ฆฌ, API ์๋ํฌ์ธํธ ์ ๊ณต ๋ฑ์ ์ฒ๋ฆฌํด.
์ฌ๊ธฐ์ ์ค์ํ ๊ฑด ํ์ด๋ธ๋ฆฌ๋ ๋ฐ์ดํฐ ๊ด๋ฆฌ์ผ. ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ๋ธ๋ก์ฒด์ธ์ ์ ์ฅํ๋ฉด ๋น์ฉ์ด ๋๋ฌด ๋ง์ด ๋ค์ด. ๊ทธ๋์ ์ค์ํ ๋ฉํ๋ฐ์ดํฐ(ํด์๊ฐ, ํ์์คํฌํ, ์์ ๊ถ ์ ๋ณด)๋ง ๋ธ๋ก์ฒด์ธ์ ์ ์ฅํ๊ณ , ์ค์ ์ฝํ
์ธ ๋ ์ ํต์ ์ธ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ IPFS ๊ฐ์ ๋ถ์ฐ ์คํ ๋ฆฌ์ง์ ์ ์ฅํ๋ ์ ๋ต์ ์ฌ์ฉํด! ๐พ
๐ 3. ๋ธ๋ก์ฒด์ธ ๋ ์ด์ด
์ด๋๋ฆฌ์์ด๋ ๋ค๋ฅธ EVM ํธํ ๋ธ๋ก์ฒด์ธ(ํด๋ฆฌ๊ณค, BSC ๋ฑ)์ ๋ฐฐํฌ๋ ์ค๋งํธ ์ปจํธ๋ํธ๊ฐ ์ฌ๊ธฐ์ ์ํด. ์๋ฆฌ๋ํฐ(Solidity)๋ก ์์ฑ๋ ์ปจํธ๋ํธ๋ ์ฝํ
์ธ ๋ฑ๋ก, ์์ ๊ถ ์ด์ , ๋ผ์ด์ ์ค ๊ด๋ฆฌ ๊ฐ์ ํต์ฌ ๋ก์ง์ ๋ด๋นํด.
web3.js๋ ์ด ๋ ์ด์ด์ ํต์ ํ๋ ๋ค๋ฆฌ ์ญํ ์ ํด. HTTP Provider๋ WebSocket Provider๋ฅผ ํตํด ๋ธ๋ก์ฒด์ธ ๋
ธ๋์ ์ฐ๊ฒฐํ๊ณ , ์ปจํธ๋ํธ ๋ฉ์๋๋ฅผ ํธ์ถํ๊ฑฐ๋ ์ด๋ฒคํธ๋ฅผ ๊ตฌ๋
ํ ์ ์์ด! ๐
๐ ๏ธ ๊ฐ๋ฐ ํ๊ฒฝ ์ธํ ํ๊ธฐ
์, ์ด์ ์ค์ ๋ก ์์ ๋๋ฝํ๋ณผ ์๊ฐ์ด์ผ! ๋จผ์ ๊ฐ๋ฐ ํ๊ฒฝ์ ๊ตฌ์ถํด๋ณด์.
๐ฆ ํ์ ๋๊ตฌ ์ค์น
๋ค์ ๋๊ตฌ๋ค์ด ํ์ํด:
| ๋๊ตฌ | ์ฉ๋ | ๋ฒ์ |
|---|---|---|
| PHP | ๋ผ๋ผ๋ฒจ ์คํ ํ๊ฒฝ | 8.1 ์ด์ |
| Composer | PHP ํจํค์ง ๊ด๋ฆฌ์ | ์ต์ ๋ฒ์ |
| Node.js | npm ๋ฐ web3.js ์คํ | 16.x ์ด์ |
| MySQL/PostgreSQL | ๋ฐ์ดํฐ๋ฒ ์ด์ค | 8.0 / 13 ์ด์ |
| Ganache | ๋ก์ปฌ ๋ธ๋ก์ฒด์ธ ํ ์คํธ | ์ต์ ๋ฒ์ |
๐ ๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ ์์ฑ
ํฐ๋ฏธ๋์ ์ด๊ณ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํด:
composer create-project laravel/laravel blockchain-cms
cd blockchain-cms
php artisan serve
์ด์ http://localhost:8000์ ์ ์ํ๋ฉด ๋ผ๋ผ๋ฒจ ํ์ ํ์ด์ง๊ฐ ๋ณด์ผ ๊ฑฐ์ผ! ๐
๐ web3.js ์ค์น
ํ๋ก์ ํธ ๋ฃจํธ ๋๋ ํ ๋ฆฌ์์ npm์ ์ด๊ธฐํํ๊ณ web3.js๋ฅผ ์ค์นํด:
npm init -y
npm install web3
npm install @truffle/contract
@truffle/contract๋ ์ค๋งํธ ์ปจํธ๋ํธ์์ ์ํธ์์ฉ์ ๋ ์ฝ๊ฒ ๋ง๋ค์ด์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. ์ ํ์ฌํญ์ด์ง๋ง ๊ฐ๋ ฅ ์ถ์ฒ! ๐
๐ ์ค๋งํธ ์ปจํธ๋ํธ ์์ฑํ๊ธฐ
๋ธ๋ก์ฒด์ธ CMS์ ํต์ฌ์ ์ค๋งํธ ์ปจํธ๋ํธ์ผ. ์ฝํ ์ธ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ณ ๊ด๋ฆฌํ๋ ๊ฐ๋จํ ์ปจํธ๋ํธ๋ฅผ ๋ง๋ค์ด๋ณด์.
๐จ ContentRegistry ์ปจํธ๋ํธ
์๋ฆฌ๋ํฐ๋ก ์์ฑ๋ ๊ธฐ๋ณธ ์ปจํธ๋ํธ ์์์ผ:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ContentRegistry {
struct Content {
string contentHash;
address author;
uint256 timestamp;
string title;
bool isActive;
}
mapping(uint256 => Content) public contents;
mapping(address => uint256[]) public authorContents;
uint256 public contentCount;
event ContentRegistered(
uint256 indexed contentId,
address indexed author,
string contentHash,
uint256 timestamp
);
event ContentUpdated(
uint256 indexed contentId,
string newContentHash
);
function registerContent(
string memory _contentHash,
string memory _title
) public returns (uint256) {
contentCount++;
contents[contentCount] = Content({
contentHash: _contentHash,
author: msg.sender,
timestamp: block.timestamp,
title: _title,
isActive: true
});
authorContents[msg.sender].push(contentCount);
emit ContentRegistered(
contentCount,
msg.sender,
_contentHash,
block.timestamp
);
return contentCount;
}
function updateContent(
uint256 _contentId,
string memory _newContentHash
) public {
require(
contents[_contentId].author == msg.sender,
"Only author can update"
);
require(
contents[_contentId].isActive,
"Content is not active"
);
contents[_contentId].contentHash = _newContentHash;
emit ContentUpdated(_contentId, _newContentHash);
}
function getContent(uint256 _contentId)
public
view
returns (
string memory,
address,
uint256,
string memory,
bool
)
{
Content memory content = contents[_contentId];
return (
content.contentHash,
content.author,
content.timestamp,
content.title,
content.isActive
);
}
function getAuthorContents(address _author)
public
view
returns (uint256[] memory)
{
return authorContents[_author];
}
}
์ด ์ปจํธ๋ํธ๋ ์ฝํ ์ธ ์ ํด์๊ฐ, ์์ฑ์, ํ์์คํฌํ, ์ ๋ชฉ์ ์ ์ฅํด. ์ค์ ์ฝํ ์ธ ๋ด์ฉ์ IPFS๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅํ๊ณ , ๊ทธ ํด์๊ฐ๋ง ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํ๋ ๊ฑฐ์ผ! ๐ฆ
๐จ ์ปจํธ๋ํธ ์ปดํ์ผ ๋ฐ ๋ฐฐํฌ
Truffle์ด๋ Hardhat์ ์ฌ์ฉํด์ ์ปจํธ๋ํธ๋ฅผ ์ปดํ์ผํ๊ณ ๋ฐฐํฌํ ์ ์์ด. Hardhat์ ์ฌ์ฉํ๋ ์์๋ฅผ ๋ณด์ฌ์ค๊ฒ:
npm install --save-dev hardhat
npx hardhat init
๊ทธ๋ฆฌ๊ณ ๋ฐฐํฌ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํด:
// scripts/deploy.js
async function main() {
const ContentRegistry = await ethers.getContractFactory("ContentRegistry");
const contentRegistry = await ContentRegistry.deploy();
await contentRegistry.deployed();
console.log("ContentRegistry deployed to:", contentRegistry.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
๋ก์ปฌ Ganache์ ๋ฐฐํฌํ๋ ค๋ฉด:
npx hardhat run scripts/deploy.js --network localhost
๋ฐฐํฌ๊ฐ ์๋ฃ๋๋ฉด ์ปจํธ๋ํธ ์ฃผ์๊ฐ ์ถ๋ ฅ๋ผ. ์ด ์ฃผ์๋ฅผ ์ ๊ธฐ์ตํด๋์! ๐ฏ
๐ ๋ผ๋ผ๋ฒจ์ web3.js ํตํฉํ๊ธฐ
์ด์ ๋ผ๋ผ๋ฒจ ์ ํ๋ฆฌ์ผ์ด์ ์์ ๋ธ๋ก์ฒด์ธ๊ณผ ํต์ ํ ์ ์๋๋ก web3.js๋ฅผ ํตํฉํด๋ณด์. ํ๋ก ํธ์๋์ ๋ฐฑ์๋ ์์ชฝ์์ ์ ๊ทผํ๋ ๋ฐฉ๋ฒ์ ์์๋ณผ๊ฒ!
๐จ ํ๋ก ํธ์๋ ํตํฉ
๋ผ๋ผ๋ฒจ์ resources/js ๋๋ ํ ๋ฆฌ์ web3 ๊ด๋ จ ๋ชจ๋์ ๋ง๋ค์ด๋ณด์:
// resources/js/web3/provider.js
import Web3 from 'web3';
class Web3Provider {
constructor() {
this.web3 = null;
this.account = null;
this.networkId = null;
}
async init() {
if (typeof window.ethereum !== 'undefined') {
this.web3 = new Web3(window.ethereum);
try {
await window.ethereum.request({
method: 'eth_requestAccounts'
});
const accounts = await this.web3.eth.getAccounts();
this.account = accounts[0];
this.networkId = await this.web3.eth.net.getId();
return true;
} catch (error) {
console.error('User denied account access', error);
return false;
}
} else {
console.error('Please install MetaMask!');
return false;
}
}
getWeb3() {
return this.web3;
}
getAccount() {
return this.account;
}
getNetworkId() {
return this.networkId;
}
}
export default new Web3Provider();
์ด์ ์ปจํธ๋ํธ์ ์ํธ์์ฉํ๋ ์๋น์ค ํด๋์ค๋ฅผ ๋ง๋ค์ด:
// resources/js/web3/contentService.js
import web3Provider from './provider';
import ContentRegistryABI from './abi/ContentRegistry.json';
class ContentService {
constructor() {
this.contractAddress = process.env.MIX_CONTRACT_ADDRESS;
this.contract = null;
}
async init() {
const web3 = web3Provider.getWeb3();
if (!web3) {
throw new Error('Web3 not initialized');
}
this.contract = new web3.eth.Contract(
ContentRegistryABI,
this.contractAddress
);
}
async registerContent(contentHash, title) {
const account = web3Provider.getAccount();
try {
const result = await this.contract.methods
.registerContent(contentHash, title)
.send({ from: account });
return {
success: true,
transactionHash: result.transactionHash,
contentId: result.events.ContentRegistered.returnValues.contentId
};
} catch (error) {
console.error('Error registering content:', error);
return {
success: false,
error: error.message
};
}
}
async getContent(contentId) {
try {
const content = await this.contract.methods
.getContent(contentId)
.call();
return {
contentHash: content[0],
author: content[1],
timestamp: content[2],
title: content[3],
isActive: content[4]
};
} catch (error) {
console.error('Error getting content:', error);
return null;
}
}
async updateContent(contentId, newContentHash) {
const account = web3Provider.getAccount();
try {
const result = await this.contract.methods
.updateContent(contentId, newContentHash)
.send({ from: account });
return {
success: true,
transactionHash: result.transactionHash
};
} catch (error) {
console.error('Error updating content:', error);
return {
success: false,
error: error.message
};
}
}
async getAuthorContents(authorAddress) {
try {
const contentIds = await this.contract.methods
.getAuthorContents(authorAddress)
.call();
return contentIds;
} catch (error) {
console.error('Error getting author contents:', error);
return [];
}
}
}
export default new ContentService();
Vue ์ปดํฌ๋ํธ์์ ์ฌ์ฉํ๋ ์์์ผ:
// resources/js/components/ContentRegister.vue
<template>
<div class="content-register">
<h2>Register New Content</h2>
<form @submit.prevent="registerContent">
<div class="form-group">
<label>Title</label>
<input v-model="title" type="text" required />
</div>
<div class="form-group">
<label>Content</label>
<textarea v-model="content" required></textarea>
</div>
<button type="submit" :disabled="isProcessing">
{{ isProcessing ? 'Processing...' : 'Register' }}
</button>
</form>
<div v-if="result" class="result">
<p>Transaction Hash: {{ result.transactionHash }}</p>
<p>Content ID: {{ result.contentId }}</p>
</div>
</div>
</template>
<script>
import web3Provider from '../web3/provider';
import contentService from '../web3/contentService';
import CryptoJS from 'crypto-js';
export default {
data() {
return {
title: '',
content: '',
isProcessing: false,
result: null
};
},
async mounted() {
await web3Provider.init();
await contentService.init();
},
methods: {
async registerContent() {
this.isProcessing = true;
this.result = null;
try {
// 1. ์ฝํ
์ธ ํด์ ์์ฑ
const contentHash = CryptoJS.SHA256(this.content).toString();
// 2. ๋ฐฑ์๋์ ์ฝํ
์ธ ์ ์ฅ
const response = await axios.post('/api/contents', {
title: this.title,
content: this.content,
hash: contentHash
});
// 3. ๋ธ๋ก์ฒด์ธ์ ๋ฑ๋ก
const result = await contentService.registerContent(
contentHash,
this.title
);
if (result.success) {
// 4. ๋ฐฑ์๋์ ๋ธ๋ก์ฒด์ธ ์ ๋ณด ์
๋ฐ์ดํธ
await axios.patch(`/api/contents/${response.data.id}`, {
blockchain_id: result.contentId,
transaction_hash: result.transactionHash
});
this.result = result;
this.title = '';
this.content = '';
}
} catch (error) {
console.error('Error:', error);
alert('Failed to register content');
} finally {
this.isProcessing = false;
}
}
}
};
</script>
โ๏ธ ๋ฐฑ์๋ API ๊ตฌํ
๋ผ๋ผ๋ฒจ์์ ์ฝํ ์ธ ๋ฅผ ๊ด๋ฆฌํ๋ API๋ฅผ ๋ง๋ค์ด๋ณด์. ๋จผ์ ๋ชจ๋ธ๊ณผ ๋ง์ด๊ทธ๋ ์ด์ ์ ์์ฑํด:
php artisan make:model Content -m
๋ง์ด๊ทธ๋ ์ด์ ํ์ผ์ ์์ ํด:
// database/migrations/xxxx_create_contents_table.php
public function up()
{
Schema::create('contents', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->string('hash')->unique();
$table->unsignedBigInteger('blockchain_id')->nullable();
$table->string('transaction_hash')->nullable();
$table->string('author_address')->nullable();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->enum('status', ['draft', 'published', 'archived'])->default('draft');
$table->timestamps();
$table->index('blockchain_id');
$table->index('author_address');
});
}
Content ๋ชจ๋ธ์ ๊ด๊ณ์ ๋ฉ์๋๋ฅผ ์ถ๊ฐํด:
// app/Models/Content.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Content extends Model
{
protected $fillable = [
'title',
'content',
'hash',
'blockchain_id',
'transaction_hash',
'author_address',
'user_id',
'status'
];
protected $casts = [
'blockchain_id' => 'integer',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function isOnBlockchain()
{
return !is_null($this->blockchain_id);
}
public function getBlockchainUrl()
{
if (!$this->transaction_hash) {
return null;
}
$network = config('blockchain.network');
$baseUrl = config("blockchain.explorer_urls.{$network}");
return "{$baseUrl}/tx/{$this->transaction_hash}";
}
}
์ปจํธ๋กค๋ฌ๋ฅผ ์์ฑํ๊ณ CRUD ๋ก์ง์ ๊ตฌํํด:
// app/Http/Controllers/Api/ContentController.php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Content;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
class ContentController extends Controller
{
public function index(Request $request)
{
$query = Content::with('user')
->where('status', 'published');
if ($request->has('author_address')) {
$query->where('author_address', $request->author_address);
}
$contents = $query->latest()->paginate(20);
return response()->json($contents);
}
public function store(Request $request)
{
$validated = $request->validate([
'title' => 'required|string|max:255',
'content' => 'required|string',
'hash' => 'required|string|unique:contents'
]);
$content = Content::create([
'title' => $validated['title'],
'content' => $validated['content'],
'hash' => $validated['hash'],
'user_id' => auth()->id(),
'status' => 'draft'
]);
return response()->json($content, 201);
}
public function show($id)
{
$content = Content::with('user')->findOrFail($id);
return response()->json($content);
}
public function update(Request $request, $id)
{
$content = Content::findOrFail($id);
// ๊ถํ ์ฒดํฌ
if ($content->user_id !== auth()->id()) {
return response()->json([
'message' => 'Unauthorized'
], 403);
}
$validated = $request->validate([
'title' => 'sometimes|string|max:255',
'content' => 'sometimes|string',
'blockchain_id' => 'sometimes|integer',
'transaction_hash' => 'sometimes|string',
'author_address' => 'sometimes|string',
'status' => 'sometimes|in:draft,published,archived'
]);
$content->update($validated);
return response()->json($content);
}
public function destroy($id)
{
$content = Content::findOrFail($id);
if ($content->user_id !== auth()->id()) {
return response()->json([
'message' => 'Unauthorized'
], 403);
}
// ๋ธ๋ก์ฒด์ธ์ ๋ฑ๋ก๋ ์ฝํ
์ธ ๋ ์์ ์ญ์ ๋ถ๊ฐ
if ($content->isOnBlockchain()) {
$content->update(['status' => 'archived']);
return response()->json([
'message' => 'Content archived (blockchain record preserved)'
]);
}
$content->delete();
return response()->json([
'message' => 'Content deleted'
]);
}
public function verify(Request $request, $id)
{
$content = Content::findOrFail($id);
$validated = $request->validate([
'content' => 'required|string'
]);
$hash = hash('sha256', $validated['content']);
return response()->json([
'is_valid' => $hash === $content->hash,
'stored_hash' => $content->hash,
'computed_hash' => $hash
]);
}
}
๋ผ์ฐํธ๋ฅผ ๋ฑ๋กํด:
// routes/api.php
use App\Http\Controllers\Api\ContentController;
Route::middleware('auth:sanctum')->group(function () {
Route::apiResource('contents', ContentController::class);
Route::post('contents/{id}/verify', [ContentController::class, 'verify']);
});
๐ ๋ฉํ๋ง์คํฌ ์ฐ๋ ๋ฐ ์ธ์ฆ
๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์์ ์ฌ์ฉ์ ์ธ์ฆ์ ์ ํต์ ์ธ ๋ฐฉ์๊ณผ ์ข ๋ฌ๋ผ. ๋ฉํ๋ง์คํฌ ๊ฐ์ ์ง๊ฐ์ ํตํด ์๋ช ์ ๋ฐ์์ ์ธ์ฆํ๋ ๋ฐฉ์์ ๊ตฌํํด๋ณด์!
๐ Web3 ์ธ์ฆ ์์คํ
๋ฉํ๋ง์คํฌ๋ก ๋ก๊ทธ์ธํ๋ ํ๋ก์ฐ๋ ์ด๋ ๊ฒ ๋์ํด:
// resources/js/web3/auth.js
import web3Provider from './provider';
import axios from 'axios';
class Web3Auth {
async login() {
try {
// 1. Web3 ์ด๊ธฐํ ๋ฐ ๊ณ์ ๊ฐ์ ธ์ค๊ธฐ
const initialized = await web3Provider.init();
if (!initialized) {
throw new Error('Failed to initialize Web3');
}
const account = web3Provider.getAccount();
const web3 = web3Provider.getWeb3();
// 2. ๋ฐฑ์๋์์ nonce ์์ฒญ
const nonceResponse = await axios.post('/api/auth/nonce', {
address: account
});
const nonce = nonceResponse.data.nonce;
// 3. ๋ฉ์์ง ์๋ช
const message = `Sign this message to authenticate with Blockchain CMS.\n\nNonce: ${nonce}`;
const signature = await web3.eth.personal.sign(
message,
account,
''
);
// 4. ์๋ช
๊ฒ์ฆ ๋ฐ ํ ํฐ ๋ฐ๊ธ
const authResponse = await axios.post('/api/auth/verify', {
address: account,
signature: signature,
message: message
});
// 5. ํ ํฐ ์ ์ฅ
localStorage.setItem('auth_token', authResponse.data.token);
localStorage.setItem('wallet_address', account);
return {
success: true,
token: authResponse.data.token,
user: authResponse.data.user
};
} catch (error) {
console.error('Login error:', error);
return {
success: false,
error: error.message
};
}
}
async logout() {
localStorage.removeItem('auth_token');
localStorage.removeItem('wallet_address');
await axios.post('/api/auth/logout');
}
isAuthenticated() {
return !!localStorage.getItem('auth_token');
}
getToken() {
return localStorage.getItem('auth_token');
}
getWalletAddress() {
return localStorage.getItem('wallet_address');
}
}
export default new Web3Auth();
๋ฐฑ์๋ ์ธ์ฆ ์ปจํธ๋กค๋ฌ:
// app/Http/Controllers/Api/AuthController.php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Cache;
use Laravel\Sanctum\PersonalAccessToken;
class AuthController extends Controller
{
public function nonce(Request $request)
{
$validated = $request->validate([
'address' => 'required|string'
]);
$address = strtolower($validated['address']);
$nonce = Str::random(32);
// nonce๋ฅผ 5๋ถ๊ฐ ์บ์์ ์ ์ฅ
Cache::put("auth_nonce:{$address}", $nonce, 300);
return response()->json([
'nonce' => $nonce
]);
}
public function verify(Request $request)
{
$validated = $request->validate([
'address' => 'required|string',
'signature' => 'required|string',
'message' => 'required|string'
]);
$address = strtolower($validated['address']);
$signature = $validated['signature'];
$message = $validated['message'];
// nonce ํ์ธ
$cachedNonce = Cache::get("auth_nonce:{$address}");
if (!$cachedNonce || !str_contains($message, $cachedNonce)) {
return response()->json([
'message' => 'Invalid nonce'
], 401);
}
// ์๋ช
๊ฒ์ฆ
$recoveredAddress = $this->recoverAddress($message, $signature);
if (strtolower($recoveredAddress) !== $address) {
return response()->json([
'message' => 'Invalid signature'
], 401);
}
// nonce ์ญ์ (์ฌ์ฌ์ฉ ๋ฐฉ์ง)
Cache::forget("auth_nonce:{$address}");
// ์ฌ์ฉ์ ์ฐพ๊ธฐ ๋๋ ์์ฑ
$user = User::firstOrCreate(
['wallet_address' => $address],
['name' => "User_{$address}"]
);
// ํ ํฐ ๋ฐ๊ธ
$token = $user->createToken('web3-auth')->plainTextToken;
return response()->json([
'token' => $token,
'user' => $user
]);
}
public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();
return response()->json([
'message' => 'Logged out successfully'
]);
}
private function recoverAddress($message, $signature)
{
// ์ด๋๋ฆฌ์ ์๋ช
๊ฒ์ฆ์ ์ํ ํฌํผ ํจ์
// web3-php ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ ๊ถ์ฅ
$hash = "\x19Ethereum Signed Message:\n" . strlen($message) . $message;
$hash = hash('sha3-256', $hash, true);
// ์ค์ ๊ตฌํ์์๋ elliptic curve ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์
// ์ฌ๊ธฐ์๋ ๊ฐ๋
์ ์ค๋ช
์ ์ํ ์์ฌ์ฝ๋
return '0x...'; // ๋ณต๊ตฌ๋ ์ฃผ์ ๋ฐํ
}
}
์ค์ ํ๋ก๋์ ํ๊ฒฝ์์๋ web3-php ๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด์ ์๋ช ์ ๊ฒ์ฆํด์ผ ํด. PHP์์ ์ง์ ํ์๊ณก์ ์ํธํ๋ฅผ ๊ตฌํํ๋ ๊ฑด ๋ณต์กํ๊ณ ์ํํ๊ฑฐ๋ ! ๐
2. ์๋ช ๊ฒ์ฆ์ ์๋ฒ ์ฌ์ด๋์์ ๋ฐ๋์ ์ํํด์ผ ํด
3. HTTPS๋ฅผ ์ฌ์ฉํด์ ์ค๊ฐ์ ๊ณต๊ฒฉ์ ๋ฐฉ์งํด์ผ ํด
4. Rate limiting์ ์ ์ฉํด์ brute force ๊ณต๊ฒฉ์ ๋ง์์ผ ํด
๐ฆ IPFS ํตํฉํ๊ธฐ
ํฐ ํ์ผ์ด๋ ๋ฏธ๋์ด ์ฝํ ์ธ ๋ฅผ ๋ธ๋ก์ฒด์ธ์ ์ง์ ์ ์ฅํ๋ ๊ฑด ๋นํ์ค์ ์ด์ผ. ๋์ IPFS(InterPlanetary File System)๋ผ๋ ๋ถ์ฐ ํ์ผ ์์คํ ์ ์ฌ์ฉํ๋ฉด ์๋ฒฝํด! ๐
๐ IPFS๋?
IPFS๋ ์ฝํ
์ธ ์ฃผ์ ์ง์ ๋ฐฉ์์ ์ฌ์ฉํ๋ ๋ถ์ฐ ํ์ผ ์์คํ
์ด์ผ. ํ์ผ์ ์
๋ก๋ํ๋ฉด ๊ณ ์ ํ ํด์(CID)๊ฐ ์์ฑ๋๊ณ , ์ด ํด์๋ก ์ ์ธ๊ณ ์ด๋์๋ ํ์ผ์ ์ ๊ทผํ ์ ์์ด.
๋ธ๋ก์ฒด์ธ + IPFS ์กฐํฉ์ ์ ๋ง ๊ฐ๋ ฅํด:
โข IPFS์ ํ์ผ ์ ์ฅ โ CID ํ๋
โข ๋ธ๋ก์ฒด์ธ์ CID ์ ์ฅ โ ๋ถ๋ณ์ฑ ๋ณด์ฅ
โข ๋๊ตฌ๋ CID๋ก ํ์ผ ๊ฒ์ฆ ๊ฐ๋ฅ โจ
๐ค IPFS ํด๋ผ์ด์ธํธ ์ค์
Pinata๋ Infura ๊ฐ์ IPFS ๊ฒ์ดํธ์จ์ด ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ฉด ์ฝ๊ฒ ์์ํ ์ ์์ด:
npm install ipfs-http-client
IPFS ์๋น์ค ํด๋์ค ์์ฑ:
// resources/js/services/ipfsService.js
import { create } from 'ipfs-http-client';
class IPFSService {
constructor() {
this.client = create({
host: 'ipfs.infura.io',
port: 5001,
protocol: 'https',
headers: {
authorization: 'Basic ' + btoa(
process.env.MIX_INFURA_PROJECT_ID + ':' +
process.env.MIX_INFURA_PROJECT_SECRET
)
}
});
}
async uploadFile(file) {
try {
const added = await this.client.add(file, {
progress: (prog) => console.log(`Uploaded: ${prog}`)
});
return {
success: true,
cid: added.cid.toString(),
path: added.path,
size: added.size
};
} catch (error) {
console.error('IPFS upload error:', error);
return {
success: false,
error: error.message
};
}
}
async uploadJSON(data) {
try {
const jsonString = JSON.stringify(data);
const added = await this.client.add(jsonString);
return {
success: true,
cid: added.cid.toString()
};
} catch (error) {
console.error('IPFS JSON upload error:', error);
return {
success: false,
error: error.message
};
}
}
getGatewayUrl(cid) {
return `https://ipfs.io/ipfs/${cid}`;
}
async getContent(cid) {
try {
const stream = this.client.cat(cid);
let data = '';
for await (const chunk of stream) {
data += chunk.toString();
}
return {
success: true,
data: data
};
} catch (error) {
console.error('IPFS get error:', error);
return {
success: false,
error: error.message
};
}
}
}
export default new IPFSService();
Vue ์ปดํฌ๋ํธ์์ IPFS ์ ๋ก๋ ์ฌ์ฉํ๊ธฐ:
// resources/js/components/IPFSUploader.vue
<template>
<div class="ipfs-uploader">
<input
type="file"
@change="handleFileSelect"
ref="fileInput"
/>
<button
@click="uploadToIPFS"
:disabled="!selectedFile || isUploading"
>
{{ isUploading ? 'Uploading...' : 'Upload to IPFS' }}
</button>
<div v-if="uploadResult" class="result">
<p>CID: {{ uploadResult.cid }}</p>
<a :href="getGatewayUrl(uploadResult.cid)" target="_blank">
View on IPFS
</a>
</div>
</div>
</template>
<script>
import ipfsService from '../services/ipfsService';
export default {
data() {
return {
selectedFile: null,
isUploading: false,
uploadResult: null
};
},
methods: {
handleFileSelect(event) {
this.selectedFile = event.target.files[0];
},
async uploadToIPFS() {
if (!this.selectedFile) return;
this.isUploading = true;
try {
const result = await ipfsService.uploadFile(this.selectedFile);
if (result.success) {
this.uploadResult = result;
this.$emit('uploaded', result);
} else {
alert('Upload failed: ' + result.error);
}
} finally {
this.isUploading = false;
}
},
getGatewayUrl(cid) {
return ipfsService.getGatewayUrl(cid);
}
}
};
</script>
๐ ๋ธ๋ก์ฒด์ธ + IPFS ํตํฉ ์ํฌํ๋ก์ฐ
์์ ํ ์ํฌํ๋ก์ฐ๋ ์ด๋ ๊ฒ ๋์ํด:
// ํตํฉ ์ฝํ
์ธ ๋ฑ๋ก ํ๋ก์ธ์ค
async function registerContentWithIPFS(title, content, file) {
try {
// 1. ํ์ผ์ IPFS์ ์
๋ก๋
const ipfsResult = await ipfsService.uploadFile(file);
if (!ipfsResult.success) {
throw new Error('IPFS upload failed');
}
// 2. ๋ฉํ๋ฐ์ดํฐ ๊ฐ์ฒด ์์ฑ
const metadata = {
title: title,
content: content,
ipfsCID: ipfsResult.cid,
timestamp: Date.now(),
fileSize: ipfsResult.size
};
// 3. ๋ฉํ๋ฐ์ดํฐ๋ฅผ IPFS์ ์
๋ก๋
const metadataResult = await ipfsService.uploadJSON(metadata);
if (!metadataResult.success) {
throw new Error('Metadata upload failed');
}
// 4. ๋ฉํ๋ฐ์ดํฐ CID๋ฅผ ๋ธ๋ก์ฒด์ธ์ ๋ฑ๋ก
const blockchainResult = await contentService.registerContent(
metadataResult.cid,
title
);
if (!blockchainResult.success) {
throw new Error('Blockchain registration failed');
}
// 5. ๋ฐฑ์๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ชจ๋ ์ ๋ณด ์ ์ฅ
const dbResult = await axios.post('/api/contents', {
title: title,
content: content,
ipfs_cid: ipfsResult.cid,
metadata_cid: metadataResult.cid,
blockchain_id: blockchainResult.contentId,
transaction_hash: blockchainResult.transactionHash
});
return {
success: true,
data: dbResult.data
};
} catch (error) {
console.error('Registration error:', error);
return {
success: false,
error: error.message
};
}
}
์ด๋ ๊ฒ ํ๋ฉด ํ์ผ์ IPFS์, ๋ฉํ๋ฐ์ดํฐ๋ ๋ธ๋ก์ฒด์ธ์, ์ ์ฒด ์ ๋ณด๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ๋๋ ์๋ฒฝํ 3์ค ๊ตฌ์กฐ๊ฐ ์์ฑ๋ผ! ๐ฏ
โข ํฐ ํ์ผ์ ์ฒญํฌ๋ก ๋๋ ์ ์ ๋ก๋ํ๋ฉด ํจ์จ์ ์ด์ผ
โข CID๋ ์ฝํ ์ธ ๊ธฐ๋ฐ ์ฃผ์๋ผ์ ํ์ผ์ด ์กฐ๊ธ์ด๋ผ๋ ๋ณ๊ฒฝ๋๋ฉด ์์ ํ ๋ค๋ฅธ CID๊ฐ ์์ฑ๋ผ
โข ํ๋ผ์ด๋น ๋ฐ์ดํฐ๋ ์ํธํํ ํ IPFS์ ์ ๋ก๋ํด์ผ ํด! ๐
โก ์ฑ๋ฅ ์ต์ ํ ์ ๋ต
๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ผ๋ฐ ์น์ฑ๋ณด๋ค ๋๋ฆด ์ ์์ด. ํธ๋์ญ์ ํ์ธ ์๊ฐ, ๊ฐ์ค๋น, ๋คํธ์ํฌ ์ง์ฐ ๋ฑ์ ๊ณ ๋ คํด์ผ ํ๊ฑฐ๋ . ์ฑ๋ฅ์ ์ต์ ํํ๋ ๋ช ๊ฐ์ง ์ ๋ต์ ์์๋ณด์! ๐
๐ ์บ์ฑ ์ ๋ต
๋ธ๋ก์ฒด์ธ ๋ฐ์ดํฐ๋ ๋ถ๋ณ์ด๋๊น ์ ๊ทน์ ์ผ๋ก ์บ์ฑํ ์ ์์ด:
// app/Services/BlockchainCacheService.php
namespace App\Services;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis;
class BlockchainCacheService
{
protected $ttl = 3600; // 1์๊ฐ
public function getContent($blockchainId)
{
$cacheKey = "blockchain:content:{$blockchainId}";
return Cache::remember($cacheKey, $this->ttl, function () use ($blockchainId) {
// ๋ธ๋ก์ฒด์ธ์์ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ
return $this->fetchFromBlockchain($blockchainId);
});
}
public function getAuthorContents($authorAddress)
{
$cacheKey = "blockchain:author:{$authorAddress}";
return Cache::remember($cacheKey, $this->ttl, function () use ($authorAddress) {
return $this->fetchAuthorContents($authorAddress);
});
}
public function invalidateContent($blockchainId)
{
$cacheKey = "blockchain:content:{$blockchainId}";
Cache::forget($cacheKey);
}
public function cacheTransaction($transactionHash, $data)
{
$cacheKey = "blockchain:tx:{$transactionHash}";
Cache::put($cacheKey, $data, $this->ttl * 24); // 24์๊ฐ
}
private function fetchFromBlockchain($blockchainId)
{
// ์ค์ ๋ธ๋ก์ฒด์ธ ์กฐํ ๋ก์ง
// web3-php ์ฌ์ฉ
return [];
}
private function fetchAuthorContents($authorAddress)
{
// ์ค์ ๋ธ๋ก์ฒด์ธ ์กฐํ ๋ก์ง
return [];
}
}
๐ ๋น๋๊ธฐ ์ฒ๋ฆฌ
๋ธ๋ก์ฒด์ธ ํธ๋์ญ์ ์ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋๊น ํ๋ฅผ ์ฌ์ฉํด์ ๋น๋๊ธฐ๋ก ์ฒ๋ฆฌํ์:
// app/Jobs/RegisterContentOnBlockchain.php
namespace App\Jobs;
use App\Models\Content;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class RegisterContentOnBlockchain implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $content;
public function __construct(Content $content)
{
$this->content = $content;
}
public function handle()
{
try {
// ๋ธ๋ก์ฒด์ธ์ ๋ฑ๋ก
$result = $this->registerOnBlockchain(
$this->content->hash,
$this->content->title
);
// ๊ฒฐ๊ณผ ์
๋ฐ์ดํธ
$this->content->update([
'blockchain_id' => $result['contentId'],
'transaction_hash' => $result['transactionHash'],
'status' => 'published'
]);
// ์ฌ์ฉ์์๊ฒ ์๋ฆผ
$this->content->user->notify(
new ContentPublishedNotification($this->content)
);
} catch (\Exception $e) {
// ์คํจ ์ฒ๋ฆฌ
$this->content->update([
'status' => 'failed',
'error_message' => $e->getMessage()
]);
// ์ฌ์๋
$this->release(60); // 60์ด ํ ์ฌ์๋
}
}
private function registerOnBlockchain($hash, $title)
{
// web3-php๋ฅผ ์ฌ์ฉํ ์ค์ ๋ธ๋ก์ฒด์ธ ๋ฑ๋ก ๋ก์ง
return [
'contentId' => 123,
'transactionHash' => '0x...'
];
}
}
์ปจํธ๋กค๋ฌ์์ ํ ๋์คํจ์น:
public function store(Request $request)
{
$validated = $request->validate([
'title' => 'required|string|max:255',
'content' => 'required|string'
]);
$content = Content::create([
'title' => $validated['title'],
'content' => $validated['content'],
'hash' => hash('sha256', $validated['content']),
'user_id' => auth()->id(),
'status' => 'pending'
]);
// ๋น๋๊ธฐ๋ก ๋ธ๋ก์ฒด์ธ ๋ฑ๋ก
RegisterContentOnBlockchain::dispatch($content);
return response()->json([
'message' => 'Content is being registered on blockchain',
'content' => $content
], 202);
}
๐ฐ ๊ฐ์ค๋น ์ต์ ํ
๊ฐ์ค๋น๋ฅผ ์ค์ด๋ ์ค๋งํธ ์ปจํธ๋ํธ ์ต์ ํ ํ:
// ์ต์ ํ๋ ์ปจํธ๋ํธ ์์
contract OptimizedContentRegistry {
// string ๋์ bytes32 ์ฌ์ฉ (๊ฐ์ค๋น ์ ์ฝ)
struct Content {
bytes32 contentHash;
address author;
uint40 timestamp; // uint256 ๋์ uint40 ์ฌ์ฉ
bool isActive;
}
// mapping์ด array๋ณด๋ค ๊ฐ์ค๋น๊ฐ ์ ๋ ด
mapping(uint256 => Content) public contents;
mapping(address => uint256[]) private authorContents;
uint256 public contentCount;
// ์ด๋ฒคํธ๋ storage๋ณด๋ค ์ ๋ ด
event ContentRegistered(
uint256 indexed contentId,
address indexed author,
bytes32 contentHash
);
function registerContent(bytes32 _contentHash)
external
returns (uint256)
{
contentCount++;
contents[contentCount] = Content({
contentHash: _contentHash,
author: msg.sender,
timestamp: uint40(block.timestamp),
isActive: true
});
authorContents[msg.sender].push(contentCount);
emit ContentRegistered(
contentCount,
msg.sender,
_contentHash
);
return contentCount;
}
// view ํจ์๋ ๊ฐ์ค๋น ์์
function getContent(uint256 _contentId)
external
view
returns (bytes32, address, uint40, bool)
{
Content memory content = contents[_contentId];
return (
content.contentHash,
content.author,
content.timestamp,
content.isActive
);
}
}
๐ก ์ด๋ฒคํธ ๋ฆฌ์ค๋
๋ธ๋ก์ฒด์ธ ์ด๋ฒคํธ๋ฅผ ์ค์๊ฐ์ผ๋ก ๊ฐ์งํด์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๋๊ธฐํํ์:
// resources/js/services/eventListener.js
class BlockchainEventListener {
constructor(contract) {
this.contract = contract;
this.listeners = new Map();
}
async startListening() {
// ContentRegistered ์ด๋ฒคํธ ๊ตฌ๋
this.contract.events.ContentRegistered({
fromBlock: 'latest'
})
.on('data', async (event) => {
await this.handleContentRegistered(event);
})
.on('error', console.error);
// ContentUpdated ์ด๋ฒคํธ ๊ตฌ๋
this.contract.events.ContentUpdated({
fromBlock: 'latest'
})
.on('data', async (event) => {
await this.handleContentUpdated(event);
})
.on('error', console.error);
}
async handleContentRegistered(event) {
const { contentId, author, contentHash } = event.returnValues;
// ๋ฐฑ์๋์ ์๋ฆผ
await axios.post('/api/blockchain/events/content-registered', {
content_id: contentId,
author: author,
content_hash: contentHash,
transaction_hash: event.transactionHash,
block_number: event.blockNumber
});
}
async handleContentUpdated(event) {
const { contentId, newContentHash } = event.returnValues;
await axios.post('/api/blockchain/events/content-updated', {
content_id: contentId,
new_content_hash: newContentHash,
transaction_hash: event.transactionHash
});
}
stopListening() {
// ๋ชจ๋ ๋ฆฌ์ค๋ ์ ๋ฆฌ
this.listeners.forEach(listener => {
listener.unsubscribe();
});
this.listeners.clear();
}
}
export default BlockchainEventListener;
โ ๋ฌด๊ฑฐ์ด ์์ ์ ํ๋ก ๋น๋๊ธฐ ์ฒ๋ฆฌ
โ ๊ฐ์ค๋น ์ต์ ํ๋ฅผ ์ํด ๋ฐ์ดํฐ ํ์ ์ ์คํ ์ ํ
โ ์ด๋ฒคํธ๋ฅผ ํ์ฉํด์ ํด๋ง ์ต์ํ
โ ๋ ์ด์ด2 ์๋ฃจ์ (Polygon, Arbitrum) ๊ณ ๋ ค
โ ๋ฐฐ์น ์ฒ๋ฆฌ๋ก ์ฌ๋ฌ ํธ๋์ญ์ ๋ฌถ๊ธฐ
๐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ณด์์ด ์ ๋ง ์ค์ํด. ํ๋ฒ ๋ฐฐํฌ๋ ์ค๋งํธ ์ปจํธ๋ํธ๋ ์์ ์ด ์ด๋ ต๊ณ , ํดํน๋นํ๋ฉด ์๊ธ ์์ค๋ก ์ด์ด์ง ์ ์๊ฑฐ๋ ! ๐ฑ
๐ก๏ธ ์ค๋งํธ ์ปจํธ๋ํธ ๋ณด์
์ปจํธ๋ํธ ์์ฑ ์ ์ฃผ์ํ ์ ๋ค:
// ์์ ํ ์ปจํธ๋ํธ ํจํด
contract SecureContentRegistry {
using SafeMath for uint256; // ์ค๋ฒํ๋ก์ฐ ๋ฐฉ์ง
address public owner;
bool public paused; // ๊ธด๊ธ ์ ์ง ๊ธฐ๋ฅ
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
modifier whenNotPaused() {
require(!paused, "Contract is paused");
_;
}
modifier validContentId(uint256 _contentId) {
require(_contentId > 0 && _contentId <= contentCount, "Invalid ID");
_;
}
constructor() {
owner = msg.sender;
paused = false;
}
// ์ฌ์ง์
๊ณต๊ฒฉ ๋ฐฉ์ง ํจํด
bool private locked;
modifier noReentrant() {
require(!locked, "No reentrancy");
locked = true;
_;
locked = false;
}
function registerContent(bytes32 _contentHash)
external
whenNotPaused
noReentrant
returns (uint256)
{
require(_contentHash != bytes32(0), "Invalid hash");
contentCount = contentCount.add(1); // SafeMath ์ฌ์ฉ
contents[contentCount] = Content({
contentHash: _contentHash,
author: msg.sender,
timestamp: uint40(block.timestamp),
isActive: true
});
emit ContentRegistered(contentCount, msg.sender, _contentHash);
return contentCount;
}
// ๊ธด๊ธ ์ ์ง ๊ธฐ๋ฅ
function pause() external onlyOwner {
paused = true;
}
function unpause() external onlyOwner {
paused = false;
}
// ์์ ๊ถ ์ด์
function transferOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "Invalid address");
owner = newOwner;
}
}
๐ ๋ฐฑ์๋ ๋ณด์
๋ผ๋ผ๋ฒจ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ณด์ ๊ฐํ:
// app/Http/Middleware/VerifyBlockchainSignature.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class VerifyBlockchainSignature
{
public function handle(Request $request, Closure $next)
{
// ๋ธ๋ก์ฒด์ธ ๊ด๋ จ ์์ฒญ์ ์๋ช
๊ฒ์ฆ
if ($request->is('api/blockchain/*')) {
$signature = $request->header('X-Signature');
$address = $request->header('X-Address');
if (!$signature || !$address) {
return response()->json([
'message' => 'Missing signature or address'
], 401);
}
// ์๋ช
๊ฒ์ฆ ๋ก์ง
if (!$this->verifySignature($request, $signature, $address)) {
return response()->json([
'message' => 'Invalid signature'
], 401);
}
$request->merge(['verified_address' => $address]);
}
return $next($request);
}
private function verifySignature($request, $signature, $address)
{
// ์ค์ ์๋ช
๊ฒ์ฆ ๊ตฌํ
return true;
}
}
Rate Limiting ์ ์ฉ:
// app/Providers/RouteServiceProvider.php
protected function configureRateLimiting()
{
RateLimiter::for('blockchain', function (Request $request) {
return Limit::perMinute(10)->by(
$request->header('X-Address') ?: $request->ip()
);
});
}
// routes/api.php
Route::middleware(['auth:sanctum', 'throttle:blockchain'])
->group(function () {
Route::post('/blockchain/register', [BlockchainController::class, 'register']);
});
๐ ํ๋ผ์ด๋น ํค ๊ด๋ฆฌ
์ ๋๋ก ํ๋ผ์ด๋น ํค๋ฅผ ์ฝ๋์ ํ๋์ฝ๋ฉํ๋ฉด ์ ๋ผ! ํ๊ฒฝ ๋ณ์์ ์ํธํ๋ฅผ ์ฌ์ฉํ์:
// .env
BLOCKCHAIN_NETWORK=mainnet
BLOCKCHAIN_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
BLOCKCHAIN_PRIVATE_KEY=encrypted:xxxxx
// config/blockchain.php
return [
'network' => env('BLOCKCHAIN_NETWORK', 'testnet'),
'rpc_url' => env('BLOCKCHAIN_RPC_URL'),
'private_key' => env('BLOCKCHAIN_PRIVATE_KEY'),
'contract_address' => env('CONTRACT_ADDRESS'),
'networks' => [
'mainnet' => [
'chain_id' => 1,
'explorer' => 'https://etherscan.io'
],
'goerli' => [
'chain_id' => 5,
'explorer' => 'https://goerli.etherscan.io'
],
'polygon' => [
'chain_id' => 137,
'explorer' => 'https://polygonscan.com'
]
]
];
ํ๋ผ์ด๋น ํค๋ Laravel์ ์ํธํ ๊ธฐ๋ฅ์ ์ฌ์ฉํด์ ์ ์ฅ:
// ์ํธํ
$encryptedKey = encrypt($privateKey);
// ๋ณตํธํ
$privateKey = decrypt(config('blockchain.private_key'));
- โ ๏ธ ๋ณด์ ์ฒดํฌ๋ฆฌ์คํธ:
- โ ํ๋ผ์ด๋น ํค๋ฅผ ์ฝ๋์ ํ๋์ฝ๋ฉํ์ง ๋ง ๊ฒ
- โ ํ๋ก ํธ์๋์์ ๋ฏผ๊ฐํ ๋ก์ง ์ฒ๋ฆฌํ์ง ๋ง ๊ฒ
- โ ์ฌ์ฉ์ ์ ๋ ฅ์ ๊ฒ์ฆ ์์ด ์ปจํธ๋ํธ์ ์ ๋ฌํ์ง ๋ง ๊ฒ
- โ ๋ชจ๋ ํธ๋์ญ์ ์ ๊ฐ์ค ๋ฆฌ๋ฏธํธ ์ค์
- โ ์ค๋งํธ ์ปจํธ๋ํธ ๊ฐ์ฌ(Audit) ๋ฐ๊ธฐ
- โ ํ ์คํธ๋ท์์ ์ถฉ๋ถํ ํ ์คํธ ํ ๋ฉ์ธ๋ท ๋ฐฐํฌ
- โ ๋ฉํฐ์๊ทธ ์ง๊ฐ ์ฌ์ฉ ๊ณ ๋ ค
๐งช ํ ์คํธ ์ ๋ต
๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ํ ์คํธ๊ฐ ํนํ ์ค์ํด. ๋ฉ์ธ๋ท์ ๋ฐฐํฌํ๋ฉด ์์ ์ด ์ด๋ ต๊ณ ์ค์๊ฐ ํฐ ๋น์ฉ์ผ๋ก ์ด์ด์ง ์ ์๊ฑฐ๋ !
๐ฌ ์ค๋งํธ ์ปจํธ๋ํธ ํ ์คํธ
Hardhat์ ์ฌ์ฉํ ์ปจํธ๋ํธ ํ ์คํธ:
// test/ContentRegistry.test.js
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("ContentRegistry", function () {
let contentRegistry;
let owner;
let addr1;
let addr2;
beforeEach(async function () {
[owner, addr1, addr2] = await ethers.getSigners();
const ContentRegistry = await ethers.getContractFactory("ContentRegistry");
contentRegistry = await ContentRegistry.deploy();
await contentRegistry.deployed();
});
describe("Content Registration", function () {
it("Should register content successfully", async function () {
const contentHash = ethers.utils.formatBytes32String("test-hash");
const title = "Test Content";
await expect(
contentRegistry.connect(addr1).registerContent(contentHash, title)
)
.to.emit(contentRegistry, "ContentRegistered")
.withArgs(1, addr1.address, contentHash, anyValue);
const content = await contentRegistry.getContent(1);
expect(content[0]).to.equal(contentHash);
expect(content[1]).to.equal(addr1.address);
});
it("Should increment content count", async function () {
const hash1 = ethers.utils.formatBytes32String("hash1");
const hash2 = ethers.utils.formatBytes32String("hash2");
await contentRegistry.registerContent(hash1, "Title 1");
await contentRegistry.registerContent(hash2, "Title 2");
const count = await contentRegistry.contentCount();
expect(count).to.equal(2);
});
it("Should track author contents", async function () {
const hash1 = ethers.utils.formatBytes32String("hash1");
const hash2 = ethers.utils.formatBytes32String("hash2");
await contentRegistry.connect(addr1).registerContent(hash1, "Title 1");
await contentRegistry.connect(addr1).registerContent(hash2, "Title 2");
const authorContents = await contentRegistry.getAuthorContents(addr1.address);
expect(authorContents.length).to.equal(2);
});
});
describe("Content Update", function () {
it("Should allow author to update content", async function () {
const originalHash = ethers.utils.formatBytes32String("original");
const newHash = ethers.utils.formatBytes32String("updated");
await contentRegistry.connect(addr1).registerContent(originalHash, "Title");
await expect(
contentRegistry.connect(addr1).updateContent(1, newHash)
)
.to.emit(contentRegistry, "ContentUpdated")
.withArgs(1, newHash);
const content = await contentRegistry.getContent(1);
expect(content[0]).to.equal(newHash);
});
it("Should reject update from non-author", async function () {
const hash = ethers.utils.formatBytes32String("hash");
const newHash = ethers.utils.formatBytes32String("new");
await contentRegistry.connect(addr1).registerContent(hash, "Title");
await expect(
contentRegistry.connect(addr2).updateContent(1, newHash)
).to.be.revertedWith("Only author can update");
});
});
});
ํ ์คํธ ์คํ:
npx hardhat test
npx hardhat coverage
๐งฉ ๋ผ๋ผ๋ฒจ ํตํฉ ํ ์คํธ
PHPUnit์ ์ฌ์ฉํ API ํ ์คํธ:
// tests/Feature/ContentApiTest.php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\User;
use App\Models\Content;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ContentApiTest extends TestCase
{
use RefreshDatabase;
protected $user;
protected function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create([
'wallet_address' => '0x1234567890123456789012345678901234567890'
]);
}
public function test_can_create_content()
{
$response = $this->actingAs($this->user, 'sanctum')
->postJson('/api/contents', [
'title' => 'Test Content',
'content' => 'This is test content',
'hash' => hash('sha256', 'This is test content')
]);
$response->assertStatus(201)
->assertJsonStructure([
'id',
'title',
'content',
'hash',
'user_id'
]);
$this->assertDatabaseHas('contents', [
'title' => 'Test Content',
'user_id' => $this->user->id
]);
}
public function test_can_list_contents()
{
Content::factory()->count(5)->create([
'user_id' => $this->user->id,
'status' => 'published'
]);
$response = $this->getJson('/api/contents');
$response->assertStatus(200)
->assertJsonCount(5, 'data');
}
public function test_can_verify_content_hash()
{
$originalContent = 'Original content';
$hash = hash('sha256', $originalContent);
$content = Content::factory()->create([
'user_id' => $this->user->id,
'content' => $originalContent,
'hash' => $hash
]);
$response = $this->postJson("/api/contents/{$content->id}/verify", [
'content' => $originalContent
]);
$response->assertStatus(200)
->assertJson([
'is_valid' => true
]);
}
public function test_cannot_update_others_content()
{
$otherUser = User::factory()->create();
$content = Content::factory()->create([
'user_id' => $otherUser->id
]);
$response = $this->actingAs($this->user, 'sanctum')
->patchJson("/api/contents/{$content->id}", [
'title' => 'Updated Title'
]);
$response->assertStatus(403);
}
}
ํ ์คํธ ์คํ:
php artisan test
php artisan test --coverage
โข ํ ์คํธ๋ท(Goerli, Sepolia)์์ ์ค์ ํ๊ฒฝ ํ ์คํธ
โข CI/CD ํ์ดํ๋ผ์ธ์ ์๋ ํ ์คํธ ํตํฉ
โข ๊ฐ์ค๋น ์ถ์ ํ ์คํธ๋ ํฌํจ
โข ์ฃ์ง ์ผ์ด์ค์ ์คํจ ์๋๋ฆฌ์ค๋ ๊ผญ ํ ์คํธ! ๐ฏ
๐ ๋ฐฐํฌ ๋ฐ ์ด์
๊ฐ๋ฐ์ด ๋๋ฌ๋ค๋ฉด ์ด์ ์ค์ ํ๊ฒฝ์ ๋ฐฐํฌํ ์ฐจ๋ก์ผ! ๋จ๊ณ๋ณ๋ก ์์ ํ๊ฒ ๋ฐฐํฌํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์.
1๏ธโฃ ํ ์คํธ๋ท ๋ฐฐํฌ
๋จผ์ Goerli๋ Sepolia ๊ฐ์ ํ ์คํธ๋ท์ ๋ฐฐํฌํด์ ๊ฒ์ฆํด:
// hardhat.config.js
module.exports = {
networks: {
goerli: {
url: process.env.GOERLI_RPC_URL,
accounts: [process.env.PRIVATE_KEY],
chainId: 5
},
sepolia: {
url: process.env.SEPOLIA_RPC_URL,
accounts: [process.env.PRIVATE_KEY],
chainId: 11155111
}
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
}
};
// ๋ฐฐํฌ ๋ช
๋ น์ด
npx hardhat run scripts/deploy.js --network goerli
// ์ปจํธ๋ํธ ๊ฒ์ฆ
npx hardhat verify --network goerli DEPLOYED_CONTRACT_ADDRESS
2๏ธโฃ ๋ผ๋ผ๋ฒจ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ
์๋ฒ ํ๊ฒฝ ์ค์ :
# .env.production
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com
DB_CONNECTION=mysql
DB_HOST=your-db-host
DB_DATABASE=your-database
DB_USERNAME=your-username
DB_PASSWORD=your-password
BLOCKCHAIN_NETWORK=mainnet
BLOCKCHAIN_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
CONTRACT_ADDRESS=0xYourContractAddress
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
QUEUE_CONNECTION=redis
๋ฐฐํฌ ์คํฌ๋ฆฝํธ:
#!/bin/bash
# deploy.sh
echo "Starting deployment..."
# Git pull
git pull origin main
# Install dependencies
composer install --no-dev --optimize-autoloader
npm install --production
npm run production
# Run migrations
php artisan migrate --force
# Clear and cache
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Restart queue workers
php artisan queue:restart
# Restart services
sudo systemctl restart php8.1-fpm
sudo systemctl restart nginx
echo "Deployment completed!"
3๏ธโฃ ๋ฉ์ธ๋ท ๋ฐฐํฌ
ํ ์คํธ๊ฐ ์๋ฃ๋๋ฉด ๋ฉ์ธ๋ท์ ๋ฐฐํฌ:
// ๋ฉ์ธ๋ท ๋ฐฐํฌ ์ ์ฒดํฌ๋ฆฌ์คํธ
โ
์ค๋งํธ ์ปจํธ๋ํธ ๊ฐ์ฌ ์๋ฃ
โ
ํ
์คํธ๋ท์์ ์ถฉ๋ถํ ํ
์คํธ ์๋ฃ
โ
๊ฐ์ค๋น ์ต์ ํ ํ์ธ
โ
๊ธด๊ธ ์ ์ง ๊ธฐ๋ฅ ํ
์คํธ
โ
๋ฐฑ์
๋ฐ ๋กค๋ฐฑ ๊ณํ ์๋ฆฝ
// ๋ฐฐํฌ
npx hardhat run scripts/deploy.js --network mainnet
// ๊ฒ์ฆ
npx hardhat verify --network mainnet DEPLOYED_CONTRACT_ADDRESS
๐ ๋ชจ๋ํฐ๋ง ์ค์
์ด์ ์ค ์์คํ ์ ๋ชจ๋ํฐ๋งํ๋ ๊ฑด ํ์์ผ:
// app/Services/BlockchainMonitorService.php
namespace App\Services;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Cache;
class BlockchainMonitorService
{
public function checkContractHealth()
{
try {
// ์ปจํธ๋ํธ ์๋ต ์๊ฐ ์ฒดํฌ
$startTime = microtime(true);
$contentCount = $this->getContentCount();
$responseTime = (microtime(true) - $startTime) * 1000;
// ๋ฉํธ๋ฆญ ๊ธฐ๋ก
$this->recordMetric('contract_response_time', $responseTime);
// ๊ฐ์ค ๊ฐ๊ฒฉ ๋ชจ๋ํฐ๋ง
$gasPrice = $this->getCurrentGasPrice();
$this->recordMetric('gas_price', $gasPrice);
// ์๋ฆผ ์กฐ๊ฑด ์ฒดํฌ
if ($responseTime > 5000) {
$this->sendAlert('High contract response time: ' . $responseTime . 'ms');
}
if ($gasPrice > 100) {
$this->sendAlert('High gas price: ' . $gasPrice . ' gwei');
}
return [
'status' => 'healthy',
'response_time' => $responseTime,
'gas_price' => $gasPrice,
'content_count' => $contentCount
];
} catch (\Exception $e) {
Log::error('Blockchain health check failed', [
'error' => $e->getMessage()
]);
$this->sendAlert('Blockchain health check failed: ' . $e->getMessage());
return [
'status' => 'unhealthy',
'error' => $e->getMessage()
];
}
}
private function recordMetric($name, $value)
{
// ๋ฉํธ๋ฆญ์ ์๊ณ์ด ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ
// InfluxDB, Prometheus ๋ฑ ์ฌ์ฉ
}
private function sendAlert($message)
{
// Slack, Discord, ์ด๋ฉ์ผ ๋ฑ์ผ๋ก ์๋ฆผ ์ ์ก
Log::alert($message);
}
private function getContentCount()
{
// ์ค์ ์ปจํธ๋ํธ ์กฐํ
return 0;
}
private function getCurrentGasPrice()
{
// ํ์ฌ ๊ฐ์ค ๊ฐ๊ฒฉ ์กฐํ
return 0;
}
}
// ์ค์ผ์ค๋ฌ์ ๋ฑ๋ก
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
app(BlockchainMonitorService::class)->checkContractHealth();
})->everyFiveMinutes();
}
โข ์ถฉ๋ถํ ETH๋ฅผ ํ๋ณดํด์ ๊ฐ์ค๋น ๋ถ์กฑ ๋ฐฉ์ง
โข ์ปจํธ๋ํธ ์ ๊ทธ๋ ์ด๋ ์ ๋ต ์๋ฆฝ (Proxy ํจํด ๊ณ ๋ ค)
โข ์ ๊ธฐ์ ์ธ ๋ฐฑ์ ๋ฐ ๋ชจ๋ํฐ๋ง
โข ๊ธด๊ธ ์ํฉ ๋์ ๋งค๋ด์ผ ์ค๋น
๐ฏ ์ค์ ํ์ฉ ์ฌ๋ก
์ด๋ก ์ ์ถฉ๋ถํ ๋ฐฐ์ ์ผ๋ ์ด์ ์ค์ ๋ก ์ด๋ป๊ฒ ํ์ฉํ ์ ์๋์ง ์์๋ณด์! ๋ธ๋ก์ฒด์ธ CMS๋ ๋ค์ํ ๋ถ์ผ์์ ํ์ ์ ๋ง๋ค์ด๋ผ ์ ์์ด. ๐
๐ฐ ํ์ค์ํ ๋ด์ค ํ๋ซํผ
๊ธฐ์ฌ์ ์๋ณธ์ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํด์ ๊ฒ์ด ์ ํญ์ฑ๊ณผ ์ง์ ๊ฒ์ฆ์ด ๊ฐ๋ฅํ ๋ด์ค ํ๋ซํผ์ ๋ง๋ค ์ ์์ด:
โข ๊ธฐ์๊ฐ ๊ธฐ์ฌ๋ฅผ ์์ฑํ๋ฉด ํด์๊ฐ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋ก๋ผ
โข ๋๊ตฌ๋ ์๋ณธ ๊ธฐ์ฌ์ ์ง์๋ฅผ ๊ฒ์ฆํ ์ ์์ด
โข ์์ ์ด๋ ฅ์ด ํฌ๋ช
ํ๊ฒ ๊ณต๊ฐ๋ผ
โข ๋
์๋ค์ด ํ ํฐ์ผ๋ก ์ข์ ๊ธฐ์ฌ์ ๋ณด์ํ ์ ์์ด
์ด๋ฐ ์์คํ
์ ๊ฐ์ง ๋ด์ค ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ์ธ๋ก ์ ์ ๋ขฐ์ฑ์ ๋์ผ ์ ์์ง! ๐ฐ
๐จ NFT ๊ธฐ๋ฐ ๋์งํธ ์ํธ ๊ฐค๋ฌ๋ฆฌ
์ํ์ ์์ ๊ถ๊ณผ ๊ฑฐ๋ ์ด๋ ฅ์ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํ๋ ์ํธ ํ๋ซํผ:
โข ์๊ฐ๊ฐ ์ํ์ ์
๋ก๋ํ๋ฉด ์๋์ผ๋ก NFT ๋ฐํ
โข ์ํ์ ์งํ ์ฌ๋ถ๋ฅผ ๋ธ๋ก์ฒด์ธ์ผ๋ก ๊ฒ์ฆ
โข 2์ฐจ ํ๋งค ์ ์๊ฐ์๊ฒ ๋ก์ดํฐ ์๋ ์ง๊ธ
โข ์ํ์ ์ ์ฒด ์์ ๊ถ ์ด๋ ฅ ์ถ์ ๊ฐ๋ฅ
๋ผ๋ผ๋ฒจ๋ก ๊ฐค๋ฌ๋ฆฌ UI๋ฅผ ๋ง๋ค๊ณ , web3.js๋ก NFT ๊ฑฐ๋๋ฅผ ์ฒ๋ฆฌํ๋ฉด ์๋ฒฝํ ๋์งํธ ์ํธ ๋ง์ผํ๋ ์ด์ค๊ฐ ์์ฑ๋ผ! ๐จ
๐ ํ์ ๋ ผ๋ฌธ ์ ์ฅ์
๋
ผ๋ฌธ์ ์ถํ ์์ ๊ณผ ์ ์๋ฅผ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํด์ ํ์ ์ ๋ฐฉ์งํ๊ณ ์ ํ ์ฐ๊ตฌ๋ฅผ ์ฆ๋ช
ํ ์ ์์ด:
โข ์ฐ๊ตฌ์๊ฐ ๋
ผ๋ฌธ์ ์ ์ถํ๋ฉด ํ์์คํฌํ์ ํจ๊ป ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋ก
โข ๋
ผ๋ฌธ์ ์๋ณธ์ฑ๊ณผ ์ถํ ์์ ์ ๋๊ตฌ๋ ๊ฒ์ฆ ๊ฐ๋ฅ
โข ๋๋ฃ ํ๊ฐ(Peer Review) ๊ณผ์ ๋ ํฌ๋ช
ํ๊ฒ ๊ธฐ๋ก
โข ์ธ์ฉ ๊ด๊ณ๋ฅผ ์ค๋งํธ ์ปจํธ๋ํธ๋ก ์๋ ์ถ์
ํ์ ์ปค๋ฎค๋ํฐ์ ํฌ๋ช
์ฑ๊ณผ ์ ๋ขฐ์ฑ์ ํฌ๊ฒ ํฅ์์ํฌ ์ ์์ด! ๐
๐ต ์์ ์ ์๊ถ ๊ด๋ฆฌ ํ๋ซํผ
์์
์ ์ ์๊ถ๊ณผ ์์ต ๋ถ๋ฐฐ๋ฅผ ์ค๋งํธ ์ปจํธ๋ํธ๋ก ์๋ํ:
โข ์์
๊ฐ๊ฐ ๊ณก์ ๋ฑ๋กํ๋ฉด ์ ์๊ถ์ด ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋ก
โข ์คํธ๋ฆฌ๋ฐ ์์ต์ด ์๋์ผ๋ก ๊ถ๋ฆฌ์๋ค์๊ฒ ๋ถ๋ฐฐ
โข ์ํ๋ง์ด๋ ๋ฆฌ๋ฏน์ค ๊ถํ์ ํ ํฐ์ผ๋ก ๊ฑฐ๋
โข ๋ชจ๋ ์์ต ๋ถ๋ฐฐ ๋ด์ญ์ด ํฌ๋ช
ํ๊ฒ ๊ณต๊ฐ
์ค๊ฐ ์
์ฒด ์์ด ์ํฐ์คํธ๊ฐ ์ง์ ์์ต์ ๋ฐ์ ์ ์์ด์ ์์
์ฐ์
์ ํ์ ํ ์ ์์ง! ๐ต
๐ฎ ๋ฏธ๋ ์ ๋ง๊ณผ ๋ฐ์ ๋ฐฉํฅ
๋ธ๋ก์ฒด์ธ CMS ๊ธฐ์ ์ ๊ณ์ ๋ฐ์ ํ๊ณ ์์ด. ์์ผ๋ก ์ด๋ค ๋ฐฉํฅ์ผ๋ก ๋์๊ฐ์ง ์ดํด๋ณด์!
โก ๋ ์ด์ด2 ์๋ฃจ์ ํตํฉ
์ด๋๋ฆฌ์ ๋ฉ์ธ๋ท์ ๋์ ๊ฐ์ค๋น ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋ ์ด์ด2 ์๋ฃจ์
๋ค์ด ์ฃผ๋ชฉ๋ฐ๊ณ ์์ด:
Polygon (Matic): ์ ๋ ดํ ์์๋ฃ์ ๋น ๋ฅธ ํธ๋์ญ์
Arbitrum: ์ด๋๋ฆฌ์๊ณผ ๋์ ํธํ์ฑ
Optimism: ๊ฐ๋จํ ๋ง์ด๊ทธ๋ ์ด์
zkSync: ์์ง์ ์ฆ๋ช
๊ธฐ๋ฐ ๋ณด์
๋ผ๋ผ๋ฒจ ์ ํ๋ฆฌ์ผ์ด์
์์ ์ฌ๋ฌ ์ฒด์ธ์ ๋์์ ์ง์ํ๋ ๋ฉํฐ์ฒด์ธ ์ํคํ
์ฒ๋ฅผ ๊ตฌํํ ์ ์์ด! ๐
๐ค AI์์ ๊ฒฐํฉ
์ธ๊ณต์ง๋ฅ๊ณผ ๋ธ๋ก์ฒด์ธ์ ๊ฒฐํฉํ๋ฉด ๋ ๊ฐ๋ ฅํ CMS๋ฅผ ๋ง๋ค ์ ์์ด:
โข AI๊ฐ ์ฝํ
์ธ ์ ํ์ง์ ์๋ ํ๊ฐ
โข ํ์ ๊ฐ์ง AI์ ๋ธ๋ก์ฒด์ธ ๊ฒ์ฆ ๊ฒฐํฉ
โข ๊ฐ์ธํ๋ ์ฝํ
์ธ ์ถ์ฒ + ํฌ๋ช
ํ ์๊ณ ๋ฆฌ์ฆ
โข AI ์์ฑ ์ฝํ
์ธ ์ ์๋ณธ ์ฆ๋ช
๋ผ๋ผ๋ฒจ์์ OpenAI API๋ฅผ ํตํฉํ๊ณ , ๊ฒฐ๊ณผ๋ฅผ ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํ๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ ์ ์์ง! ๐ค
๐ ํ์ค์ํ ์ ์ ์ธ์ฆ (DID)
์ ํต์ ์ธ ์ด๋ฉ์ผ/๋น๋ฐ๋ฒํธ ์ธ์ฆ ๋์ ํ์ค์ํ ์ ์์ ์ฌ์ฉ:
โข ์ฌ์ฉ์๊ฐ ์์ ์ ๋ฐ์ดํฐ๋ฅผ ์์ ํ ํต์
โข ์ฌ๋ฌ ํ๋ซํผ์์ ํ๋์ ์ ์์ผ๋ก ๋ก๊ทธ์ธ
โข ๊ฐ์ธ์ ๋ณด ์ ์ถ ์ํ ์ต์ํ
โข ๊ฒ์ฆ ๊ฐ๋ฅํ ์๊ฒฉ์ฆ๋ช
(Verifiable Credentials)
๋ผ๋ผ๋ฒจ์ DID ์ธ์ฆ์ ํตํฉํ๋ฉด ๋ ์์ ํ๊ณ ์ฌ์ฉ์ ์นํ์ ์ธ ์์คํ
์ ๋ง๋ค ์ ์์ด! ๐
๐ฐ ํ ํฐ ์ด์ฝ๋ ธ๋ฏธ ์ค๊ณ
ํ๋ซํผ ์์ฒด ํ ํฐ์ ๋ฐํํด์ ์ํ๊ณ๋ฅผ ํ์ฑํ:
โข ์ข์ ์ฝํ
์ธ ์์ฑ์์๊ฒ ํ ํฐ ๋ณด์
โข ํ๋ ์ด์
์ฐธ์ฌ์์๊ฒ ์ธ์ผํฐ๋ธ ์ ๊ณต
โข ๊ฑฐ๋ฒ๋์ค ํฌํ๋ก ํ๋ซํผ ์ด์ ๊ฒฐ์
โข ์คํ
์ดํน์ผ๋ก ์ฅ๊ธฐ ์ฐธ์ฌ ์ ๋
ERC-20 ํ ํฐ์ ๋ฐํํ๊ณ ๋ผ๋ผ๋ฒจ์์ ํ ํฐ ์ด์ฝ๋
ธ๋ฏธ๋ฅผ ๊ด๋ฆฌํ๋ ์์คํ
์ ๊ตฌ์ถํ ์ ์์ด! ๐
๐ ํ์ต ๋ฆฌ์์ค ๋ฐ ์ปค๋ฎค๋ํฐ
๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ ๊ณ์ ๊ณต๋ถํ๊ณ ์ถ๋ค๋ฉด ์ด๋ฐ ๋ฆฌ์์ค๋ค์ ํ์ฉํด๋ด!
๐ ๊ณต์ ๋ฌธ์
โข Laravel: https://laravel.com/docs
โข Web3.js: https://web3js.readthedocs.io
โข Solidity: https://docs.soliditylang.org
โข Hardhat: https://hardhat.org/docs
โข IPFS: https://docs.ipfs.tech
๐ฏ ์จ๋ผ์ธ ๊ฐ์
โข CryptoZombies: ๊ฒ์์ผ๋ก ๋ฐฐ์ฐ๋ ์๋ฆฌ๋ํฐ
โข Buildspace: Web3 ํ๋ก์ ํธ ์ค์ต
โข Alchemy University: ๋ฌด๋ฃ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ๊ณผ์
โข Udemy: ๋ผ๋ผ๋ฒจ + ๋ธ๋ก์ฒด์ธ ํตํฉ ๊ฐ์
๐ฅ ์ปค๋ฎค๋ํฐ
โข Ethereum Stack Exchange: ๊ธฐ์ ์ง๋ฌธ
โข Laravel Korea: ํ๊ตญ ๋ผ๋ผ๋ฒจ ์ปค๋ฎค๋ํฐ
โข Web3 Korea: ํ๊ตญ Web3 ๊ฐ๋ฐ์ ๋ชจ์
โข Discord/Telegram: ๋ค์ํ ํ๋ก์ ํธ ์ฑ๋
๐ฌ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์, ์ฌ๊ธฐ๊น์ง ๋ผ๋ผ๋ฒจ๊ณผ web3.js๋ฅผ ์ฌ์ฉํด์ ๋ธ๋ก์ฒด์ธ CMS๋ฅผ ํตํฉํ๋ ๋ฐฉ๋ฒ์ ์์๋ดค์ด! ์ ๋ง ๊ธด ์ฌ์ ์ด์์ง? ๐
์ฐ๋ฆฌ๊ฐ ๋ค๋ฃฌ ๋ด์ฉ์ ์ ๋ฆฌํด๋ณด๋ฉด:
โ
๋ผ๋ผ๋ฒจ๊ณผ web3.js์ ๊ธฐ๋ณธ ๊ฐ๋
๊ณผ ์ฅ์
โ
์์คํ
์ํคํ
์ฒ ์ค๊ณ ๋ฐฉ๋ฒ
โ
์ค๋งํธ ์ปจํธ๋ํธ ์์ฑ๊ณผ ๋ฐฐํฌ
โ
ํ๋ก ํธ์๋์ ๋ฐฑ์๋ ํตํฉ
โ
๋ฉํ๋ง์คํฌ ์ธ์ฆ ์์คํ
โ
IPFS๋ฅผ ํ์ฉํ ํ์ผ ์ ์ฅ
โ
์ฑ๋ฅ ์ต์ ํ์ ๋ณด์ ์ ๋ต
โ
ํ
์คํธ์ ๋ฐฐํฌ ๋ฐฉ๋ฒ
โ
์ค์ ํ์ฉ ์ฌ๋ก์ ๋ฏธ๋ ์ ๋ง
๋ธ๋ก์ฒด์ธ ๊ธฐ์ ์ ์์ง ๋ฐ์ ์ค์ด๊ณ , ์๋ก์ด ๋๊ตฌ์ ํจํด๋ค์ด ๊ณ์ ๋์ค๊ณ ์์ด. ํ์ง๋ง ๊ธฐ๋ณธ ์๋ฆฌ๋ฅผ ์ดํดํ๊ณ ์๋ค๋ฉด ์ด๋ค ๋ณํ์๋ ๋น ๋ฅด๊ฒ ์ ์ํ ์ ์์ ๊ฑฐ์ผ! ๐ช
๊ฐ์ฅ ์ค์ํ ๊ฑด ์ง์ ๋ง๋ค์ด๋ณด๋ ๊ฒ์ด์ผ. ์ด ๊ธ์ ์ฝ๋ ๊ฒ๋ง์ผ๋ก๋ ๋ถ์กฑํด. ํ
์คํธ๋ท์์ ์ค์ ๋ก ์ปจํธ๋ํธ๋ฅผ ๋ฐฐํฌํด๋ณด๊ณ , ๋ผ๋ผ๋ฒจ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ง๋ค์ด๋ณด๊ณ , ์๋ฌ๋ฅผ ๋ง๋๊ณ ํด๊ฒฐํ๋ฉด์ ์ง์ง ์ค๋ ฅ์ด ๋์ด๋๋ ๊ฑฐ์ผ! ๐ฏ
์ฌ๋ฅ๋ท(https://www.jaenung.net) ๊ฐ์ ํ๋ซํผ์์ ์ฌ๋ฌ๋ถ์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ์ฌ๋ฅ์ ๊ณต์ ํ ์๋ ์๊ณ , ๋ค๋ฅธ ์ ๋ฌธ๊ฐ๋ค์ ์ง์์ ๋ฐฐ์ธ ์๋ ์์ด. ํผ์ ๊ณต๋ถํ๊ธฐ ์ด๋ ต๋ค๋ฉด ์ปค๋ฎค๋ํฐ์ ๋์์ ๋ฐ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ง! ๐ค
๋ธ๋ก์ฒด์ธ๊ณผ ์น ๊ฐ๋ฐ์ ๊ฒฐํฉ์ ์ ๋ง ํฅ๋ฏธ์ง์งํ ๋ถ์ผ์ผ. ํ์ค์ํ๋ ๋ฏธ๋๋ฅผ ํจ๊ป ๋ง๋ค์ด๊ฐ๋ ๊ฐ๋ฐ์๊ฐ ๋๊ธธ ๋ฐ๋ผ! ํ์ดํ
! ๐โจ
๐ ์ถํํฉ๋๋ค! ๋ธ๋ก์ฒด์ธ CMS ํตํฉ ๋ง์คํฐ ๊ณผ์ ์ ์๋ฃํ์ต๋๋ค! ๐
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.