Ver3.0 ๐ฆ ๋ผ๋ผ๋ฒจ๋ก ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ์ฐ๋ํ๊ธฐ: Web3 ์๋์ ์ธ์ฆ ์์คํ ๊ตฌ์ถ ์๋ฒฝ ๊ฐ์ด๋

๐ฆ ๋ผ๋ผ๋ฒจ๋ก ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ์ฐ๋ํ๊ธฐ: Web3 ์๋์ ์ธ์ฆ ์์คํ ๊ตฌ์ถ ์๋ฒฝ ๊ฐ์ด๋
๋ธ๋ก์ฒด์ธ ์ง๊ฐ์ผ๋ก ๋ก๊ทธ์ธํ๋ ๋ฏธ๋ํ ์ธ์ฆ ์์คํ ์ ๋ง๋ค์ด๋ณด์!
๐ ์๋
! ์ค๋์ ์ ๋ง ํซํ ์ฃผ์ ๋ฅผ ๊ฐ์ง๊ณ ์์ด. ๋ฐ๋ก ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ๋ผ๋ผ๋ฒจ์ ์ฐ๋ํ๋ ๋ฐฉ๋ฒ์ด์ผ. ์์ฆ Web3๊ฐ ๋์ธ์์? NFT ๋ง์ผํ๋ ์ด์ค๋ , DAO ํ๋ซํผ์ด๋ , ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ์๋น์ค๋ฅผ ๋ง๋ค๋ ค๋ฉด ๋ฉํ๋ง์คํฌ ๊ฐ์ ์ง๊ฐ ๋ก๊ทธ์ธ์ ํ์๊ฐ ๋์ด๊ฐ๊ณ ์์ด.
์ ํต์ ์ธ ์ด๋ฉ์ผ/๋น๋ฐ๋ฒํธ ๋ฐฉ์ ๋์ ๋ธ๋ก์ฒด์ธ ์ง๊ฐ ์ฃผ์๋ก ๋ก๊ทธ์ธํ๋ ๊ฑด ๋จ์ํ ํธ๋ ๋ํ ๊ฒ์ ๋์ด์ ๋ณด์์ฑ๊ณผ ํ์ค์ํ๋ผ๋ Web3์ ํต์ฌ ๊ฐ์น๋ฅผ ์คํํ๋ ๋ฐฉ๋ฒ์ด๊ธฐ๋ ํด. ์ฌ์ฉ์๋ ๋น๋ฐ๋ฒํธ๋ฅผ ๊ธฐ์ตํ ํ์๋ ์๊ณ , ๊ฐ๋ฐ์๋ ๋น๋ฐ๋ฒํธ ํด์ฑ์ด๋ ๋ถ์ค ์ฒ๋ฆฌ ๊ฐ์ ๊ณจ์น ์ํ ์ผ์์ ํด๋ฐฉ๋ ์ ์์ง!
์ด ๊ธ์์๋ ๋ผ๋ผ๋ฒจ ํ๋ ์์ํฌ๋ฅผ ์ฌ์ฉํด์ ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ฒ์๋ถํฐ ๋๊น์ง ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์น๊ตฌ์ฒ๋ผ ํธํ๊ฒ ์ค๋ช
ํด์ค๊ฒ. ์ฝ๋ ์์ ๋ ํ๋ถํ๊ฒ ์ค๋นํ์ผ๋๊น ๋ฐ๋ผ๋ง ํ๋ฉด ๋ผ! ๐
๐ค ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ด ๋ญ๊ธธ๋?
๋จผ์ ๊ธฐ๋ณธ ๊ฐ๋
๋ถํฐ ์ง๊ณ ๋์ด๊ฐ์. ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ ํต์ ์ธ ์ค์ํ๋ ์ธ์ฆ ๋ฐฉ์๊ณผ๋ ์์ ํ ๋ค๋ฅธ ์ ๊ทผ์ด์ผ.
์ผ๋ฐ์ ์ธ ๋ก๊ทธ์ธ์ ์ด๋ ๊ฒ ์๋ํ์ง?
์ ํต์ ๋ก๊ทธ์ธ ํ๋ฆ:
1๏ธโฃ ์ฌ์ฉ์๊ฐ ์ด๋ฉ์ผ๊ณผ ๋น๋ฐ๋ฒํธ ์
๋ ฅ
2๏ธโฃ ์๋ฒ๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ํด์๋ ๋น๋ฐ๋ฒํธ ํ์ธ
3๏ธโฃ ์ผ์นํ๋ฉด ์ธ์
์์ฑ ๋๋ JWT ํ ํฐ ๋ฐ๊ธ
4๏ธโฃ ์ฌ์ฉ์ ์ธ์ฆ ์๋ฃ
๋ฐ๋ฉด ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ด๋ ๊ฒ ์๋ํด:
๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ํ๋ฆ:
1๏ธโฃ ์ฌ์ฉ์๊ฐ ๋ฉํ๋ง์คํฌ ์ฐ๊ฒฐ ๋ฒํผ ํด๋ฆญ
2๏ธโฃ ๋ฉํ๋ง์คํฌ๊ฐ ์ง๊ฐ ์ฃผ์ ์ ๊ณต
3๏ธโฃ ์๋ฒ๊ฐ ๋๋คํ nonce(์ผํ์ฉ ์ซ์) ์์ฑ
4๏ธโฃ ์ฌ์ฉ์๊ฐ ๋ฉํ๋ง์คํฌ๋ก nonce์ ์๋ช
5๏ธโฃ ์๋ฒ๊ฐ ์๋ช
์ ๊ฒ์ฆํ์ฌ ์ง๊ฐ ์์ ๊ถ ํ์ธ
6๏ธโฃ ์ธ์ฆ ์๋ฃ ๋ฐ ์ธ์
/ํ ํฐ ๋ฐ๊ธ
๐ก ํต์ฌ ํฌ์ธํธ: ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ํต์ฌ์ ์ํธํ์ ์๋ช ์ด์ผ. ์ฌ์ฉ์๋ ์์ ์ ๊ฐ์ธํค๋ก ๋ฉ์์ง์ ์๋ช ํ๊ณ , ์๋ฒ๋ ๊ณต๊ฐํค(์ง๊ฐ ์ฃผ์)๋ก ๊ทธ ์๋ช ์ ๊ฒ์ฆํด. ์ด ๊ณผ์ ์์ ๊ฐ์ธํค๋ ์ ๋ ๋คํธ์ํฌ๋ฅผ ํตํด ์ ์ก๋์ง ์์. ์ด๊ฒ ๋ฐ๋ก ๋ณด์์ ํต์ฌ์ด์ง!
์ ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ฌ์ฉํด์ผ ํ ๊น?
๐ ๋ณด์์ฑ ํฅ์
๋น๋ฐ๋ฒํธ ์ ์ถ ๊ฑฑ์ ์ด ์์ด. ์ฌ์ฉ์์ ๊ฐ์ธํค๋ ๋ฉํ๋ง์คํฌ ์์ ์์ ํ๊ฒ ๋ณด๊ด๋๊ณ , ์๋ช
๊ณผ์ ์์๋ ์ธ๋ถ๋ก ๋
ธ์ถ๋์ง ์์.
๐ฏ ์ฌ์ฉ์ ๊ฒฝํ ๊ฐ์
ํ์๊ฐ์
์ ์ฐจ๊ฐ ๊ฐ์ํ๋ผ. ์ด๋ฉ์ผ ์ธ์ฆ๋ ํ์ ์๊ณ , ๋น๋ฐ๋ฒํธ๋ฅผ ๊ธฐ์ตํ ํ์๋ ์์ด. ํด๋ฆญ ๋ช ๋ฒ์ด๋ฉด ๋!
๐ Web3 ์ํ๊ณ ํตํฉ
NFT, DeFi, DAO ๋ฑ ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ๊ธฐ๋ฅ๋ค๊ณผ ์์ฐ์ค๋ฝ๊ฒ ์ฐ๊ฒฐ๋ผ. ์ง๊ฐ ์ฃผ์ ํ๋๋ก ๋ชจ๋ Web3 ์๋น์ค๋ฅผ ์ด์ฉํ ์ ์์ง.
๐ ๊ฐ๋ฐ ํธ์์ฑ
๋น๋ฐ๋ฒํธ ์ฌ์ค์ , ์ด๋ฉ์ผ ์ธ์ฆ, 2FA ๊ฐ์ ๋ณต์กํ ๊ธฐ๋ฅ๋ค์ ๊ตฌํํ ํ์๊ฐ ์์ด. ๋ธ๋ก์ฒด์ธ์ด ์ธ์ฆ์ ๋์ ํด์ฃผ๊ฑฐ๋ !
๐ ๏ธ ๊ฐ๋ฐ ํ๊ฒฝ ์ค๋นํ๊ธฐ
์, ์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ์ฝ๋ฉ์ ์์ํด๋ณผ๊น? ๋จผ์ ํ์ํ ๊ฒ๋ค์ ์ค๋นํด์ผ ํด.
ํ์ ์๊ตฌ์ฌํญ
| ํญ๋ชฉ | ๋ฒ์ /์ค๋ช | ์ฉ๋ |
|---|---|---|
| PHP | 8.0 ์ด์ | ๋ผ๋ผ๋ฒจ ์คํ ํ๊ฒฝ |
| Laravel | 9.x ๋๋ 10.x | ๋ฐฑ์๋ ํ๋ ์์ํฌ |
| Composer | ์ต์ ๋ฒ์ | PHP ํจํค์ง ๊ด๋ฆฌ |
| Node.js & NPM | 16.x ์ด์ | ํ๋ก ํธ์๋ ๋น๋ |
| MySQL/PostgreSQL | 5.7+ / 12+ | ๋ฐ์ดํฐ๋ฒ ์ด์ค |
| MetaMask | ๋ธ๋ผ์ฐ์ ํ์ฅ | ํ ์คํธ์ฉ ์ง๊ฐ |
๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ ์์ฑ
์๋ก์ด ๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด๋ณด์. ํฐ๋ฏธ๋์ ์ด๊ณ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํด:
composer create-project laravel/laravel metamask-auth
cd metamask-auth
php artisan serve
์ด์ http://localhost:8000์์ ๋ผ๋ผ๋ฒจ ๊ธฐ๋ณธ ํ์ด์ง๋ฅผ ๋ณผ ์ ์์ ๊ฑฐ์ผ. ๐
ํ์ํ NPM ํจํค์ง ์ค์น
ํ๋ก ํธ์๋์์ ๋ฉํ๋ง์คํฌ์ ํต์ ํ๋ ค๋ฉด Web3 ๊ด๋ จ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์ํด. ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ ๊ฑด ethers.js์ web3.js์ธ๋ฐ, ์ฌ๊ธฐ์๋ ethers.js๋ฅผ ์ฌ์ฉํ ๊ฒ. ๋ ๊ฐ๋ณ๊ณ ํ๋์ ์ด๊ฑฐ๋ !
npm install ethers
npm install axios
๐ก ethers.js vs web3.js: ๋ ๋ค ์ด๋๋ฆฌ์๊ณผ ์ํธ์์ฉํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. ethers.js๋ ๋ ์๊ณ ๋ชจ๋ํ๋์ด ์์ด์ ์ต๊ทผ์ ๋ ์ธ๊ธฐ๊ฐ ๋ง์. web3.js๋ ์ญ์ฌ๊ฐ ๊ธธ๊ณ ๋ ๊ฑฐ์ ํ๋ก์ ํธ์์ ๋ง์ด ์ฌ์ฉ๋ผ. ์ทจํฅ๊ป ์ ํํ๋ฉด ๋์ง๋ง, ์ด ๊ธ์์๋ ethers.js๋ก ์งํํ ๊ฒ!
PHP ํจํค์ง ์ค์น
์๋ช ๊ฒ์ฆ์ ์ํด PHP์์๋ ์ด๋๋ฆฌ์ ๊ด๋ จ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์ํด. kornrunner/keccak๊ณผ simplito/elliptic-php๋ฅผ ์ค์นํ์:
composer require kornrunner/keccak
composer require simplito/elliptic-php
์ด ํจํค์ง๋ค์ ์ด๋๋ฆฌ์ ์๋ช ์ ๊ฒ์ฆํ๋ ๋ฐ ํ์ํ ์ํธํ์ ํจ์๋ค์ ์ ๊ณตํด์ค.
๐๏ธ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ค๊ณํ๊ธฐ
๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ตฌ์กฐ๋ฅผ ์ค๊ณํด๋ณด์. ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์ ์ฅํ ํ ์ด๋ธ์ด ํ์ํ๊ณ , ๋ก๊ทธ์ธ ๊ณผ์ ์์ ์ฌ์ฉํ nonce๋ฅผ ์ ์ฅํ ํ๋๋ ํ์ํด.
Users ํ ์ด๋ธ ๋ง์ด๊ทธ๋ ์ด์
๋ผ๋ผ๋ฒจ์ ๊ธฐ๋ณธ์ ์ผ๋ก users ํ ์ด๋ธ์ ์ ๊ณตํ์ง๋ง, ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ๋ง๊ฒ ์์ ํด์ผ ํด. ์๋ก์ด ๋ง์ด๊ทธ๋ ์ด์ ์ ๋ง๋ค์:
php artisan make:migration add_wallet_fields_to_users_table --table=users
์์ฑ๋ ๋ง์ด๊ทธ๋ ์ด์ ํ์ผ์ ์ด๊ณ ๋ค์๊ณผ ๊ฐ์ด ์์ ํด:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
// ์ง๊ฐ ์ฃผ์ (๊ณ ์ ๊ฐ, ์ธ๋ฑ์ค)
$table->string('wallet_address', 42)->unique()->nullable();
// ๋ก๊ทธ์ธ์ฉ nonce (๋๋ค ๋ฌธ์์ด)
$table->string('nonce')->nullable();
// ์ด๋ฉ์ผ์ ์ ํ์ฌํญ์ผ๋ก ๋ณ๊ฒฝ
$table->string('email')->nullable()->change();
$table->string('password')->nullable()->change();
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['wallet_address', 'nonce']);
});
}
};
๐ก ์ nonce๊ฐ ํ์ํ ๊น? nonce๋ "number used once"์ ์ฝ์์ผ. ์ฌ์ ๊ณต๊ฒฉ(replay attack)์ ๋ฐฉ์งํ๊ธฐ ์ํด ์ฌ์ฉ๋ผ. ๋งค๋ฒ ๋ก๊ทธ์ธํ ๋๋ง๋ค ์๋ก์ด nonce๋ฅผ ์์ฑํ๊ณ , ์ฌ์ฉ์๋ ์ด nonce์ ์๋ช ํด. ์๋ฒ๋ ์ด ์๋ช ์ด ํ์ฌ nonce์ ์ผ์นํ๋์ง ํ์ธํ๊ณ , ํ์ธ ํ์๋ nonce๋ฅผ ์๋ก ์์ฑํด. ์ด๋ ๊ฒ ํ๋ฉด ์ด์ ์๋ช ์ ์ฌ์ฌ์ฉํ๋ ๊ณต๊ฒฉ์ ๋ง์ ์ ์์ด!
User ๋ชจ๋ธ ์์
User ๋ชจ๋ธ๋ ์์ ํด์ผ ํด. app/Models/User.php ํ์ผ์ ์ด๊ณ :
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
class User extends Authenticatable
{
use HasFactory, Notifiable;
protected $fillable = [
'name',
'email',
'password',
'wallet_address',
'nonce',
];
protected $hidden = [
'password',
'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* ์๋ก์ด nonce ์์ฑ
*/
public function generateNonce(): string
{
$nonce = Str::random(32);
$this->nonce = $nonce;
$this->save();
return $nonce;
}
/**
* ์ง๊ฐ ์ฃผ์๋ก ์ฌ์ฉ์ ์ฐพ๊ธฐ ๋๋ ์์ฑ
*/
public static function findOrCreateByWallet(string $walletAddress): self
{
$user = self::where('wallet_address', $walletAddress)->first();
if (!$user) {
$user = self::create([
'wallet_address' => $walletAddress,
'name' => 'User ' . substr($walletAddress, 0, 6),
'nonce' => Str::random(32),
]);
}
return $user;
}
}
๋ง์ด๊ทธ๋ ์ด์ ์ ์คํํ์:
php artisan migrate
์ด์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ค๋น๊ฐ ๋๋ฌ์ด! โ
โ๏ธ ๋ฐฑ์๋ API ๊ตฌ์ถํ๊ธฐ
์ด์ ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ์ฒ๋ฆฌํ API ์๋ํฌ์ธํธ๋ฅผ ๋ง๋ค์ด๋ณด์. ํฌ๊ฒ ์ธ ๊ฐ์ง ์๋ํฌ์ธํธ๊ฐ ํ์ํด:
ํ์ํ API ์๋ํฌ์ธํธ:
1๏ธโฃ GET /api/auth/nonce/{address} - ์ง๊ฐ ์ฃผ์์ ๋ํ nonce ์กฐํ
2๏ธโฃ POST /api/auth/verify - ์๋ช
๊ฒ์ฆ ๋ฐ ๋ก๊ทธ์ธ
3๏ธโฃ POST /api/auth/logout - ๋ก๊ทธ์์
์ปจํธ๋กค๋ฌ ์์ฑ
php artisan make:controller Api/Web3AuthController
์๋ช ๊ฒ์ฆ ์๋น์ค ํด๋์ค ๋ง๋ค๊ธฐ
์๋ช
๊ฒ์ฆ ๋ก์ง์ ๋ณต์กํ๋๊น ๋ณ๋์ ์๋น์ค ํด๋์ค๋ก ๋ถ๋ฆฌํ๋ ๊ฒ ์ข์. app/Services/Web3SignatureVerifier.php ํ์ผ์ ๋ง๋ค์:
<?php
namespace App\Services;
use kornrunner\Keccak;
use Elliptic\EC;
class Web3SignatureVerifier
{
/**
* ์ด๋๋ฆฌ์ ์๋ช
๊ฒ์ฆ
*
* @param string $message ์๋ณธ ๋ฉ์์ง
* @param string $signature ์๋ช
(0x๋ก ์์ํ๋ hex)
* @param string $address ์ง๊ฐ ์ฃผ์
* @return bool
*/
public function verify(string $message, string $signature, string $address): bool
{
// 1. ๋ฉ์์ง๋ฅผ ์ด๋๋ฆฌ์ ์๋ช
ํ์์ผ๋ก ๋ณํ
$hash = $this->hashMessage($message);
// 2. ์๋ช
์์ r, s, v ๊ฐ ์ถ์ถ
$signature = $this->removeHexPrefix($signature);
if (strlen($signature) !== 130) {
return false;
}
$r = substr($signature, 0, 64);
$s = substr($signature, 64, 64);
$v = hexdec(substr($signature, 128, 2));
// v ๊ฐ ์กฐ์ (27 ๋๋ 28์ด์ด์ผ ํจ)
if ($v < 27) {
$v += 27;
}
// 3. ๊ณต๊ฐํค ๋ณต๊ตฌ
$publicKey = $this->recoverPublicKey($hash, $r, $s, $v);
if (!$publicKey) {
return false;
}
// 4. ๊ณต๊ฐํค์์ ์ฃผ์ ์ถ์ถ
$recoveredAddress = $this->publicKeyToAddress($publicKey);
// 5. ์ฃผ์ ๋น๊ต (๋์๋ฌธ์ ๋ฌด์)
return strtolower($recoveredAddress) === strtolower($this->removeHexPrefix($address));
}
/**
* ๋ฉ์์ง๋ฅผ ์ด๋๋ฆฌ์ ์๋ช
ํด์๋ก ๋ณํ
*/
private function hashMessage(string $message): string
{
$prefix = "\x19Ethereum Signed Message:\n" . strlen($message);
$prefixedMessage = $prefix . $message;
return Keccak::hash($prefixedMessage, 256);
}
/**
* ๊ณต๊ฐํค ๋ณต๊ตฌ
*/
private function recoverPublicKey(string $hash, string $r, string $s, int $v): ?string
{
$ec = new EC('secp256k1');
$recoveryId = $v - 27;
try {
$signature = [
'r' => $r,
's' => $s,
];
$publicKey = $ec->recoverPubKey(
$hash,
$signature,
$recoveryId,
'hex'
);
return '04' . $publicKey->getX()->toString(16) . $publicKey->getY()->toString(16);
} catch (\Exception $e) {
return null;
}
}
/**
* ๊ณต๊ฐํค์์ ์ด๋๋ฆฌ์ ์ฃผ์ ์ถ์ถ
*/
private function publicKeyToAddress(string $publicKey): string
{
// 04 ํ๋ฆฌํฝ์ค ์ ๊ฑฐ
$publicKey = $this->removeHexPrefix($publicKey);
if (substr($publicKey, 0, 2) === '04') {
$publicKey = substr($publicKey, 2);
}
// Keccak-256 ํด์
$hash = Keccak::hash(hex2bin($publicKey), 256);
// ๋ง์ง๋ง 20๋ฐ์ดํธ(40์)๋ฅผ ์ฃผ์๋ก ์ฌ์ฉ
return '0x' . substr($hash, -40);
}
/**
* 0x ํ๋ฆฌํฝ์ค ์ ๊ฑฐ
*/
private function removeHexPrefix(string $hex): string
{
if (substr($hex, 0, 2) === '0x') {
return substr($hex, 2);
}
return $hex;
}
}
โ ๏ธ ์ฃผ์์ฌํญ: ์ด ์ฝ๋๋ ์ด๋๋ฆฌ์์ ECDSA ์๋ช ๊ฒ์ฆ์ ๊ตฌํํ ๊ฑฐ์ผ. ์ํธํ์ ์ผ๋ก ๋ณต์กํ ๋ถ๋ถ์ด๋๊น ์ ํํ ์ดํดํ์ง ๋ชปํด๋ ๊ด์ฐฎ์. ์ค์ํ ๊ฑด ์ด ์๋น์ค ํด๋์ค๊ฐ ์๋ช ์ ์ ํจ์ฑ์ ๊ฒ์ฆํด์ค๋ค๋ ๊ฑฐ์ง!
์ปจํธ๋กค๋ฌ ๊ตฌํ
์ด์ ์ปจํธ๋กค๋ฌ๋ฅผ ๊ตฌํํด๋ณด์. app/Http/Controllers/Api/Web3AuthController.php:
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Services\Web3SignatureVerifier;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
class Web3AuthController extends Controller
{
private Web3SignatureVerifier $verifier;
public function __construct(Web3SignatureVerifier $verifier)
{
$this->verifier = $verifier;
}
/**
* Nonce ์กฐํ
* GET /api/auth/nonce/{address}
*/
public function getNonce(string $address)
{
// ์ฃผ์ ์ ํจ์ฑ ๊ฒ์ฌ
if (!$this->isValidAddress($address)) {
return response()->json([
'error' => 'Invalid wallet address'
], 400);
}
// ์ฌ์ฉ์ ์ฐพ๊ธฐ ๋๋ ์์ฑ
$user = User::findOrCreateByWallet($address);
// Nonce๊ฐ ์์ผ๋ฉด ์์ฑ
if (!$user->nonce) {
$user->generateNonce();
}
return response()->json([
'nonce' => $user->nonce,
'message' => "Sign this message to authenticate with nonce: {$user->nonce}"
]);
}
/**
* ์๋ช
๊ฒ์ฆ ๋ฐ ๋ก๊ทธ์ธ
* POST /api/auth/verify
*/
public function verify(Request $request)
{
$request->validate([
'address' => 'required|string',
'signature' => 'required|string',
]);
$address = $request->input('address');
$signature = $request->input('signature');
// ์ฌ์ฉ์ ์กฐํ
$user = User::where('wallet_address', $address)->first();
if (!$user || !$user->nonce) {
return response()->json([
'error' => 'User not found or nonce not generated'
], 404);
}
// ์๋ช
ํ ๋ฉ์์ง ์ฌ๊ตฌ์ฑ
$message = "Sign this message to authenticate with nonce: {$user->nonce}";
// ์๋ช
๊ฒ์ฆ
$isValid = $this->verifier->verify($message, $signature, $address);
if (!$isValid) {
return response()->json([
'error' => 'Invalid signature'
], 401);
}
// ๋ก๊ทธ์ธ ์ฒ๋ฆฌ
Auth::login($user);
// ์๋ก์ด nonce ์์ฑ (์ฌ์ ๊ณต๊ฒฉ ๋ฐฉ์ง)
$user->generateNonce();
// Sanctum ํ ํฐ ์์ฑ (API ์ธ์ฆ์ฉ)
$token = $user->createToken('web3-auth')->plainTextToken;
return response()->json([
'message' => 'Authentication successful',
'user' => $user,
'token' => $token
]);
}
/**
* ๋ก๊ทธ์์
* POST /api/auth/logout
*/
public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();
return response()->json([
'message' => 'Logged out successfully'
]);
}
/**
* ์ง๊ฐ ์ฃผ์ ์ ํจ์ฑ ๊ฒ์ฌ
*/
private function isValidAddress(string $address): bool
{
return preg_match('/^0x[a-fA-F0-9]{40}$/', $address) === 1;
}
}
๋ผ์ฐํธ ๋ฑ๋ก
routes/api.php ํ์ผ์ ๋ผ์ฐํธ๋ฅผ ์ถ๊ฐํ์:
<?php
use App\Http\Controllers\Api\Web3AuthController;
use Illuminate\Support\Facades\Route;
Route::prefix('auth')->group(function () {
Route::get('nonce/{address}', [Web3AuthController::class, 'getNonce']);
Route::post('verify', [Web3AuthController::class, 'verify']);
Route::middleware('auth:sanctum')->group(function () {
Route::post('logout', [Web3AuthController::class, 'logout']);
});
});
Sanctum ์ค์
API ํ ํฐ ์ธ์ฆ์ ์ํด Laravel Sanctum์ ์ค์ ํด์ผ ํด. ๋ผ๋ผ๋ฒจ 9 ์ด์์์๋ ๊ธฐ๋ณธ์ผ๋ก ํฌํจ๋์ด ์์ง๋ง, ์ค์ ์ ํ์ํด:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
app/Http/Kernel.php์์ API ๋ฏธ๋ค์จ์ด ๊ทธ๋ฃน์ Sanctum์ ์ถ๊ฐ:
'api' => [
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
๋ฐฑ์๋ ์ค๋น ์๋ฃ! ๐
๐จ ํ๋ก ํธ์๋ ๊ตฌํํ๊ธฐ
์ด์ ์ฌ๋ฏธ์๋ ๋ถ๋ถ์ด์ผ! ์ฌ์ฉ์๊ฐ ์ค์ ๋ก ๋ฉํ๋ง์คํฌ๋ก ๋ก๊ทธ์ธํ ์ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๋ง๋ค์ด๋ณด์.
๊ธฐ๋ณธ HTML ํ์ด์ง ๋ง๋ค๊ธฐ
resources/views/welcome.blade.php ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ด ์์ ํด:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>MetaMask Login Demo</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
padding: 40px;
max-width: 500px;
width: 100%;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 28px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
font-size: 14px;
}
.btn {
width: 100%;
padding: 16px;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: #f3f4f6;
color: #333;
margin-top: 10px;
}
.btn-secondary:hover {
background: #e5e7eb;
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.status {
margin-top: 20px;
padding: 15px;
border-radius: 10px;
font-size: 14px;
}
.status.success {
background: #d1fae5;
color: #065f46;
border: 1px solid #6ee7b7;
}
.status.error {
background: #fee2e2;
color: #991b1b;
border: 1px solid #fca5a5;
}
.status.info {
background: #dbeafe;
color: #1e40af;
border: 1px solid #93c5fd;
}
.user-info {
margin-top: 20px;
padding: 20px;
background: #f9fafb;
border-radius: 10px;
}
.user-info h3 {
color: #333;
margin-bottom: 10px;
font-size: 18px;
}
.user-info p {
color: #666;
font-size: 14px;
margin: 5px 0;
word-break: break-all;
}
.hidden {
display: none;
}
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="container">
<h1>๐ฆ MetaMask Login</h1>
<p class="subtitle">Connect your wallet to authenticate</p>
<div id="loginSection">
<button id="connectBtn" class="btn btn-primary">
<span>Connect MetaMask</span>
</button>
</div>
<div id="userSection" class="hidden">
<div class="user-info">
<h3>โ
Connected</h3>
<p><strong>Address:</strong> <span id="userAddress"></span></p>
<p><strong>Name:</strong> <span id="userName"></span></p>
</div>
<button id="logoutBtn" class="btn btn-secondary">
Disconnect
</button>
</div>
<div id="status"></div>
</div>
<script type="module">
import { ethers } from 'https://cdn.ethers.io/lib/ethers-5.7.esm.min.js';
const API_BASE = '/api/auth';
let currentUser = null;
let authToken = null;
// DOM ์์
const connectBtn = document.getElementById('connectBtn');
const logoutBtn = document.getElementById('logoutBtn');
const loginSection = document.getElementById('loginSection');
const userSection = document.getElementById('userSection');
const statusDiv = document.getElementById('status');
// ์ํ ๋ฉ์์ง ํ์
function showStatus(message, type = 'info') {
statusDiv.className = `status ${type}`;
statusDiv.textContent = message;
statusDiv.style.display = 'block';
}
// ์ํ ๋ฉ์์ง ์จ๊ธฐ๊ธฐ
function hideStatus() {
statusDiv.style.display = 'none';
}
// ๋ฉํ๋ง์คํฌ ์ค์น ํ์ธ
function checkMetaMask() {
if (typeof window.ethereum === 'undefined') {
showStatus('MetaMask is not installed. Please install it to continue.', 'error');
return false;
}
return true;
}
// ๋ก๊ทธ์ธ ์ฒ๋ฆฌ
async function login() {
if (!checkMetaMask()) return;
try {
connectBtn.disabled = true;
connectBtn.innerHTML = '<span class="loading"></span> Connecting...';
// 1. ๋ฉํ๋ง์คํฌ ๊ณ์ ์์ฒญ
showStatus('Requesting account access...', 'info');
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
const address = await signer.getAddress();
// 2. Nonce ๊ฐ์ ธ์ค๊ธฐ
showStatus('Getting nonce...', 'info');
const nonceResponse = await fetch(`${API_BASE}/nonce/${address}`);
const nonceData = await nonceResponse.json();
if (!nonceResponse.ok) {
throw new Error(nonceData.error || 'Failed to get nonce');
}
// 3. ๋ฉ์์ง ์๋ช
showStatus('Please sign the message in MetaMask...', 'info');
const message = nonceData.message;
const signature = await signer.signMessage(message);
// 4. ์๋ช
๊ฒ์ฆ ๋ฐ ๋ก๊ทธ์ธ
showStatus('Verifying signature...', 'info');
const verifyResponse = await fetch(`${API_BASE}/verify`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
address: address,
signature: signature,
}),
});
const verifyData = await verifyResponse.json();
if (!verifyResponse.ok) {
throw new Error(verifyData.error || 'Verification failed');
}
// 5. ๋ก๊ทธ์ธ ์ฑ๊ณต
currentUser = verifyData.user;
authToken = verifyData.token;
showStatus('Login successful!', 'success');
updateUI(true);
} catch (error) {
console.error('Login error:', error);
showStatus(`Login failed: ${error.message}`, 'error');
} finally {
connectBtn.disabled = false;
connectBtn.innerHTML = '<span>Connect MetaMask</span>';
}
}
// ๋ก๊ทธ์์ ์ฒ๋ฆฌ
async function logout() {
try {
if (authToken) {
await fetch(`${API_BASE}/logout`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${authToken}`,
'Accept': 'application/json',
},
});
}
currentUser = null;
authToken = null;
updateUI(false);
showStatus('Logged out successfully', 'info');
} catch (error) {
console.error('Logout error:', error);
showStatus('Logout failed', 'error');
}
}
// UI ์
๋ฐ์ดํธ
function updateUI(isLoggedIn) {
if (isLoggedIn) {
loginSection.classList.add('hidden');
userSection.classList.remove('hidden');
document.getElementById('userAddress').textContent = currentUser.wallet_address;
document.getElementById('userName').textContent = currentUser.name;
} else {
loginSection.classList.remove('hidden');
userSection.classList.add('hidden');
}
}
// ์ด๋ฒคํธ ๋ฆฌ์ค๋
connectBtn.addEventListener('click', login);
logoutBtn.addEventListener('click', logout);
// ๊ณ์ ๋ณ๊ฒฝ ๊ฐ์ง
if (window.ethereum) {
window.ethereum.on('accountsChanged', (accounts) => {
if (accounts.length === 0) {
logout();
} else if (currentUser && accounts[0].toLowerCase() !== currentUser.wallet_address.toLowerCase()) {
showStatus('Account changed. Please login again.', 'info');
logout();
}
});
}
</script>
</body>
</html>
๐ก ์ฝ๋ ์ค๋ช : ์ด ์ฝ๋๋ ethers.js๋ฅผ CDN์ผ๋ก ๋ถ๋ฌ์์ ์ฌ์ฉํ๊ณ ์์ด. ์ค์ ํ๋ก๋์ ์์๋ npm์ผ๋ก ์ค์นํ๊ณ ๋น๋ ๋๊ตฌ(Vite, Webpack ๋ฑ)๋ฅผ ์ฌ์ฉํ๋ ๊ฒ ์ข์. ํ์ง๋ง ๋ฐ๋ชจ ๋ชฉ์ ์ผ๋ก๋ CDN์ด ๊ฐํธํ์ง!
์๋ ํ๋ฆ ์์ธ ์ค๋ช
1๏ธโฃ Connect MetaMask ๋ฒํผ ํด๋ฆญ
์ฌ์ฉ์๊ฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด eth_requestAccounts ๋ฉ์๋๊ฐ ํธ์ถ๋ผ. ์ด๊ฑด ๋ฉํ๋ง์คํฌ ํ์
์ ๋์์ ์ฌ์ฉ์์๊ฒ ๊ณ์ ์ ๊ทผ ๊ถํ์ ์์ฒญํ๋ ๊ฑฐ์ผ.
2๏ธโฃ Nonce ์์ฒญ
์ง๊ฐ ์ฃผ์๋ฅผ ๋ฐ์ผ๋ฉด ์๋ฒ์ GET ์์ฒญ์ ๋ณด๋ด์ ํด๋น ์ฃผ์์ nonce๋ฅผ ๊ฐ์ ธ์. ์ฌ์ฉ์๊ฐ ์ฒ์์ด๋ฉด ์๋์ผ๋ก ๊ณ์ ์ด ์์ฑ๋๊ณ nonce๋ ์์ฑ๋ผ.
3๏ธโฃ ๋ฉ์์ง ์๋ช
signer.signMessage()๋ฅผ ํธ์ถํ๋ฉด ๋ฉํ๋ง์คํฌ๊ฐ ๋ค์ ํ์
์ ๋์. ์ฌ์ฉ์๋ ๋ฉ์์ง๋ฅผ ํ์ธํ๊ณ ์๋ช
๋ฒํผ์ ๋๋ฌ์ผ ํด. ์ด๋ ๊ฐ์ธํค๊ฐ ์ฌ์ฉ๋์ง๋ง, ๊ฐ์ธํค ์์ฒด๋ ์ ๋ ์ธ๋ถ๋ก ๋๊ฐ์ง ์์!
4๏ธโฃ ์๋ช
๊ฒ์ฆ
์๋ช
์ ์๋ฒ๋ก ๋ณด๋ด๋ฉด ์๋ฒ๋ ์ํธํ์ ๊ฒ์ฆ์ ์ํํด. ์๋ช
์ด ์ ํจํ๋ฉด ๋ก๊ทธ์ธ ์ฑ๊ณต!
5๏ธโฃ ํ ํฐ ์ ์ฅ ๋ฐ UI ์
๋ฐ์ดํธ
์๋ฒ์์ ๋ฐ์ ์ธ์ฆ ํ ํฐ์ ์ ์ฅํ๊ณ , UI๋ฅผ ๋ก๊ทธ์ธ ์ํ๋ก ์
๋ฐ์ดํธํด. ์ดํ API ์์ฒญ์๋ ์ด ํ ํฐ์ ํค๋์ ํฌํจ์์ผ์ ๋ณด๋ด๋ฉด ๋ผ.
๐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ๊ตฌํํ ๋ ๋ฐ๋์ ๊ณ ๋ คํด์ผ ํ ๋ณด์ ์ฌํญ๋ค์ด ์์ด. ์ด๊ฑธ ๋์น๋ฉด ํฐ์ผ ๋๋๊น ๊ผญ ์ฒดํฌํด!
1. Nonce ์ฌ์ฌ์ฉ ๋ฐฉ์ง
โ ๏ธ ์ฌ์ ๊ณต๊ฒฉ(Replay Attack): ๊ณต๊ฒฉ์๊ฐ ์ด์ ์ ์ฌ์ฉ๋ ์๋ช
์ ๊ฐ๋ก์ฑ์ ๋ค์ ์ฌ์ฉํ๋ ๊ณต๊ฒฉ์ด์ผ. ์ด๋ฅผ ๋ฐฉ์งํ๋ ค๋ฉด nonce๋ฅผ ํ ๋ฒ ์ฌ์ฉํ ํ์๋ ๋ฐ๋์ ์๋ก ์์ฑํด์ผ ํด. ์ฐ๋ฆฌ ์ฝ๋์์๋ verify ๋ฉ์๋์์ ์ธ์ฆ ์ฑ๊ณต ํ generateNonce()๋ฅผ ํธ์ถํ๊ณ ์์ด.
2. ํ์์คํฌํ ์ถ๊ฐ
๋ ๊ฐ๋ ฅํ ๋ณด์์ ์ํด nonce์ ํ์์คํฌํ๋ฅผ ํฌํจ์ํฌ ์ ์์ด:
public function generateNonce(): string
{
$timestamp = time();
$random = Str::random(32);
$nonce = $timestamp . ':' . $random;
$this->nonce = $nonce;
$this->nonce_created_at = now();
$this->save();
return $nonce;
}
// ๊ฒ์ฆ ์ ํ์์คํฌํ ํ์ธ
public function isNonceValid(int $maxAge = 300): bool
{
if (!$this->nonce_created_at) {
return false;
}
return $this->nonce_created_at->diffInSeconds(now()) <= $maxAge;
}
์ด๋ ๊ฒ ํ๋ฉด 5๋ถ(300์ด) ์ด์ ์ง๋ nonce๋ ๋ฌดํจํ๋ผ. ๊ณต๊ฒฉ์๊ฐ ์๋ช ์ ๊ฐ๋ก์ฑ๋ ์๊ฐ์ด ์ง๋๋ฉด ์ฌ์ฉํ ์ ์๊ฒ ๋๋ ๊ฑฐ์ง!
3. HTTPS ํ์
โ ๏ธ ์ค์: ๋ฉํ๋ง์คํฌ๋ ๋ณด์์์ ์ด์ ๋ก HTTPS ์ฐ๊ฒฐ์์๋ง ์๋ํด. ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ(localhost)์์๋ HTTP๋ ๊ด์ฐฎ์ง๋ง, ํ๋ก๋์ ์์๋ ๋ฐ๋์ HTTPS๋ฅผ ์ฌ์ฉํด์ผ ํด!
4. Rate Limiting
๋ฌด์ฐจ๋ณ ๋์ ๊ณต๊ฒฉ์ ๋ฐฉ์งํ๊ธฐ ์ํด API์ ์๋ ์ ํ์ ๊ฑธ์ด์ผ ํด:
Route::prefix('auth')->middleware('throttle:10,1')->group(function () {
Route::get('nonce/{address}', [Web3AuthController::class, 'getNonce']);
Route::post('verify', [Web3AuthController::class, 'verify']);
});
์ด๋ ๊ฒ ํ๋ฉด 1๋ถ์ 10๋ฒ๊น์ง๋ง ์์ฒญํ ์ ์์ด.
5. ์ฃผ์ ๊ฒ์ฆ ๊ฐํ
์ฒดํฌ์ฌ ์ฃผ์(checksum address) ๊ฒ์ฆ์ ์ถ๊ฐํ๋ฉด ๋ ์์ ํด:
private function isValidAddress(string $address): bool
{
// ๊ธฐ๋ณธ ํ์ ๊ฒ์ฆ
if (!preg_match('/^0x[a-fA-F0-9]{40}$/', $address)) {
return false;
}
// ์ฒดํฌ์ฌ ๊ฒ์ฆ (์ ํ์ฌํญ์ด์ง๋ง ๊ถ์ฅ)
$address = strtolower($address);
$hash = Keccak::hash(substr($address, 2), 256);
for ($i = 0; $i < 40; $i++) {
$char = substr($address, $i + 2, 1);
$hashChar = substr($hash, $i, 1);
if (ctype_alpha($char)) {
$isUpperCase = $char === strtoupper($char);
$shouldBeUpperCase = hexdec($hashChar) >= 8;
if ($isUpperCase !== $shouldBeUpperCase) {
return false;
}
}
}
return true;
}
๐ ๊ณ ๊ธ ๊ธฐ๋ฅ ์ถ๊ฐํ๊ธฐ
๊ธฐ๋ณธ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ์์ฑํ์ด! ์ด์ ๋ ๋ฉ์ง ๊ธฐ๋ฅ๋ค์ ์ถ๊ฐํด๋ณด์.
1. ๋ค์ค ์ง๊ฐ ์ง์
ํ ์ฌ์ฉ์๊ฐ ์ฌ๋ฌ ๊ฐ์ ์ง๊ฐ์ ์ฐ๊ฒฐํ ์ ์๊ฒ ํด๋ณด์. ๋จผ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ตฌ์กฐ๋ฅผ ์์ ํด์ผ ํด:
php artisan make:migration create_user_wallets_table
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('user_wallets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('wallet_address', 42)->unique();
$table->string('nonce')->nullable();
$table->boolean('is_primary')->default(false);
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'is_primary']);
});
}
public function down()
{
Schema::dropIfExists('user_wallets');
}
};
2. ENS(Ethereum Name Service) ์ง์
ENS๋ ์ด๋๋ฆฌ์์ ๋๋ฉ์ธ ๋ค์ ์์คํ
์ด์ผ. 0x1234... ๊ฐ์ ์ฃผ์ ๋์ vitalik.eth ๊ฐ์ ์ด๋ฆ์ ์ฌ์ฉํ ์ ์์ง. ์ด๊ฑธ ์ง์ํ๋ฉด ์ฌ์ฉ์ ๊ฒฝํ์ด ํจ์ฌ ์ข์์ ธ!
async function getENSName(address) {
try {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const ensName = await provider.lookupAddress(address);
return ensName || address;
} catch (error) {
console.error('ENS lookup failed:', error);
return address;
}
}
// ์ฌ์ฉ ์์
const address = await signer.getAddress();
const displayName = await getENSName(address);
console.log(`Connected as: ${displayName}`);
3. ๋คํธ์ํฌ ์ฒดํฌ
์ฌ์ฉ์๊ฐ ์ฌ๋ฐ๋ฅธ ๋คํธ์ํฌ(๋ฉ์ธ๋ท, ํ ์คํธ๋ท ๋ฑ)์ ์ฐ๊ฒฐ๋์ด ์๋์ง ํ์ธํ๋ ๊ธฐ๋ฅ:
async function checkNetwork() {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const network = await provider.getNetwork();
const REQUIRED_CHAIN_ID = 1; // 1 = Ethereum Mainnet, 5 = Goerli Testnet
if (network.chainId !== REQUIRED_CHAIN_ID) {
showStatus(`Please switch to the correct network. Current: ${network.name}`, 'error');
// ๋คํธ์ํฌ ์ ํ ์์ฒญ
try {
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: `0x${REQUIRED_CHAIN_ID.toString(16)}` }],
});
} catch (error) {
console.error('Network switch failed:', error);
}
return false;
}
return true;
}
// ๋ก๊ทธ์ธ ์ ์ ์ฒดํฌ
async function login() {
if (!checkMetaMask()) return;
if (!await checkNetwork()) return;
// ... ๋๋จธ์ง ๋ก๊ทธ์ธ ๋ก์ง
}
4. ์ธ์ ๊ด๋ฆฌ ๊ฐ์
ํ ํฐ ๋ง๋ฃ ์๊ฐ์ ์ค์ ํ๊ณ , ์๋ ๊ฐฑ์ ๊ธฐ๋ฅ์ ์ถ๊ฐํด๋ณด์:
public function verify(Request $request)
{
// ... ๊ธฐ์กด ๊ฒ์ฆ ๋ก์ง
// ํ ํฐ ์์ฑ ์ ๋ง๋ฃ ์๊ฐ ์ค์
$token = $user->createToken('web3-auth', ['*'], now()->addDays(7))->plainTextToken;
return response()->json([
'message' => 'Authentication successful',
'user' => $user,
'token' => $token,
'expires_at' => now()->addDays(7)->toIso8601String(),
]);
}
// ํ ํฐ ๊ฐฑ์ ์๋ํฌ์ธํธ
public function refresh(Request $request)
{
$user = $request->user();
// ๊ธฐ์กด ํ ํฐ ์ญ์
$request->user()->currentAccessToken()->delete();
// ์ ํ ํฐ ๋ฐ๊ธ
$token = $user->createToken('web3-auth', ['*'], now()->addDays(7))->plainTextToken;
return response()->json([
'token' => $token,
'expires_at' => now()->addDays(7)->toIso8601String(),
]);
}
5. ์์ ํ๋กํ ํตํฉ
์ฌ์ฉ์๊ฐ ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ ๋ ฅํ ์ ์๊ฒ ํ๋กํ ์ ๋ฐ์ดํธ ๊ธฐ๋ฅ์ ์ถ๊ฐํ์:
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function updateProfile(Request $request)
{
$user = $request->user();
$validated = $request->validate([
'name' => 'sometimes|string|max:255',
'email' => 'sometimes|email|unique:users,email,' . $user->id,
'bio' => 'sometimes|string|max:500',
'avatar_url' => 'sometimes|url',
]);
$user->update($validated);
return response()->json([
'message' => 'Profile updated successfully',
'user' => $user,
]);
}
public function getProfile(Request $request)
{
return response()->json([
'user' => $request->user(),
]);
}
}
๐งช ํ ์คํธํ๊ธฐ
์ฝ๋๋ฅผ ์์ฑํ์ผ๋ฉด ํ ์คํธ๋ฅผ ํด๋ด์ผ์ง! ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ์ ๋๋ก ํ ์คํธํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์.
๋ก์ปฌ ํ๊ฒฝ์์ ํ ์คํธ
1๏ธโฃ ๋ฉํ๋ง์คํฌ ์ค์น
ํฌ๋กฌ์ด๋ ํ์ด์ดํญ์ค์ ๋ฉํ๋ง์คํฌ ํ์ฅ ํ๋ก๊ทธ๋จ์ ์ค์นํด. ์์ง ์ ํ๋ค๋ฉด metamask.io์์ ๋ค์ด๋ก๋!
2๏ธโฃ ํ
์คํธ ๊ณ์ ์์ฑ
๋ฉํ๋ง์คํฌ์์ ์ ์ง๊ฐ์ ๋ง๋ค๊ฑฐ๋, ๊ธฐ์กด ์ง๊ฐ์ ๊ฐ์ ธ์. ํ
์คํธ์ฉ์ผ๋ก๋ ์ ์ง๊ฐ์ ๋ง๋๋ ๊ฒ ์์ ํด!
3๏ธโฃ ํ
์คํธ๋ท ์ฌ์ฉ
์ค์ ์ด๋๋ฅผ ์ฌ์ฉํ ํ์๋ ์์ด. Goerli๋ Sepolia ๊ฐ์ ํ
์คํธ๋ท์ผ๋ก ์ ํํ๊ณ , ๋ฌด๋ฃ ํ
์คํธ ์ด๋๋ฅผ ๋ฐ์์ ํ
์คํธํด. Faucet ์ฌ์ดํธ์์ ๋ฐ์ ์ ์์ด!
4๏ธโฃ ์๋ฒ ์คํ
php artisan serve๋ก ๋ผ๋ผ๋ฒจ ์๋ฒ๋ฅผ ์คํํ๊ณ , ๋ธ๋ผ์ฐ์ ์์ http://localhost:8000์ ์ ์ํด.
5๏ธโฃ ๋ก๊ทธ์ธ ํ
์คํธ
Connect MetaMask ๋ฒํผ์ ํด๋ฆญํ๊ณ , ๋ฉํ๋ง์คํฌ ํ์
์์ ์ฐ๊ฒฐ์ ์น์ธํด. ๊ทธ ๋ค์ ์๋ช
์์ฒญ์ด ๋จ๋ฉด ์๋ช
ํด. ์ฑ๊ณตํ๋ฉด ๋ก๊ทธ์ธ ์๋ฃ!
์๋ํ ํ ์คํธ ์์ฑ
PHPUnit์ผ๋ก ๋ฐฑ์๋ ๋ก์ง์ ํ ์คํธํ ์ ์์ด:
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class Web3AuthTest extends TestCase
{
use RefreshDatabase;
public function test_can_get_nonce_for_new_address()
{
$address = '0x' . str_repeat('a', 40);
$response = $this->getJson("/api/auth/nonce/{$address}");
$response->assertStatus(200)
->assertJsonStructure(['nonce', 'message']);
$this->assertDatabaseHas('users', [
'wallet_address' => $address,
]);
}
public function test_nonce_is_consistent_for_same_address()
{
$address = '0x' . str_repeat('b', 40);
$response1 = $this->getJson("/api/auth/nonce/{$address}");
$nonce1 = $response1->json('nonce');
$response2 = $this->getJson("/api/auth/nonce/{$address}");
$nonce2 = $response2->json('nonce');
$this->assertEquals($nonce1, $nonce2);
}
public function test_invalid_address_returns_error()
{
$response = $this->getJson("/api/auth/nonce/invalid-address");
$response->assertStatus(400)
->assertJson(['error' => 'Invalid wallet address']);
}
public function test_verify_requires_address_and_signature()
{
$response = $this->postJson('/api/auth/verify', []);
$response->assertStatus(422)
->assertJsonValidationErrors(['address', 'signature']);
}
}
ํ ์คํธ ์คํ:
php artisan test --filter=Web3AuthTest
๐ก ์ค์ ์๋ช ํ ์คํธ: ์ค์ ์ํธํ์ ์๋ช ์ ํ ์คํธํ๋ ค๋ฉด ํ ์คํธ์ฉ ๊ฐ์ธํค๋ฅผ ์ฌ์ฉํด์ ์๋ช ์ ์์ฑํ๊ณ ๊ฒ์ฆํ๋ ๋ก์ง์ ์ถ๊ฐํ ์ ์์ด. ํ์ง๋ง ์ด๊ฑด ์ข ๋ณต์กํ๋๊น ํตํฉ ํ ์คํธ๋ ์๋์ผ๋ก ํ๋ ๊ฒ ๋ ์ค์ฉ์ ์ผ ์ ์์ด!
๐ฏ ์ค์ ๋ฐฐํฌ ๊ฐ์ด๋
๋ก์ปฌ์์ ์ ์๋ํ๋ค๋ฉด ์ด์ ์ค์ ์๋ฒ์ ๋ฐฐํฌํ ์ฐจ๋ก์ผ!
ํ๊ฒฝ ์ค์
.env ํ์ผ์ ํ๋ก๋์
์ค์ ์ ์ถ๊ฐํด:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com
# ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ค์
DB_CONNECTION=mysql
DB_HOST=your-db-host
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
# Sanctum ์ค์
SANCTUM_STATEFUL_DOMAINS=yourdomain.com
SESSION_DOMAIN=.yourdomain.com
# CORS ์ค์
CORS_ALLOWED_ORIGINS=https://yourdomain.com
HTTPS ์ค์
โ ๏ธ ํ์: ๋ฉํ๋ง์คํฌ๋ HTTPS์์๋ง ์๋ํด! Let's Encrypt๋ก ๋ฌด๋ฃ SSL ์ธ์ฆ์๋ฅผ ๋ฐ๊ธ๋ฐ์ ์ ์์ด. Nginx๋ Apache ์ค์ ์์ HTTPS๋ฅผ ํ์ฑํํ๊ณ , HTTP๋ HTTPS๋ก ๋ฆฌ๋ค์ด๋ ํธํ๋๋ก ์ค์ ํด์ผ ํด.
์ฑ๋ฅ ์ต์ ํ
# ์ค์ ์บ์ฑ
php artisan config:cache
# ๋ผ์ฐํธ ์บ์ฑ
php artisan route:cache
# ๋ทฐ ์บ์ฑ
php artisan view:cache
# Composer ์ต์ ํ
composer install --optimize-autoloader --no-dev
# ํ๋ก ํธ์๋ ๋น๋
npm run build
๋ชจ๋ํฐ๋ง ์ค์
๋ก๊ทธ๋ฅผ ๋ชจ๋ํฐ๋งํด์ ๋ฌธ์ ๋ฅผ ๋น ๋ฅด๊ฒ ํ์ ํ ์ ์์ด:
use Illuminate\Support\Facades\Log;
public function verify(Request $request)
{
try {
// ... ๊ฒ์ฆ ๋ก์ง
Log::info('Web3 login successful', [
'address' => $address,
'user_id' => $user->id,
]);
return response()->json([...]);
} catch (\Exception $e) {
Log::error('Web3 login failed', [
'address' => $request->input('address'),
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
throw $e;
}
}
๋ณด์ ์ฒดํฌ๋ฆฌ์คํธ
| ํญ๋ชฉ | ํ์ธ |
|---|---|
| HTTPS ํ์ฑํ | โ |
| CORS ์ค์ | โ |
| Rate Limiting | โ |
| ํ๊ฒฝ ๋ณ์ ๋ณด์ | โ |
| ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐฑ์ | โ |
| ์๋ฌ ๋ก๊น | โ |
| ํ ํฐ ๋ง๋ฃ ์ค์ | โ |
๐ค ์ฌ๋ฅ๋ท์์ Web3 ๊ฐ๋ฐ์ ์ฐพ๊ธฐ
๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ตฌํ์ด ์๊ฐ๋ณด๋ค ๋ณต์กํ๋ค๊ณ ๋๊ปด์ง ์ ์์ด. ํนํ ์ํธํ์ ์๋ช
๊ฒ์ฆ ๋ถ๋ถ์ ์ ๋ง ๊น๋ค๋กญ๊ฑฐ๋ ! ํผ์์ ๋งํ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ์ฌ๋ฅ๋ท์์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ์ ๋ฌธ๊ฐ์ ๋์์ ๋ฐ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ.
์ฌ๋ฅ๋ท์๋ Web3 ๊ฐ๋ฐ, ์ค๋งํธ ์ปจํธ๋ํธ ์์ฑ, NFT ๋ง์ผํ๋ ์ด์ค ๊ตฌ์ถ ๋ฑ ๋ค์ํ ๋ธ๋ก์ฒด์ธ ๊ด๋ จ ์ฌ๋ฅ์ ๊ฐ์ง ๊ฐ๋ฐ์๋ค์ด ๋ง์. ์ฝ๋ ๋ฆฌ๋ทฐ๋ฅผ ๋ฐ๊ฑฐ๋, ํน์ ๊ธฐ๋ฅ ๊ตฌํ์ ์๋ขฐํ๊ฑฐ๋, ๋ฉํ ๋ง์ ๋ฐ์ ์๋ ์์ง. ํผ์ ๊ณ ๋ฏผํ๋ ์๊ฐ์ ์ค์ด๊ณ ์ ๋ฌธ๊ฐ์ ๋
ธํ์ฐ๋ฅผ ๋ฐฐ์ธ ์ ์๋ ์ข์ ๊ธฐํ์ผ! ๐
๐ก ํธ๋ฌ๋ธ์ํ ๊ฐ์ด๋
๊ฐ๋ฐํ๋ค ๋ณด๋ฉด ์ฌ๋ฌ ๊ฐ์ง ๋ฌธ์ ์ ๋ถ๋ชํ ์ ์์ด. ์์ฃผ ๋ฐ์ํ๋ ๋ฌธ์ ๋ค๊ณผ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ ๋ฆฌํด๋ดค์ด!
๋ฌธ์ 1: ๋ฉํ๋ง์คํฌ๊ฐ ๊ฐ์ง๋์ง ์์
์ฆ์: window.ethereum์ด undefined
์์ธ:
- ๋ฉํ๋ง์คํฌ๊ฐ ์ค์น๋์ง ์์
- ํ์ด์ง ๋ก๋ ์ ์ ์คํฌ๋ฆฝํธ๊ฐ ์คํ๋จ
- ๋ค๋ฅธ ์ง๊ฐ ํ์ฅ์ด ์ถฉ๋
ํด๊ฒฐ:
// ํ์ด์ง ๋ก๋ ํ ์ฒดํฌ
window.addEventListener('load', async () => {
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
} else {
alert('Please install MetaMask!');
window.open('https://metamask.io/download/', '_blank');
}
});
๋ฌธ์ 2: ์๋ช ๊ฒ์ฆ ์คํจ
์ฆ์: ์๋ช
์ด ํญ์ ์ ํจํ์ง ์๋ค๊ณ ๋์ด
์์ธ:
- ๋ฉ์์ง ํ์์ด ํ๋ก ํธ์๋์ ๋ฐฑ์๋์์ ๋ค๋ฆ
- ์ฃผ์ ๋์๋ฌธ์ ๋ถ์ผ์น
- v ๊ฐ ์กฐ์ ๋ฌธ์
ํด๊ฒฐ:
๋ฉ์์ง๋ฅผ ์ ํํ ๋์ผํ๊ฒ ๊ตฌ์ฑํด์ผ ํด. ๊ณต๋ฐฑ ํ๋, ์ค๋ฐ๊ฟ ํ๋๋ ๋ฌ๋ผ์ง๋ฉด ์ ๋ผ!
// ํ๋ก ํธ์๋
const message = `Sign this message to authenticate with nonce: ${nonce}`;
// ๋ฐฑ์๋
$message = "Sign this message to authenticate with nonce: {$user->nonce}";
๋ฌธ์ 3: CORS ์๋ฌ
์ฆ์: Access-Control-Allow-Origin ์๋ฌ
์์ธ: ํ๋ก ํธ์๋์ ๋ฐฑ์๋ ๋๋ฉ์ธ์ด ๋ค๋ฅผ ๋ ๋ฐ์
ํด๊ฒฐ: config/cors.php ์ค์ :
return [
'paths' => ['api/*'],
'allowed_methods' => ['*'],
'allowed_origins' => [
'http://localhost:3000',
'https://yourdomain.com',
],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
];
๋ฌธ์ 4: ํ ํฐ์ด ์๋ํ์ง ์์
์ฆ์: API ์์ฒญ ์ 401 Unauthorized
์์ธ:
- ํ ํฐ์ด ํค๋์ ์ ๋๋ก ํฌํจ๋์ง ์์
- ํ ํฐ์ด ๋ง๋ฃ๋จ
- Sanctum ์ค์ ๋ฌธ์
ํด๊ฒฐ:
// ์ฌ๋ฐ๋ฅธ ํค๋ ์ค์
fetch('/api/user/profile', {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json',
'Content-Type': 'application/json',
}
});
๋ฌธ์ 5: ๋คํธ์ํฌ ์ ํ ์คํจ
์ฆ์: wallet_switchEthereumChain์ด ์๋ํ์ง ์์
์์ธ: ์ฌ์ฉ์๊ฐ ํด๋น ๋คํธ์ํฌ๋ฅผ ์ถ๊ฐํ์ง ์์
ํด๊ฒฐ: ๋คํธ์ํฌ ์ถ๊ฐ ์์ฒญ๋ ํจ๊ป ์ฒ๋ฆฌ:
async function switchToNetwork(chainId) {
try {
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: `0x${chainId.toString(16)}` }],
});
} catch (error) {
// ๋คํธ์ํฌ๊ฐ ์์ผ๋ฉด ์ถ๊ฐ
if (error.code === 4902) {
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: `0x${chainId.toString(16)}`,
chainName: 'Ethereum Mainnet',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18
},
rpcUrls: ['https://mainnet.infura.io/v3/YOUR_INFURA_KEY'],
blockExplorerUrls: ['https://etherscan.io']
}],
});
}
}
}
๐ ์ถ๊ฐ ํ์ต ์๋ฃ
๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ์ ๋ง์คํฐํ๋ค๋ฉด, ๋ค์ ๋จ๊ณ๋ก ๋์๊ฐ ์ ์์ด!
๋ ๋ฐฐ์ธ ๊ฒ๋ค
๐ ์ค๋งํธ ์ปจํธ๋ํธ ์ฐ๋
๋ฉํ๋ง์คํฌ๋ก ๋ก๊ทธ์ธํ ์ฌ์ฉ์๊ฐ ์ค๋งํธ ์ปจํธ๋ํธ์ ์ํธ์์ฉํ ์ ์๊ฒ ํด๋ณด์. NFT ๋ฏผํ
, ํ ํฐ ์ ์ก ๋ฑ์ ๊ตฌํํ ์ ์์ด.
๐ Sign-In with Ethereum (SIWE)
EIP-4361 ํ์ค์ ๋ฐ๋ฅด๋ ๋ ํ์คํ๋ ๋ก๊ทธ์ธ ๋ฐฉ์์ด์ผ. ๋ฉ์์ง ํ์์ด ์ ํด์ ธ ์์ด์ ๋ ์์ ํ๊ณ ์ผ๊ด์ฑ ์์ด.
๐จ WalletConnect ์ง์
๋ฉํ๋ง์คํฌ ์ธ์๋ ๋ค์ํ ์ง๊ฐ์ ์ง์ํ๊ณ ์ถ๋ค๋ฉด WalletConnect๋ฅผ ํตํฉํด๋ด. ๋ชจ๋ฐ์ผ ์ง๊ฐ๋ค๋ ์ฐ๊ฒฐํ ์ ์์ด!
โก Layer 2 ์๋ฃจ์
Polygon, Arbitrum, Optimism ๊ฐ์ Layer 2 ๋คํธ์ํฌ๋ฅผ ์ง์ํ๋ฉด ๊ฐ์ค๋น๋ฅผ ํฌ๊ฒ ์ค์ผ ์ ์์ด.
๐๏ธ DApp ๊ฐ๋ฐ
์์ ํ ํ์ค์ํ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ง๋ค์ด๋ณด์. IPFS๋ก ํ๋ก ํธ์๋๋ฅผ ํธ์คํ
ํ๊ณ , ์ค๋งํธ ์ปจํธ๋ํธ๋ก ๋ฐฑ์๋๋ฅผ ๋์ฒดํ ์ ์์ด.
์ ์ฉํ ๋ฆฌ์์ค
๊ณต์ ๋ฌธ์:
โข MetaMask Docs: docs.metamask.io
โข Ethers.js Docs: docs.ethers.io
โข Laravel Sanctum: laravel.com/docs/sanctum
์ปค๋ฎค๋ํฐ:
โข Ethereum Stack Exchange
โข r/ethdev (Reddit)
โข Web3 ๊ฐ๋ฐ์ ๋์ค์ฝ๋ ์๋ฒ๋ค
ํ์ต ํ๋ซํผ:
โข CryptoZombies (๊ฒ์์ผ๋ก ๋ฐฐ์ฐ๋ Solidity)
โข Buildspace (Web3 ํ๋ก์ ํธ ํํ ๋ฆฌ์ผ)
โข Alchemy University (๋ฌด๋ฃ Web3 ๊ฐ์)
๐ฌ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์! ์ฌ๊ธฐ๊น์ง ์๋ค๋ฉด ์ ๋ง ๋๋จํด! ๐
์ฐ๋ฆฌ๋ ๋ฉํ๋ง์คํฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ์ฒ์๋ถํฐ ๋๊น์ง ๊ตฌํํด๋ดค์ด. ๋ผ๋ผ๋ฒจ ๋ฐฑ์๋์์ ์ํธํ์ ์๋ช
์ ๊ฒ์ฆํ๊ณ , ํ๋ก ํธ์๋์์ ethers.js๋ก ๋ฉํ๋ง์คํฌ์ ํต์ ํ๋ ๋ฐฉ๋ฒ์ ๋ฐฐ์ ์ง. ๋ณด์ ๊ณ ๋ ค์ฌํญ๋ถํฐ ๊ณ ๊ธ ๊ธฐ๋ฅ, ํธ๋ฌ๋ธ์ํ
๊น์ง ๋ชจ๋ ๋ค๋ค์ด.
Web3๋ ์์ง ๋ฐ์ ํ๊ณ ์๋ ๋ถ์ผ์ผ. ์๋ก์ด ํ์ค๊ณผ ๋ฒ ์คํธ ํ๋ํฐ์ค๊ฐ ๊ณ์ ๋์ค๊ณ ์์ด. ํ์ง๋ง ์ด ๊ธ์์ ๋ฐฐ์ด ๊ธฐ๋ณธ ์๋ฆฌ๋ค์ ๋ณํ์ง ์์. ์ํธํ์ ์๋ช
์ ํตํ ์ธ์ฆ, ํ์ค์ํ๋ ์ ์ ๊ด๋ฆฌ, ์ด๋ฐ ํต์ฌ ๊ฐ๋
๋ค์ Web3์ ๊ทผ๊ฐ์ด๊ฑฐ๋ .
์ด์ ๋น์ ์ ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ์ ํ๋ฆฌ์ผ์ด์
์ ์ฒซ ๊ฑธ์์ ๋์ด. NFT ๋ง์ผํ๋ ์ด์ค๋ฅผ ๋ง๋ค๋ , DAO ํ๋ซํผ์ ๊ตฌ์ถํ๋ , DeFi ์๋น์ค๋ฅผ ๊ฐ๋ฐํ๋ , ์ด ๋ก๊ทธ์ธ ์์คํ
์ด ์์์ ์ด ๋ ๊ฑฐ์ผ.
ํน์ ๊ตฌํํ๋ค๊ฐ ๋งํ๋ ๋ถ๋ถ์ด ์๊ฑฐ๋, ๋ ๋ณต์กํ ๊ธฐ๋ฅ์ด ํ์ํ๋ค๋ฉด ์ฌ๋ฅ๋ท์์ ์ ๋ฌธ๊ฐ์ ๋์์ ๋ฐ๋ ๊ฒ๋ ์์ง ๋ง! ๋๋ก๋ ๊ฒฝํ ๋ง์ ๊ฐ๋ฐ์์ ์กฐ์ธ ํ๋ง๋๊ฐ ๋ฉฐ์น ๊ฐ์ ์ฝ์ง์ ์ค์ฌ์ค ์ ์๊ฑฐ๋ . ๐
์, ์ด์ ๋น์ ์ ๋ฉ์ง Web3 ํ๋ก์ ํธ๋ฅผ ์์ํด๋ด! ํ์ดํ
! ๐
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.