Ver3.0 ๐ ์๋ฐ๋ก ์์ํ๋ ๋ธ๋ก์ฒด์ธ ์ธ๊ณ! Web3j๋ฅผ ํ์ฉํ ์ด๋๋ฆฌ์ DApp ๊ฐ๋ฐ ์๋ฒฝ ๊ฐ์ด๋

๐ ์๋ฐ๋ก ์์ํ๋ ๋ธ๋ก์ฒด์ธ ์ธ๊ณ! Web3j๋ฅผ ํ์ฉํ ์ด๋๋ฆฌ์ DApp ๊ฐ๋ฐ ์๋ฒฝ ๊ฐ์ด๋
์๋ ! ๐ ํน์ ๋ธ๋ก์ฒด์ธ์ด๋ ์ด๋๋ฆฌ์์ ๊ด์ฌ์ ์๋๋ฐ, JavaScript๋ Solidity๋ง ๋ด์ผ ํ๋ค๊ณ ์๊ฐํ๋ ์๋ฐ ๊ฐ๋ฐ์๋ผ๋ฉด? ์ค๋ ์ด์ผ๊ธฐ๋ ๋๋ฅผ ์ํ ๊ฑฐ์ผ! ์ฐ๋ฆฌ๊ฐ ์ต์ํ ์๋ฐ๋ก๋ ์ถฉ๋ถํ ๋ฉ์ง ๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค ์ ์๊ฑฐ๋ . ๐ฏ
๋ธ๋ก์ฒด์ธ ๊ธฐ์ ์ด ์ธ์์ ๋ฐ๊พธ๊ณ ์๋ค๋ ๊ฑด ์ด์ ๋๊ตฌ๋ ์๋ ์ฌ์ค์ด์ง? NFT, DeFi, ๋ฉํ๋ฒ์ค... ์ด ๋ชจ๋ ๊ฒ ๋ธ๋ก์ฒด์ธ ์์์ ๋์๊ฐ๊ณ ์์ด. ๊ทธ๋ฐ๋ฐ ์๋ฐ ๊ฐ๋ฐ์๋ค์ ์ข ์ข ์ด ํํฐ์์ ์์ธ๊ฐ์ ๋๋ผ๊ณค ํด. "๋๋ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ํด๋ณด๊ณ ์ถ์๋ฐ, ์๋ก์ด ์ธ์ด๋ฅผ ๋ ๋ฐฐ์์ผ ํ๋?" ํ๋ฉด์ ๋ง์ด์ผ. ๐
๊ทธ๋ฐ๋ฐ ์ฌ๊ธฐ ์ข์ ์์์ด ์์ด! Web3j๋ผ๋ ๊ฐ๋ ฅํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ถ์, ์ฐ๋ฆฌ๋ ์๋ฐ๋ก๋ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ์ํธ์์ฉํ๋ DApp(ํ์ค์ํ ์ ํ๋ฆฌ์ผ์ด์ )์ ๋ง๋ค ์ ์์ด. ๋ง์น JDBC๋ก ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ํต์ ํ๋ฏ์ด, Web3j๋ก ๋ธ๋ก์ฒด์ธ๊ณผ ๋ํํ ์ ์๋ ๊ฑฐ์ง! ๐
๐ฏ ๋ธ๋ก์ฒด์ธ๊ณผ DApp, ๊ทธ๊ฒ ๋ญ๋ฐ?
๋ณธ๊ฒฉ์ ์ผ๋ก ์ฝ๋๋ฅผ ํํค์น๊ธฐ ์ ์, ๊ธฐ๋ณธ ๊ฐ๋ ๋ถํฐ ์ง๊ณ ๋์ด๊ฐ์. ๋ธ๋ก์ฒด์ธ์ ์ฒ์ ์ ํ๋ ์๋ฐ ๊ฐ๋ฐ์๋ผ๋ฉด ์ด ๋ถ๋ถ์ด ํนํ ์ค์ํด! ๐
๋ธ๋ก์ฒด์ธ์ ํต์ฌ ๊ฐ๋
๋ธ๋ก์ฒด์ธ์ ๋ง ๊ทธ๋๋ก '๋ธ๋ก'๋ค์ด '์ฒด์ธ'์ฒ๋ผ ์ฐ๊ฒฐ๋ ๊ตฌ์กฐ์ผ. ๊ฐ ๋ธ๋ก์๋ ๊ฑฐ๋ ์ ๋ณด๊ฐ ๋ด๊ฒจ ์๊ณ , ์ด์ ๋ธ๋ก์ ํด์๊ฐ์ ํฌํจํ๊ณ ์์ด์ ์ฒด์ธ์ฒ๋ผ ์ฐ๊ฒฐ๋๋ ๊ฑฐ์ง. ์ด๊ฒ ์ ํ๋ช ์ ์ด๋๊ณ ? ๐ค
2. ํฌ๋ช ์ฑ(Transparency) - ๋ชจ๋ ๊ฑฐ๋ ๊ธฐ๋ก์ด ๊ณต๊ฐ๋์ด ์์ด. ๋๊ตฌ๋ ํ์ธํ ์ ์์ง๋ง, ๊ฐ์ธ์ ๋ณด๋ ์ํธํ๋์ด ๋ณดํธ๋ผ.
3. ๋ถ๋ณ์ฑ(Immutability) - ํ๋ฒ ๊ธฐ๋ก๋ ๋ฐ์ดํฐ๋ ์์ ์ด ๊ฑฐ์ ๋ถ๊ฐ๋ฅํด. ๊ณผ๊ฑฐ ๋ฐ์ดํฐ๋ฅผ ์กฐ์ํ๋ ค๋ฉด ์ ์ฒด ๋คํธ์ํฌ์ 51% ์ด์์ ์ฅ์ ํด์ผ ํ๊ฑฐ๋ .
DApp์ด๋?
DApp(Decentralized Application)์ ํ์ค์ํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฝ์์ผ. ์ผ๋ฐ ์ฑ๊ณผ ๋ญ๊ฐ ๋ค๋ฅด๋๊ณ ? ์ผ๋ฐ ์ฑ์ ์ค์ ์๋ฒ์์ ๋์๊ฐ์ง๋ง, DApp์ ๋ธ๋ก์ฒด์ธ ๋คํธ์ํฌ ์์์ ์คํ๋ผ. ๐
์๋ฅผ ๋ค์ด๋ณผ๊ฒ. ์ ํต์ ์ธ ์ํ ์ฑ์ ์๊ฐํด๋ด. ๋์ ๊ณ์ข ์์ก, ๊ฑฐ๋ ๋ด์ญ ๋ชจ๋ ์ํ์ ์ค์ ์๋ฒ์ ์ ์ฅ๋์ด ์์ง? ์ํ์ด ๋งํ๊ฑฐ๋, ํดํน๋นํ๊ฑฐ๋, ์์คํ ์ด ๋ค์ด๋๋ฉด ๋์ ๋์ ์ ๊ทผํ ์ ์์ด. ๐ฑ
ํ์ง๋ง DApp ๊ธฐ๋ฐ์ ๊ธ์ต ์๋น์ค(DeFi)๋ ๋ค๋ฅด์ง! ๋์ ์์ฐ ์ ๋ณด๊ฐ ๋ธ๋ก์ฒด์ธ์ ๋ถ์ฐ ์ ์ฅ๋์ด ์์ด์, ํน์ ํ์ฌ๊ฐ ๋งํด๋ ๋์ ์์ฐ์ ์์ ํด. ์ด๊ฒ ๋ฐ๋ก DApp์ ํ์ด์ผ! ๐ช
์ด๋๋ฆฌ์์ด๋?
์ด๋๋ฆฌ์(Ethereum)์ ๋นํธ์ฝ์ธ ๋ค์์ผ๋ก ์ ๋ช ํ ๋ธ๋ก์ฒด์ธ ํ๋ซํผ์ด์ผ. ๋นํธ์ฝ์ธ์ด '๋์งํธ ํํ'์ ์ง์คํ๋ค๋ฉด, ์ด๋๋ฆฌ์์ '์ค๋งํธ ์ปจํธ๋ํธ'๋ผ๋ ๊ฐ๋ ์ ๋์ ํด์ ๋ธ๋ก์ฒด์ธ ์์์ ํ๋ก๊ทธ๋จ์ ์คํํ ์ ์๊ฒ ๋ง๋ค์์ด. ๐จ
์ค๋งํธ ์ปจํธ๋ํธ(Smart Contract)๋ ๋ธ๋ก์ฒด์ธ์ ๋ฐฐํฌ๋๋ ํ๋ก๊ทธ๋จ์ด์ผ. ์ผ์ข ์ '์๋ ์คํ๋๋ ๊ณ์ฝ์'๋ผ๊ณ ์๊ฐํ๋ฉด ๋ผ. ์๋ฅผ ๋ค์ด, "A๊ฐ B์๊ฒ 1 ETH๋ฅผ ๋ณด๋ด๋ฉด, ์๋์ผ๋ก NFT๋ฅผ ์ ์กํ๋ค"๋ ๋ก์ง์ ์ฝ๋๋ก ์์ฑํด์ ๋ธ๋ก์ฒด์ธ์ ์ฌ๋ ค๋๋ ๊ฑฐ์ง.
โ Web3j: ์๋ฐ ๊ฐ๋ฐ์์ ๋ธ๋ก์ฒด์ธ ์ฌ๊ถ
์, ์ด์ ์ฐ๋ฆฌ์ ์ฃผ์ธ๊ณต Web3j๋ฅผ ๋ง๋๋ณผ ์๊ฐ์ด์ผ! Web3j๋ ์๋ฐ์์ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ์ํธ์์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. ๋ง์น JDBC๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ๋ค๋ฆฌ ์ญํ ์ ํ๋ฏ์ด, Web3j๋ ๋ธ๋ก์ฒด์ธ๊ณผ์ ๋ค๋ฆฌ ์ญํ ์ ํด์ฃผ๋ ๊ฑฐ์ง. ๐
Web3j์ ์ฃผ์ ๊ธฐ๋ฅ
- โ ์ด๋๋ฆฌ์ ๋ ธ๋์ JSON-RPC ํต์
- โ ์ง๊ฐ ์์ฑ ๋ฐ ๊ด๋ฆฌ
- โ ํธ๋์ญ์ ์์ฑ ๋ฐ ์ ์ก
- โ ์ค๋งํธ ์ปจํธ๋ํธ ๋ฐฐํฌ
- โ ์ค๋งํธ ์ปจํธ๋ํธ ํจ์ ํธ์ถ
- โ ์ด๋ฒคํธ ๋ฆฌ์ค๋
- โ ENS(Ethereum Name Service) ์ง์
- โ ERC-20, ERC-721 ํ ํฐ ํ์ค ์ง์
Web3j vs Web3.js
ํน์ JavaScript์ Web3.js๋ฅผ ๋ค์ด๋ดค์ ์๋ ์์ด. Web3j๋ ๊ทธ๊ฒ์ ์๋ฐ ๋ฒ์ ์ด๋ผ๊ณ ๋ณด๋ฉด ๋ผ. ๊ธฐ๋ฅ์ ์ผ๋ก๋ ๊ฑฐ์ ๋์ผํ์ง๋ง, ์๋ฐ์ ๊ฐ๋ ฅํ ํ์ ์์คํ ๊ณผ ๊ฐ์ฒด์งํฅ ํจ๋ฌ๋ค์์ ํ์ฉํ ์ ์๋ค๋ ๊ฒ ํฐ ์ฅ์ ์ด์ง! ๐ฏ
ํนํ ์ํฐํ๋ผ์ด์ฆ ํ๊ฒฝ์์๋ ์๋ฐ์ ์์ ์ฑ๊ณผ ์ฑ์ํ ์ํ๊ณ๊ฐ ํฐ ๊ฐ์ ์ด ๋ผ. Spring Boot์ ํตํฉํด์ ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ๋ฐฑ์๋ ์๋น์ค๋ฅผ ๋ง๋ค ์๋ ์๊ณ , Android ์ฑ์์๋ ์ฌ์ฉํ ์ ์์ด!
๐ ๏ธ ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ถํ๊ธฐ
์ด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ์์ ๋๋ฝํ๋ณผ ์๊ฐ์ด์ผ! ๋จผ์ ๊ฐ๋ฐ ํ๊ฒฝ๋ถํฐ ์ธํ ํด๋ณด์. ๊ฑฑ์ ๋ง, ์๊ฐ๋ณด๋ค ๊ฐ๋จํด! ๐
Web3j๋ Java 8 ์ด์์ ์๊ตฌํด. ์ต์ LTS ๋ฒ์ ์ธ Java 17์ ์ฌ์ฉํ๋ ๊ฑธ ์ถ์ฒํด!
IDE์์ ์ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด์ค. IntelliJ IDEA๋ Eclipse ๋ญ๋ ์๊ด์์ด!
ํ๋ก์ ํธ์ Web3j ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐํด์ผ ํด. ์๋ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํด๋ด!
Maven ์ค์
Maven์ ์ฌ์ฉํ๋ค๋ฉด pom.xml์ ๋ค์ ์์กด์ฑ์ ์ถ๊ฐํด์ค:
<dependencies>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.10.3</version>
</dependency>
<!-- ๋ก๊น
์ ์ํ SLF4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
Gradle ์ค์
Gradle์ ์ ํธํ๋ค๋ฉด build.gradle์ ์ด๋ ๊ฒ ์ถ๊ฐํด:
dependencies {
implementation 'org.web3j:core:4.10.3'
implementation 'org.slf4j:slf4j-simple:2.0.9'
}
๋ธ๋ก์ฒด์ธ๊ณผ ํต์ ํ๋ ค๋ฉด ์ด๋๋ฆฌ์ ๋ ธ๋์ ์ ๊ทผํด์ผ ํด. ์ง์ ๋ ธ๋๋ฅผ ์ด์ํ ์๋ ์์ง๋ง, ์ด๋ณด์์๊ฒ๋ Infura๋ Alchemy ๊ฐ์ ์๋น์ค๋ฅผ ์ถ์ฒํด!
Infura ์ค์ ํ๊ธฐ
Infura๋ ์ด๋๋ฆฌ์ ๋ ธ๋๋ฅผ ํด๋ผ์ฐ๋๋ก ์ ๊ณตํ๋ ์๋น์ค์ผ. ๋ฌด๋ฃ ํ๋์ผ๋ก๋ ์ถฉ๋ถํ ๊ฐ๋ฐํ ์ ์์ด! ๐
2. ์ ํ๋ก์ ํธ ์์ฑ
3. ํ๋ก์ ํธ ID ๋ณต์ฌ (์ด๊ฒ API ํค์ผ!)
4. ๋คํธ์ํฌ ์ ํ (๊ฐ๋ฐ์ฉ์ผ๋ก๋ Sepolia ํ ์คํธ๋ท ์ถ์ฒ)
Infura ์๋ํฌ์ธํธ๋ ์ด๋ฐ ํ์์ด์ผ:
// ๋ฉ์ธ๋ท
https://mainnet.infura.io/v3/YOUR_PROJECT_ID
// Sepolia ํ
์คํธ๋ท (๊ฐ๋ฐ์ฉ ์ถ์ฒ!)
https://sepolia.infura.io/v3/YOUR_PROJECT_ID
๐ ์ฒซ ๋ฒ์งธ Web3j ์ ํ๋ฆฌ์ผ์ด์
์, ์ด์ ์ง์ง ์ฝ๋๋ฅผ ์์ฑํด๋ณผ ์๊ฐ์ด์ผ! ์ฒซ ๋ฒ์งธ ์์ ๋ก ๋ธ๋ก์ฒด์ธ์ ์ฐ๊ฒฐํ๊ณ ์ต์ ๋ธ๋ก ๋ฒํธ๋ฅผ ๊ฐ์ ธ์๋ณด์. ๊ฐ๋จํ์ง๋ง ๋ธ๋ก์ฒด์ธ๊ณผ์ ์ฒซ ๋ํ๋ผ๋ ์ ์์ ์๋ฏธ๊ฐ ์์ด! ๐
๋ธ๋ก์ฒด์ธ ์ฐ๊ฒฐํ๊ธฐ
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.core.methods.response.EthBlockNumber;
import org.web3j.protocol.core.methods.response.Web3ClientVersion;
public class BlockchainConnector {
public static void main(String[] args) {
// Infura ์๋ํฌ์ธํธ๋ก Web3j ์ธ์คํด์ค ์์ฑ
String infuraUrl = "https://sepolia.infura.io/v3/YOUR_PROJECT_ID";
Web3j web3j = Web3j.build(new HttpService(infuraUrl));
try {
// ํด๋ผ์ด์ธํธ ๋ฒ์ ํ์ธ (์ฐ๊ฒฐ ํ
์คํธ)
Web3ClientVersion clientVersion = web3j.web3ClientVersion().send();
System.out.println("๐ฏ ์ฐ๊ฒฐ ์ฑ๊ณต!");
System.out.println("ํด๋ผ์ด์ธํธ ๋ฒ์ : " + clientVersion.getWeb3ClientVersion());
// ์ต์ ๋ธ๋ก ๋ฒํธ ๊ฐ์ ธ์ค๊ธฐ
EthBlockNumber blockNumber = web3j.ethBlockNumber().send();
System.out.println("๐ฆ ์ต์ ๋ธ๋ก ๋ฒํธ: " + blockNumber.getBlockNumber());
} catch (Exception e) {
System.err.println("โ ์ค๋ฅ ๋ฐ์: " + e.getMessage());
e.printStackTrace();
} finally {
// ๋ฆฌ์์ค ์ ๋ฆฌ
web3j.shutdown();
}
}
}
์ด ์ฝ๋๋ฅผ ์คํํ๋ฉด ๋ญ๊ฐ ๋ง๋ฒ ๊ฐ์ ์ผ์ด ์ผ์ด๋! ๋์ ์๋ฐ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ค์ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ํต์ ํ๋ ๊ฑฐ์ผ. ๐ช
์ฝ๋ ํด๋ถํ๊ธฐ
์ ์ฝ๋๋ฅผ ํ ์ค์ฉ ๋ฏ์ด๋ณด์:
Web3j.build(new HttpService(infuraUrl))๋ HTTP๋ฅผ ํตํด ์ด๋๋ฆฌ์ ๋
ธ๋์ ํต์ ํ ์ ์๋ Web3j ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด์ค. ์ด๊ฒ ์ฐ๋ฆฌ์ ๋ธ๋ก์ฒด์ธ ํด๋ผ์ด์ธํธ์ผ!2. ๋๊ธฐ vs ๋น๋๊ธฐ
.send() ๋ฉ์๋๋ ๋๊ธฐ ๋ฐฉ์์ด์ผ. ๋ธ๋ก์ฒด์ธ ์๋ต์ ๊ธฐ๋ค๋ ธ๋ค๊ฐ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ์ง. ๋น๋๊ธฐ๋ก ํ๊ณ ์ถ๋ค๋ฉด .sendAsync()๋ฅผ ์ฌ์ฉํ๋ฉด ๋ผ. CompletableFuture๋ฅผ ๋ฐํํด์ ๋
ผ๋ธ๋กํน ์ฒ๋ฆฌ๊ฐ ๊ฐ๋ฅํด!3. ๋ฆฌ์์ค ์ ๋ฆฌ
web3j.shutdown()์ผ๋ก ์ฐ๊ฒฐ์ ์ ๋ฆฌํด์ค์ผ ํด. ์ ๊ทธ๋ฌ๋ฉด ์ค๋ ๋๊ฐ ๊ณ์ ์ด์์์ด์ ์ ํ๋ฆฌ์ผ์ด์
์ด ์ข
๋ฃ๋์ง ์์ ์ ์์ด.
๋น๋๊ธฐ ๋ฒ์ ์ผ๋ก ๊ฐ์ ํ๊ธฐ
์ค์ ํ๋ก๋์ ํ๊ฒฝ์์๋ ๋น๋๊ธฐ ์ฒ๋ฆฌ๊ฐ ๋ ํจ์จ์ ์ด์ผ. ํนํ ์ฌ๋ฌ ์์ฒญ์ ๋์์ ์ฒ๋ฆฌํด์ผ ํ ๋ ๋ง์ด์ง! ๐
import java.util.concurrent.CompletableFuture;
public class AsyncBlockchainConnector {
public static void main(String[] args) {
String infuraUrl = "https://sepolia.infura.io/v3/YOUR_PROJECT_ID";
Web3j web3j = Web3j.build(new HttpService(infuraUrl));
// ๋น๋๊ธฐ๋ก ํด๋ผ์ด์ธํธ ๋ฒ์ ๊ฐ์ ธ์ค๊ธฐ
CompletableFuture<Web3ClientVersion> clientVersionFuture =
web3j.web3ClientVersion().sendAsync();
// ๋น๋๊ธฐ๋ก ๋ธ๋ก ๋ฒํธ ๊ฐ์ ธ์ค๊ธฐ
CompletableFuture<EthBlockNumber> blockNumberFuture =
web3j.ethBlockNumber().sendAsync();
// ๋ ์์ฒญ์ด ๋ชจ๋ ์๋ฃ๋ ๋๊น์ง ๋๊ธฐ
CompletableFuture.allOf(clientVersionFuture, blockNumberFuture)
.thenRun(() -> {
try {
String version = clientVersionFuture.get().getWeb3ClientVersion();
String blockNum = blockNumberFuture.get().getBlockNumber().toString();
System.out.println("๐ฏ ๋น๋๊ธฐ ์ฐ๊ฒฐ ์ฑ๊ณต!");
System.out.println("ํด๋ผ์ด์ธํธ ๋ฒ์ : " + version);
System.out.println("๐ฆ ์ต์ ๋ธ๋ก ๋ฒํธ: " + blockNum);
} catch (Exception e) {
System.err.println("โ ์ค๋ฅ: " + e.getMessage());
}
})
.join(); // ๋ฉ์ธ ์ค๋ ๋๊ฐ ์ข
๋ฃ๋์ง ์๋๋ก ๋๊ธฐ
web3j.shutdown();
}
}
CompletableFuture๋ฅผ ์ฌ์ฉํ๋ฉด ์ฌ๋ฌ ๋ธ๋ก์ฒด์ธ ์์ฒญ์ ๋ณ๋ ฌ๋ก ์ฒ๋ฆฌํ ์ ์์ด์ ์ฑ๋ฅ์ด ํจ์ฌ ์ข์์ ธ! ๐
๐ฐ ์ง๊ฐ ์์ฑ๊ณผ ๊ด๋ฆฌ
๋ธ๋ก์ฒด์ธ์์ ๋ญ๊ฐ๋ฅผ ํ๋ ค๋ฉด ์ง๊ฐ์ด ํ์ํด. ์ง๊ฐ์ ๋์ ๋์งํธ ์ ์์ด์ ์์ฐ์ ๋ณด๊ดํ๋ ๊ณณ์ด์ผ. Web3j๋ก ์ง๊ฐ์ ์์ฑํ๊ณ ๊ด๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์! ๐
์ ์ง๊ฐ ์์ฑํ๊ธฐ
import org.web3j.crypto.Credentials;
import org.web3j.crypto.WalletUtils;
import java.io.File;
public class WalletCreator {
public static void main(String[] args) {
try {
// ์ง๊ฐ ํ์ผ์ ์ ์ฅํ ๋๋ ํ ๋ฆฌ
String walletDir = "./wallets";
new File(walletDir).mkdirs();
// ์ง๊ฐ ๋น๋ฐ๋ฒํธ ์ค์
String password = "mySecurePassword123!";
// ์ ์ง๊ฐ ์์ฑ
String walletFileName = WalletUtils.generateNewWalletFile(
password,
new File(walletDir)
);
System.out.println("โ
์ง๊ฐ ์์ฑ ์๋ฃ!");
System.out.println("๐ ํ์ผ๋ช
: " + walletFileName);
// ์์ฑ๋ ์ง๊ฐ ๋ก๋
Credentials credentials = WalletUtils.loadCredentials(
password,
walletDir + "/" + walletFileName
);
// ์ง๊ฐ ์ฃผ์ ์ถ๋ ฅ
String address = credentials.getAddress();
System.out.println("๐ ์ง๊ฐ ์ฃผ์: " + address);
// ๊ฐ์ธํค ์ถ๋ ฅ (์ค์ ๋ก๋ ์ ๋ ์ถ๋ ฅํ๋ฉด ์ ๋ผ!)
String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16);
System.out.println("๐ ๊ฐ์ธํค: " + privateKey);
} catch (Exception e) {
System.err.println("โ ์ง๊ฐ ์์ฑ ์คํจ: " + e.getMessage());
e.printStackTrace();
}
}
}
์ง๊ฐ ์ฃผ์์ ๊ตฌ์กฐ
์ด๋๋ฆฌ์ ์ง๊ฐ ์ฃผ์๋ 0x๋ก ์์ํ๋ 42์๋ฆฌ 16์ง์ ๋ฌธ์์ด์ด์ผ. ์๋ฅผ ๋ค๋ฉด ์ด๋ฐ ์์ด์ง:
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb์ด ์ฃผ์๋ ๊ณต๊ฐ๋์ด๋ ๊ด์ฐฎ์. ์ํ ๊ณ์ข๋ฒํธ์ฒ๋ผ ์๊ฐํ๋ฉด ๋ผ. ํ์ง๋ง ๊ฐ์ธํค๋ ๋น๋ฐ๋ฒํธ์ ๊ฐ์์ ์ ๋ ๊ณต๊ฐํ๋ฉด ์ ๋ผ!
๊ธฐ์กด ์ง๊ฐ ๋ถ๋ฌ์ค๊ธฐ
์ด๋ฏธ ์๋ ์ง๊ฐ์ ์ฌ์ฉํ๊ณ ์ถ๋ค๋ฉด? ๊ฐ์ธํค๋ ๋๋ชจ๋(๋ณต๊ตฌ ๋ฌธ๊ตฌ)์ผ๋ก ์ง๊ฐ์ ๋ถ๋ฌ์ฌ ์ ์์ด:
import org.web3j.crypto.Credentials;
import org.web3j.crypto.ECKeyPair;
import java.math.BigInteger;
public class WalletLoader {
public static void main(String[] args) {
// ๋ฐฉ๋ฒ 1: ๊ฐ์ธํค๋ก ๋ถ๋ฌ์ค๊ธฐ
String privateKeyHex = "your_private_key_here";
BigInteger privateKey = new BigInteger(privateKeyHex, 16);
ECKeyPair keyPair = ECKeyPair.create(privateKey);
Credentials credentials = Credentials.create(keyPair);
System.out.println("์ง๊ฐ ์ฃผ์: " + credentials.getAddress());
// ๋ฐฉ๋ฒ 2: ์ง๊ฐ ํ์ผ๋ก ๋ถ๋ฌ์ค๊ธฐ
try {
Credentials creds = WalletUtils.loadCredentials(
"password",
"/path/to/wallet/file"
);
System.out.println("์ง๊ฐ ๋ก๋ ์๋ฃ: " + creds.getAddress());
} catch (Exception e) {
e.printStackTrace();
}
}
}
ํ ์คํธ๋ท ETH ๋ฐ๊ธฐ
์ง๊ฐ์ ๋ง๋ค์์ผ๋ฉด ํ ์คํธ์ฉ ์ด๋๊ฐ ํ์ํด. ์ค์ ๋์ ์ธ ์ ์์ผ๋๊น! ํ ์คํธ๋ท Faucet์์ ๋ฌด๋ฃ๋ก ๋ฐ์ ์ ์์ด: ๐ฐ
- https://faucet.sepolia.dev/
์ง๊ฐ ์ฃผ์๋ฅผ ์ ๋ ฅํ๋ฉด 0.5 ETH ์ ๋๋ฅผ ๋ฌด๋ฃ๋ก ๋ฐ์ ์ ์์ด. ํ๋ฃจ์ ํ ๋ฒ์ฉ ๋ฐ์ ์ ์์ผ๋ ๊ฐ๋ฐํ๋ฉด์ ๋ถ์กฑํ๋ฉด ๋ค์ ๋ฐ์ผ๋ฉด ๋ผ!
๐ธ ํธ๋์ญ์ ๋ณด๋ด๊ธฐ
์ด์ ์ง์ง ๋ธ๋ก์ฒด์ธ๋ค์ด ์ผ์ ํด๋ณด์! ๋ค๋ฅธ ์ฃผ์๋ก ETH๋ฅผ ์ ์กํ๋ ํธ๋์ญ์ ์ ๋ง๋ค์ด๋ณผ ๊ฑฐ์ผ. ์ด๊ฒ ๋ฐ๋ก ๋ธ๋ก์ฒด์ธ์ ํต์ฌ ๊ธฐ๋ฅ์ด์ง! ๐ฏ
๊ฐ๋จํ ETH ์ ์ก
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Transfer;
import org.web3j.utils.Convert;
import java.math.BigDecimal;
public class EthTransfer {
public static void main(String[] args) {
String infuraUrl = "https://sepolia.infura.io/v3/YOUR_PROJECT_ID";
Web3j web3j = Web3j.build(new HttpService(infuraUrl));
try {
// ์ง๊ฐ ๋ก๋
Credentials credentials = WalletUtils.loadCredentials(
"password",
"/path/to/wallet"
);
// ๋ฐ๋ ์ฌ๋ ์ฃผ์
String toAddress = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb";
// ์ ์กํ ๊ธ์ก (0.01 ETH)
BigDecimal amount = BigDecimal.valueOf(0.01);
System.out.println("๐ธ ํธ๋์ญ์
์ ์ก ์ค...");
// ETH ์ ์ก
TransactionReceipt receipt = Transfer.sendFunds(
web3j,
credentials,
toAddress,
amount,
Convert.Unit.ETHER
).send();
System.out.println("โ
์ ์ก ์๋ฃ!");
System.out.println("๐ ํธ๋์ญ์
ํด์: " + receipt.getTransactionHash());
System.out.println("โฝ ์ฌ์ฉ๋ ๊ฐ์ค: " + receipt.getGasUsed());
} catch (Exception e) {
System.err.println("โ ์ ์ก ์คํจ: " + e.getMessage());
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
}
ํธ๋์ญ์ ์ ๊ตฌ์กฐ
๋ธ๋ก์ฒด์ธ ํธ๋์ญ์ ์ ์ฌ๋ฌ ์์๋ก ๊ตฌ์ฑ๋์ด ์์ด. ๊ฐ๊ฐ์ ์ดํดํ๋ฉด ๋ธ๋ก์ฒด์ธ์ ๋ ๊น์ด ์ดํดํ ์ ์์ง! ๐
| ํ๋ | ์ค๋ช |
|---|---|
| from | ๋ณด๋ด๋ ์ฌ๋์ ์ฃผ์ (๋์ ์ง๊ฐ ์ฃผ์) |
| to | ๋ฐ๋ ์ฌ๋์ ์ฃผ์ |
| value | ์ ์กํ ETH ๊ธ์ก (Wei ๋จ์) |
| gas | ํธ๋์ญ์ ์คํ์ ํ์ํ ๊ฐ์ค ํ๋ |
| gasPrice | ๊ฐ์ค 1๋จ์๋น ์ง๋ถํ ๊ฐ๊ฒฉ |
| nonce | ๋ฐ์ ์๊ฐ ๋ณด๋ธ ํธ๋์ญ์ ์๋ฒ |
| data | ์ค๋งํธ ์ปจํธ๋ํธ ํธ์ถ ๋ฐ์ดํฐ |
๊ฐ์ค(Gas)๋?
๋ธ๋ก์ฒด์ธ์์ ๊ฐ์ค(Gas)๋ ํธ๋์ญ์ ์์๋ฃ์ผ. ์ ํ์ํ๋๊ณ ? ๐ค
2. ์ฑ๊ตด์ ๋ณด์ - ํธ๋์ญ์ ์ ์ฒ๋ฆฌํ๋ ์ฑ๊ตด์(๋๋ ๊ฒ์ฆ์)์๊ฒ ๋ณด์์ ์ค.
3. ์์ ํ ๋น - ๋ณต์กํ ์ฐ์ฐ์ผ์๋ก ๋ ๋ง์ ๊ฐ์ค๊ฐ ํ์ํด. ์ด๊ฒ ๊ณต์ ํ ์์ ๋ฐฐ๋ถ์ ๊ฐ๋ฅํ๊ฒ ํด.
๊ฐ์ค ๊ฐ๊ฒฉ์ ์์ฅ ์ํฉ์ ๋ฐ๋ผ ๋ณํด. ๋คํธ์ํฌ๊ฐ ํผ์กํ๋ฉด ๊ฐ์ค๋น๊ฐ ์ฌ๋ผ๊ฐ๊ณ , ํ๊ฐํ๋ฉด ๋ด๋ ค๊ฐ์ง. ๋ง์น ์ฐ๋ฒ์ ํ ์ฆ ์๊ธ ๊ฐ์ ๊ฑฐ์ผ! ๐
์๋์ผ๋ก ํธ๋์ญ์ ๋ง๋ค๊ธฐ
Transfer.sendFunds()๋ ํธ๋ฆฌํ์ง๋ง, ๋ ์ธ๋ฐํ ์ ์ด๊ฐ ํ์ํ ๋๋ ์์ด. ์๋์ผ๋ก ํธ๋์ญ์
์ ๋ง๋ค์ด๋ณด์:
import org.web3j.crypto.*;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.utils.Numeric;
import java.math.BigInteger;
public class ManualTransaction {
public static void main(String[] args) {
Web3j web3j = Web3j.build(new HttpService("https://sepolia.infura.io/v3/YOUR_PROJECT_ID"));
try {
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/wallet");
// ํ์ฌ nonce ๊ฐ์ ธ์ค๊ธฐ
BigInteger nonce = web3j.ethGetTransactionCount(
credentials.getAddress(),
DefaultBlockParameterName.LATEST
).send().getTransactionCount();
// ๊ฐ์ค ๊ฐ๊ฒฉ ๊ฐ์ ธ์ค๊ธฐ
BigInteger gasPrice = web3j.ethGasPrice().send().getGasPrice();
// ๊ฐ์ค ํ๋ ์ค์
BigInteger gasLimit = BigInteger.valueOf(21000); // ๊ธฐ๋ณธ ์ ์ก์ 21000
// ์ ์กํ ๊ธ์ก (0.01 ETH = 10^16 Wei)
BigInteger value = Convert.toWei("0.01", Convert.Unit.ETHER).toBigInteger();
// ๋ฐ๋ ์ฃผ์
String toAddress = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb";
// Raw ํธ๋์ญ์
์์ฑ
RawTransaction rawTransaction = RawTransaction.createEtherTransaction(
nonce,
gasPrice,
gasLimit,
toAddress,
value
);
// ํธ๋์ญ์
์๋ช
byte[] signedMessage = TransactionEncoder.signMessage(
rawTransaction,
credentials
);
String hexValue = Numeric.toHexString(signedMessage);
// ํธ๋์ญ์
์ ์ก
EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).send();
String transactionHash = ethSendTransaction.getTransactionHash();
System.out.println("โ
ํธ๋์ญ์
์ ์ก ์๋ฃ!");
System.out.println("๐ ํด์: " + transactionHash);
} catch (Exception e) {
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
}
์ด ๋ฐฉ์์ ๋ ๋ณต์กํ์ง๋ง, ํธ๋์ญ์ ์ ๋ชจ๋ ํ๋ผ๋ฏธํฐ๋ฅผ ์ง์ ์ ์ดํ ์ ์์ด. ํนํ ๊ฐ์ค ์ต์ ํ๊ฐ ์ค์ํ ์ํฉ์์ ์ ์ฉํ์ง! โก
๐ ์ค๋งํธ ์ปจํธ๋ํธ ์์ฑํ๊ธฐ
์ด์ ๋ธ๋ก์ฒด์ธ์ ์ง์ง ๋งค๋ ฅ, ์ค๋งํธ ์ปจํธ๋ํธ๋ฅผ ๋ง๋ค์ด๋ณด์! ์ค๋งํธ ์ปจํธ๋ํธ๋ Solidity๋ผ๋ ์ธ์ด๋ก ์์ฑํด. JavaScript์ ๋น์ทํด์ ๋ฐฐ์ฐ๊ธฐ ์ด๋ ต์ง ์์! ๐
๊ฐ๋จํ ์ค๋งํธ ์ปจํธ๋ํธ ์์
ํฌํ ์์คํ ์ ๋ง๋ค์ด๋ณผ๊น? ๊ฐ๋จํ์ง๋ง ๋ธ๋ก์ฒด์ธ์ ํน์ฑ์ ์ ๋ณด์ฌ์ฃผ๋ ์์ ์ผ:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleVoting {
// ํฌํ ํญ๋ชฉ ๊ตฌ์กฐ์ฒด
struct Proposal {
string name;
uint voteCount;
}
// ํฌํ์ ์ฃผ์ => ํฌํ ์ฌ๋ถ
mapping(address => bool) public hasVoted;
// ํฌํ ํญ๋ชฉ ๋ฐฐ์ด
Proposal[] public proposals;
// ์ปจํธ๋ํธ ์์ ์
address public owner;
// ์์ฑ์
constructor(string[] memory proposalNames) {
owner = msg.sender;
// ํฌํ ํญ๋ชฉ ์ด๊ธฐํ
for (uint i = 0; i < proposalNames.length; i++) {
proposals.push(Proposal({
name: proposalNames[i],
voteCount: 0
}));
}
}
// ํฌํํ๊ธฐ
function vote(uint proposalIndex) public {
require(!hasVoted[msg.sender], "Already voted!");
require(proposalIndex < proposals.length, "Invalid proposal!");
hasVoted[msg.sender] = true;
proposals[proposalIndex].voteCount++;
}
// ์น๋ฆฌํ ์ ์ ๊ฐ์ ธ์ค๊ธฐ
function getWinner() public view returns (string memory winnerName) {
uint winningVoteCount = 0;
uint winningProposal = 0;
for (uint i = 0; i < proposals.length; i++) {
if (proposals[i].voteCount > winningVoteCount) {
winningVoteCount = proposals[i].voteCount;
winningProposal = i;
}
}
winnerName = proposals[winningProposal].name;
}
// ์ ์ ๊ฐ์ ๊ฐ์ ธ์ค๊ธฐ
function getProposalCount() public view returns (uint) {
return proposals.length;
}
}
Solidity ๊ธฐ์ด ๋ฌธ๋ฒ
์ ์ฝ๋๋ฅผ ์ดํดํ๊ธฐ ์ํด Solidity์ ํต์ฌ ๊ฐ๋ ์ ์ง์ด๋ณด์:
^0.8.0์ 0.8.0 ์ด์ 0.9.0 ๋ฏธ๋ง์ ์๋ฏธํด.2. contract - ์๋ฐ์ class์ ๋น์ทํด. ์ํ ๋ณ์์ ํจ์๋ฅผ ํฌํจํด.
3. struct - ์ฌ์ฉ์ ์ ์ ํ์ . ์ฌ๋ฌ ๋ณ์๋ฅผ ๋ฌถ์ด์ ๊ด๋ฆฌํ ์ ์์ด.
4. mapping - ํด์๋งต๊ณผ ๊ฐ์. key-value ์ ์ฅ์์ผ.
5. public/private - ์ ๊ทผ ์ ์ด์. public์ ์ธ๋ถ์์ ์ ๊ทผ ๊ฐ๋ฅํด.
6. view/pure - view๋ ์ํ๋ฅผ ์ฝ๊ธฐ๋ง ํ๊ณ , pure๋ ์ํ๋ฅผ ์ฝ์ง๋ ์ฐ์ง๋ ์์. ๊ฐ์ค๋น๊ฐ ์ ๋ค์ด!
7. msg.sender - ํจ์๋ฅผ ํธ์ถํ ์ฃผ์. ์๋ฐ์ this์ ๋น์ทํ ๊ฐ๋ ์ด์ผ.
์ปจํธ๋ํธ ์ปดํ์ผํ๊ธฐ
Solidity ์ฝ๋๋ฅผ ์์ฑํ์ผ๋ฉด ์ปดํ์ผํด์ผ ํด. ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์์ง๋ง, Remix IDE๋ฅผ ์ฌ์ฉํ๋ ๊ฒ ๊ฐ์ฅ ์ฌ์:
2. ์ ํ์ผ ์์ฑ (SimpleVoting.sol)
3. ์ ์ฝ๋ ๋ถ์ฌ๋ฃ๊ธฐ
4. ์ผ์ชฝ ๋ฉ๋ด์์ "Solidity Compiler" ํด๋ฆญ
5. "Compile SimpleVoting.sol" ๋ฒํผ ํด๋ฆญ
6. ABI์ Bytecode ๋ณต์ฌ (๋์ค์ Web3j์์ ์ฌ์ฉ)
์ปดํ์ผํ๋ฉด ๋ ๊ฐ์ง ์ค์ํ ๊ฒฐ๊ณผ๋ฌผ์ด ๋์:
์ปจํธ๋ํธ์ ์ธํฐํ์ด์ค ์ ์์ผ. ์ด๋ค ํจ์๊ฐ ์๊ณ , ํ๋ผ๋ฏธํฐ๋ ๋ญ์ง ๋ฑ์ JSON ํ์์ผ๋ก ์ค๋ช ํด. ์๋ฐ์ ์ธํฐํ์ด์ค์ ๋น์ทํด!
2. Bytecode
์ค์ ๋ก ๋ธ๋ก์ฒด์ธ์ ๋ฐฐํฌ๋๋ ๋ฐ์ด๋๋ฆฌ ์ฝ๋์ผ. EVM(Ethereum Virtual Machine)์ด ์คํํ ์ ์๋ ํํ์ง.
๐ข ์ค๋งํธ ์ปจํธ๋ํธ ๋ฐฐํฌํ๊ธฐ
์ด์ ์ฐ๋ฆฌ๊ฐ ๋ง๋ ํฌํ ์ปจํธ๋ํธ๋ฅผ ๋ธ๋ก์ฒด์ธ์ ๋ฐฐํฌํด๋ณด์! Web3j๋ฅผ ์ฌ์ฉํ๋ฉด ์๋ฐ ์ฝ๋๋ก ๋ฐฐํฌํ ์ ์์ด. ๐
Web3j๋ก ์ปจํธ๋ํธ ๋ฐฐํฌ
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.tx.gas.DefaultGasProvider;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
public class ContractDeployer {
public static void main(String[] args) {
String infuraUrl = "https://sepolia.infura.io/v3/YOUR_PROJECT_ID";
Web3j web3j = Web3j.build(new HttpService(infuraUrl));
try {
// ์ง๊ฐ ๋ก๋
Credentials credentials = WalletUtils.loadCredentials(
"password",
"/path/to/wallet"
);
// ํฌํ ํญ๋ชฉ ์ค๋น
List<String> proposalNames = Arrays.asList(
"Proposal A",
"Proposal B",
"Proposal C"
);
System.out.println("๐ ์ปจํธ๋ํธ ๋ฐฐํฌ ์ค...");
// ์ปจํธ๋ํธ ๋ฐฐํฌ (Web3j๊ฐ ์๋ ์์ฑํ ๋ํผ ํด๋์ค ์ฌ์ฉ)
SimpleVoting contract = SimpleVoting.deploy(
web3j,
credentials,
new DefaultGasProvider(),
proposalNames
).send();
String contractAddress = contract.getContractAddress();
System.out.println("โ
๋ฐฐํฌ ์๋ฃ!");
System.out.println("๐ ์ปจํธ๋ํธ ์ฃผ์: " + contractAddress);
// ๋ฐฐํฌ๋ ์ปจํธ๋ํธ์ ์ํธ์์ฉ
System.out.println("\n๐ ํฌํ ํญ๋ชฉ ๊ฐ์: " + contract.getProposalCount().send());
} catch (Exception e) {
System.err.println("โ ๋ฐฐํฌ ์คํจ: " + e.getMessage());
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
}
Web3j ๋ํผ ํด๋์ค ์์ฑ
์ ์ฝ๋์์ SimpleVoting ํด๋์ค๋ ์ด๋์ ์จ ๊ฑธ๊น? Web3j๋ Solidity ์ปจํธ๋ํธ๋ฅผ ์๋ฐ ํด๋์ค๋ก ๋ณํํด์ฃผ๋ ๋๊ตฌ๋ฅผ ์ ๊ณตํด! ๐ ๏ธ
Web3j CLI๋ฅผ ์ฌ์ฉํด์ ๋ํผ ํด๋์ค๋ฅผ ์์ฑํ ์ ์์ด:
# Web3j CLI ์ค์น (macOS/Linux)
curl -L get.web3j.io | sh
# ๋ํผ ํด๋์ค ์์ฑ
web3j generate solidity \
-b SimpleVoting.bin \
-a SimpleVoting.abi \
-o /path/to/output \
-p com.example.contracts
์ด ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด SimpleVoting.java ํ์ผ์ด ์์ฑ๋ผ. ์ด ํด๋์ค๋ฅผ ์ฌ์ฉํ๋ฉด ํ์
์์ ํ๊ฒ ์ปจํธ๋ํธ์ ์ํธ์์ฉํ ์ ์์ด! ๐
์๋์ผ๋ก ์ปจํธ๋ํธ ๋ฐฐํฌํ๊ธฐ
๋ํผ ํด๋์ค ์์ด๋ ๋ฐฐํฌํ ์ ์์ด. ์ข ๋ ๋ณต์กํ์ง๋ง ๋ด๋ถ ๋์์ ์ดํดํ๋ ๋ฐ ๋์์ด ๋ผ:
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.datatypes.Utf8String;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.tx.RawTransactionManager;
import org.web3j.tx.TransactionManager;
public class ManualContractDeployer {
public static void main(String[] args) {
Web3j web3j = Web3j.build(new HttpService("https://sepolia.infura.io/v3/YOUR_PROJECT_ID"));
try {
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/wallet");
// ์ปจํธ๋ํธ ๋ฐ์ดํธ์ฝ๋ (Remix์์ ๋ณต์ฌ)
String bytecode = "0x608060405234801561001057600080fd5b50..."; // ์ค์ ๋ฐ์ดํธ์ฝ๋
// ์์ฑ์ ํ๋ผ๋ฏธํฐ ์ธ์ฝ๋ฉ
List<Utf8String> proposalNames = Arrays.asList(
new Utf8String("Proposal A"),
new Utf8String("Proposal B"),
new Utf8String("Proposal C")
);
String encodedConstructor = FunctionEncoder.encodeConstructor(
Arrays.asList(new DynamicArray<>(Utf8String.class, proposalNames))
);
// ๋ฐ์ดํธ์ฝ๋ + ์์ฑ์ ํ๋ผ๋ฏธํฐ
String data = bytecode + encodedConstructor.substring(2);
// ํธ๋์ญ์
๋งค๋์ ์์ฑ
TransactionManager txManager = new RawTransactionManager(web3j, credentials);
// ์ปจํธ๋ํธ ๋ฐฐํฌ ํธ๋์ญ์
์ ์ก
EthSendTransaction transactionResponse = txManager.sendTransaction(
DefaultGasProvider.GAS_PRICE,
DefaultGasProvider.GAS_LIMIT,
null, // to address (null for contract creation)
data,
BigInteger.ZERO // value
);
String txHash = transactionResponse.getTransactionHash();
System.out.println("๐ ๋ฐฐํฌ ํธ๋์ญ์
: " + txHash);
// ํธ๋์ญ์
์์์ฆ ๋๊ธฐ
TransactionReceipt receipt = waitForReceipt(web3j, txHash);
String contractAddress = receipt.getContractAddress();
System.out.println("โ
์ปจํธ๋ํธ ๋ฐฐํฌ ์๋ฃ!");
System.out.println("๐ ์ฃผ์: " + contractAddress);
} catch (Exception e) {
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
// ํธ๋์ญ์
์์์ฆ ๋๊ธฐ ํฌํผ ํจ์
private static TransactionReceipt waitForReceipt(Web3j web3j, String txHash)
throws Exception {
Optional<TransactionReceipt> receipt = Optional.empty();
for (int i = 0; i < 40; i++) {
receipt = web3j.ethGetTransactionReceipt(txHash).send().getTransactionReceipt();
if (receipt.isPresent()) {
return receipt.get();
}
Thread.sleep(3000); // 3์ด ๋๊ธฐ
}
throw new Exception("Transaction receipt not received after 2 minutes");
}
}
์ปจํธ๋ํธ ๋ฐฐํฌ๋ ์ผ๋ฐ ํธ๋์ญ์
๊ณผ ๋น์ทํ์ง๋ง, to ์ฃผ์๊ฐ null์ด๊ณ data ํ๋์ ๋ฐ์ดํธ์ฝ๋๊ฐ ๋ค์ด๊ฐ๋ค๋ ๊ฒ ๋ค๋ฅธ ์ ์ด์ผ! ๐ฏ
๐ ์ค๋งํธ ์ปจํธ๋ํธ์ ์ํธ์์ฉํ๊ธฐ
์ปจํธ๋ํธ๋ฅผ ๋ฐฐํฌํ์ผ๋ฉด ์ด์ ์ฌ์ฉํด์ผ์ง! ํฌํํ๊ณ , ๊ฒฐ๊ณผ๋ฅผ ์กฐํํ๋ ๋ฑ์ ์์ ์ ํด๋ณด์. ๐
์ปจํธ๋ํธ ํจ์ ํธ์ถํ๊ธฐ
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import java.math.BigInteger;
public class ContractInteraction {
public static void main(String[] args) {
String infuraUrl = "https://sepolia.infura.io/v3/YOUR_PROJECT_ID";
Web3j web3j = Web3j.build(new HttpService(infuraUrl));
try {
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/wallet");
// ๋ฐฐํฌ๋ ์ปจํธ๋ํธ ์ฃผ์
String contractAddress = "0x..."; // ๋ฐฐํฌ ์ ๋ฐ์ ์ฃผ์
// ์ปจํธ๋ํธ ์ธ์คํด์ค ๋ก๋
SimpleVoting contract = SimpleVoting.load(
contractAddress,
web3j,
credentials,
new DefaultGasProvider()
);
System.out.println("๐ ์ปจํธ๋ํธ์ ์ํธ์์ฉ ์์!");
// 1. ํฌํ ํญ๋ชฉ ๊ฐ์ ์กฐํ (view ํจ์ - ๊ฐ์ค๋น ๋ฌด๋ฃ!)
BigInteger proposalCount = contract.getProposalCount().send();
System.out.println("ํฌํ ํญ๋ชฉ ๊ฐ์: " + proposalCount);
// 2. ๊ฐ ํฌํ ํญ๋ชฉ ์ ๋ณด ์กฐํ
for (int i = 0; i < proposalCount.intValue(); i++) {
// proposals ๋งคํ ์กฐํ
// Tuple2<String, BigInteger> proposal = contract.proposals(BigInteger.valueOf(i)).send();
// System.out.println("ํญ๋ชฉ " + i + ": " + proposal.component1() +
// " (๋ํ์: " + proposal.component2() + ")");
}
// 3. ํฌํํ๊ธฐ (์ํ ๋ณ๊ฒฝ - ๊ฐ์ค๋น ํ์!)
System.out.println("\n๐ณ๏ธ ํฌํ ์ค...");
TransactionReceipt voteReceipt = contract.vote(BigInteger.ZERO).send();
System.out.println("โ
ํฌํ ์๋ฃ! ํธ๋์ญ์
: " + voteReceipt.getTransactionHash());
// 4. ์น์ ์กฐํ
String winner = contract.getWinner().send();
System.out.println("\n๐ ํ์ฌ ์น์: " + winner);
// 5. ํฌํ ์ฌ๋ถ ํ์ธ
boolean hasVoted = contract.hasVoted(credentials.getAddress()).send();
System.out.println("๋ด๊ฐ ํฌํํ๋? " + (hasVoted ? "์" : "์๋์ค"));
} catch (Exception e) {
System.err.println("โ ์ค๋ฅ: " + e.getMessage());
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
}
View vs Transaction ํจ์
์ค๋งํธ ์ปจํธ๋ํธ ํจ์๋ ํฌ๊ฒ ๋ ์ข ๋ฅ๋ก ๋๋์ด:
- ๊ฐ์ค๋น๊ฐ ๋ค์ง ์์ (๋ฌด๋ฃ!)
- ์ฆ์ ๊ฒฐ๊ณผ ๋ฐํ
- ์:
getWinner(), getProposalCount()โ๏ธ Transaction ํจ์
- ๋ธ๋ก์ฒด์ธ ์ํ๋ฅผ ๋ณ๊ฒฝํจ
- ๊ฐ์ค๋น ํ์
- ํธ๋์ญ์ ์ด ๋ธ๋ก์ ํฌํจ๋ ๋๊น์ง ๋๊ธฐ
- ์:
vote()
์ด๋ฒคํธ ๋ฆฌ์ค๋
์ค๋งํธ ์ปจํธ๋ํธ๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํฌ ์ ์์ด. ์ด๋ฒคํธ๋ฅผ ๋ฆฌ์ค๋ํ๋ฉด ์ค์๊ฐ์ผ๋ก ๋ธ๋ก์ฒด์ธ ์ํ ๋ณํ๋ฅผ ๊ฐ์งํ ์ ์์ง! ๐ง
๋จผ์ Solidity ์ปจํธ๋ํธ์ ์ด๋ฒคํธ๋ฅผ ์ถ๊ฐํด๋ณด์:
contract SimpleVoting {
// ... ๊ธฐ์กด ์ฝ๋ ...
// ์ด๋ฒคํธ ์ ์
event VoteCast(address indexed voter, uint proposalIndex);
event WinnerDeclared(string winnerName, uint voteCount);
function vote(uint proposalIndex) public {
require(!hasVoted[msg.sender], "Already voted!");
require(proposalIndex < proposals.length, "Invalid proposal!");
hasVoted[msg.sender] = true;
proposals[proposalIndex].voteCount++;
// ์ด๋ฒคํธ ๋ฐ์
emit VoteCast(msg.sender, proposalIndex);
}
}
์ด์ ์๋ฐ์์ ์ด๋ฒคํธ๋ฅผ ๋ฆฌ์ค๋ํด๋ณด์:
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.EthFilter;
import io.reactivex.disposables.Disposable;
public class EventListener {
public static void main(String[] args) {
Web3j web3j = Web3j.build(new HttpService("https://sepolia.infura.io/v3/YOUR_PROJECT_ID"));
try {
Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/wallet");
String contractAddress = "0x...";
SimpleVoting contract = SimpleVoting.load(
contractAddress,
web3j,
credentials,
new DefaultGasProvider()
);
System.out.println("๐ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์์...");
// VoteCast ์ด๋ฒคํธ ๋ฆฌ์ค๋
Disposable subscription = contract.voteCastEventFlowable(
DefaultBlockParameterName.LATEST,
DefaultBlockParameterName.LATEST
).subscribe(event -> {
System.out.println("\n๐ณ๏ธ ์๋ก์ด ํฌํ ๊ฐ์ง!");
System.out.println("ํฌํ์: " + event.voter);
System.out.println("์ ํํ ํญ๋ชฉ: " + event.proposalIndex);
});
// ํ๋ก๊ทธ๋จ์ด ์ข
๋ฃ๋์ง ์๋๋ก ๋๊ธฐ
System.out.println("์ด๋ฒคํธ๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ์ค... (Ctrl+C๋ก ์ข
๋ฃ)");
Thread.sleep(Long.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
} finally {
web3j.shutdown();
}
}
}
์ด๋ฒคํธ ๋ฆฌ์ค๋์ ์ค์๊ฐ DApp์ ๋ง๋ค ๋ ์ ๋ง ์ ์ฉํด! ์ฌ์ฉ์๊ฐ ํฌํํ๋ฉด ์ฆ์ UI๋ฅผ ์ ๋ฐ์ดํธํ ์ ์๊ฑฐ๋ . ๐
๐จ ์ค์ DApp ํ๋ก์ ํธ: NFT ๋ง์ผํ๋ ์ด์ค
์ด๋ก ์ ์ถฉ๋ถํ ๋ฐฐ์ ์ผ๋, ์ด์ ์ค์ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด๋ณด์! ๊ฐ๋จํ NFT ๋ง์ผํ๋ ์ด์ค๋ฅผ ๊ตฌ์ถํด๋ณผ ๊ฑฐ์ผ. NFT๋ฅผ ๋ฐํํ๊ณ , ํ๋งคํ๊ณ , ๊ตฌ๋งคํ๋ ๊ธฐ๋ฅ์ ๊ตฌํํด๋ณด์! ๐ผ๏ธ
ERC-721 NFT ์ปจํธ๋ํธ
NFT๋ ERC-721 ํ์ค์ ๋ฐ๋ผ. OpenZeppelin ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ฉด ์ฝ๊ฒ ๋ง๋ค ์ ์์ด:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract SimpleNFT is ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
// NFT ๊ฐ๊ฒฉ ๋งคํ
mapping(uint256 => uint256) public tokenPrices;
// ํ๋งค ์ค์ธ NFT ๋งคํ
mapping(uint256 => bool) public isForSale;
// ์ด๋ฒคํธ
event NFTMinted(uint256 tokenId, address owner, string tokenURI);
event NFTListed(uint256 tokenId, uint256 price);
event NFTSold(uint256 tokenId, address from, address to, uint256 price);
constructor() ERC721("SimpleNFT", "SNFT") {}
// NFT ๋ฐํ
function mintNFT(address recipient, string memory tokenURI)
public onlyOwner returns (uint256) {
_tokenIds.increment();
uint256 newTokenId = _tokenIds.current();
_mint(recipient, newTokenId);
_setTokenURI(newTokenId, tokenURI);
emit NFTMinted(newTokenId, recipient, tokenURI);
return newTokenId;
}
// NFT ํ๋งค ๋ฑ๋ก
function listNFT(uint256 tokenId, uint256 price) public {
require(ownerOf(tokenId) == msg.sender, "Not the owner");
require(price > 0, "Price must be greater than 0");
tokenPrices[tokenId] = price;
isForSale[tokenId] = true;
// ๋ง์ผํ๋ ์ด์ค์ ํ๋งค ๊ถํ ๋ถ์ฌ
approve(address(this), tokenId);
emit NFTListed(tokenId, price);
}
// NFT ๊ตฌ๋งค
function buyNFT(uint256 tokenId) public payable {
require(isForSale[tokenId], "NFT not for sale");
require(msg.value >= tokenPrices[tokenId], "Insufficient payment");
address seller = ownerOf(tokenId);
uint256 price = tokenPrices[tokenId];
// NFT ์ ์ก
_transfer(seller, msg.sender, tokenId);
// ํ๋งค์์๊ฒ ๋๊ธ ์ ์ก
payable(seller).transfer(price);
// ์ด๊ณผ ๊ธ์ก ํ๋ถ
if (msg.value > price) {
payable(msg.sender).transfer(msg.value - price);
}
// ํ๋งค ์ํ ์
๋ฐ์ดํธ
isForSale[tokenId] = false;
tokenPrices[tokenId] = 0;
emit NFTSold(tokenId, seller, msg.sender, price);
}
// ํ๋งค ์ทจ์
function cancelListing(uint256 tokenId) public {
require(ownerOf(tokenId) == msg.sender, "Not the owner");
require(isForSale[tokenId], "NFT not listed");
isForSale[tokenId] = false;
tokenPrices[tokenId] = 0;
}
// ์ ์ฒด NFT ๊ฐ์
function totalSupply() public view returns (uint256) {
return _tokenIds.current();
}
}
์๋ฐ ๋ฐฑ์๋ ๊ตฌํ
์ด์ Spring Boot๋ก NFT ๋ง์ผํ๋ ์ด์ค ๋ฐฑ์๋๋ฅผ ๋ง๋ค์ด๋ณด์! ๐
import org.springframework.stereotype.Service;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.tx.gas.DefaultGasProvider;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@Service
public class NFTMarketplaceService {
private final Web3j web3j;
private final SimpleNFT nftContract;
private final Credentials credentials;
public NFTMarketplaceService() {
// Web3j ์ด๊ธฐํ
this.web3j = Web3j.build(new HttpService(
"https://sepolia.infura.io/v3/YOUR_PROJECT_ID"
));
// ์ง๊ฐ ๋ก๋
try {
this.credentials = WalletUtils.loadCredentials(
"password",
"/path/to/wallet"
);
} catch (Exception e) {
throw new RuntimeException("Failed to load credentials", e);
}
// ์ปจํธ๋ํธ ๋ก๋
String contractAddress = "0x..."; // ๋ฐฐํฌ๋ ์ปจํธ๋ํธ ์ฃผ์
this.nftContract = SimpleNFT.load(
contractAddress,
web3j,
credentials,
new DefaultGasProvider()
);
}
// NFT ๋ฐํ
public String mintNFT(String recipientAddress, String tokenURI) {
try {
TransactionReceipt receipt = nftContract.mintNFT(
recipientAddress,
tokenURI
).send();
// ์ด๋ฒคํธ์์ ํ ํฐ ID ์ถ์ถ
List<SimpleNFT.NFTMintedEventResponse> events =
nftContract.getNFTMintedEvents(receipt);
if (!events.isEmpty()) {
BigInteger tokenId = events.get(0).tokenId;
return tokenId.toString();
}
return null;
} catch (Exception e) {
throw new RuntimeException("Failed to mint NFT", e);
}
}
// NFT ํ๋งค ๋ฑ๋ก
public void listNFT(String tokenId, String priceInEth) {
try {
BigInteger tokenIdBig = new BigInteger(tokenId);
BigInteger priceInWei = Convert.toWei(priceInEth, Convert.Unit.ETHER).toBigInteger();
nftContract.listNFT(tokenIdBig, priceInWei).send();
} catch (Exception e) {
throw new RuntimeException("Failed to list NFT", e);
}
}
// NFT ๊ตฌ๋งค
public void buyNFT(String tokenId, String buyerAddress) {
try {
BigInteger tokenIdBig = new BigInteger(tokenId);
// NFT ๊ฐ๊ฒฉ ์กฐํ
BigInteger price = nftContract.tokenPrices(tokenIdBig).send();
// ๊ตฌ๋งค์ ์ง๊ฐ์ผ๋ก ํธ๋์ญ์
์ ์ก
// (์ค์ ๋ก๋ ํ๋ก ํธ์๋์์ MetaMask ๋ฑ์ผ๋ก ์ฒ๋ฆฌ)
nftContract.buyNFT(tokenIdBig).send();
} catch (Exception e) {
throw new RuntimeException("Failed to buy NFT", e);
}
}
// ํ๋งค ์ค์ธ NFT ๋ชฉ๋ก ์กฐํ
public List<NFTInfo> getListedNFTs() {
try {
List<NFTInfo> nfts = new ArrayList<>();
BigInteger totalSupply = nftContract.totalSupply().send();
for (int i = 1; i <= totalSupply.intValue(); i++) {
BigInteger tokenId = BigInteger.valueOf(i);
boolean isForSale = nftContract.isForSale(tokenId).send();
if (isForSale) {
String owner = nftContract.ownerOf(tokenId).send();
String tokenURI = nftContract.tokenURI(tokenId).send();
BigInteger price = nftContract.tokenPrices(tokenId).send();
NFTInfo nft = new NFTInfo(
tokenId.toString(),
owner,
tokenURI,
Convert.fromWei(price.toString(), Convert.Unit.ETHER).toString()
);
nfts.add(nft);
}
}
return nfts;
} catch (Exception e) {
throw new RuntimeException("Failed to get listed NFTs", e);
}
}
// NFT ์ ๋ณด DTO
public static class NFTInfo {
private String tokenId;
private String owner;
private String tokenURI;
private String price;
public NFTInfo(String tokenId, String owner, String tokenURI, String price) {
this.tokenId = tokenId;
this.owner = owner;
this.tokenURI = tokenURI;
this.price = price;
}
// Getters and Setters
// ...
}
}
REST API ์ปจํธ๋กค๋ฌ
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@RestController
@RequestMapping("/api/nft")
public class NFTController {
@Autowired
private NFTMarketplaceService nftService;
// NFT ๋ฐํ
@PostMapping("/mint")
public ResponseEntity<String> mintNFT(@RequestBody MintRequest request) {
try {
String tokenId = nftService.mintNFT(
request.getRecipient(),
request.getTokenURI()
);
return ResponseEntity.ok(tokenId);
} catch (Exception e) {
return ResponseEntity.status(500).body("Error: " + e.getMessage());
}
}
// NFT ํ๋งค ๋ฑ๋ก
@PostMapping("/list")
public ResponseEntity<String> listNFT(@RequestBody ListRequest request) {
try {
nftService.listNFT(request.getTokenId(), request.getPrice());
return ResponseEntity.ok("NFT listed successfully");
} catch (Exception e) {
return ResponseEntity.status(500).body("Error: " + e.getMessage());
}
}
// ํ๋งค ์ค์ธ NFT ๋ชฉ๋ก
@GetMapping("/listed")
public ResponseEntity<List<NFTMarketplaceService.NFTInfo>> getListedNFTs() {
try {
List<NFTMarketplaceService.NFTInfo> nfts = nftService.getListedNFTs();
return ResponseEntity.ok(nfts);
} catch (Exception e) {
return ResponseEntity.status(500).build();
}
}
// Request DTOs
static class MintRequest {
private String recipient;
private String tokenURI;
// Getters and Setters
}
static class ListRequest {
private String tokenId;
private String price;
// Getters and Setters
}
}
์ด์ ํ๋ก ํธ์๋์์ ์ด API๋ฅผ ํธ์ถํ๋ฉด NFT ๋ง์ผํ๋ ์ด์ค๊ฐ ์์ฑ๋ผ! ๋ฌผ๋ก ์ค์ ํ๋ก๋์ ์์๋ ๋ณด์, ์๋ฌ ์ฒ๋ฆฌ, ํธ๋์ญ์ ๋ชจ๋ํฐ๋ง ๋ฑ ๋ ๋ง์ ๊ฒ๋ค์ ๊ณ ๋ คํด์ผ ํ์ง๋ง, ๊ธฐ๋ณธ ๊ตฌ์กฐ๋ ์ด๋ ๊ฒ ๋ง๋ค ์ ์์ด. ๐จ
๐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์์ ๋ณด์์ ์ ๋ง์ ๋ง ์ค์ํด! ํ๋ฒ ๋ฐฐํฌ๋ ์ปจํธ๋ํธ๋ ์์ ํ ์ ์๊ณ , ํดํน๋นํ๋ฉด ์์ฐ์ ์์ ์ ์๊ฑฐ๋ . ๐ฑ
์ฃผ์ ๋ณด์ ์ํ
๋ฐฉ์ด ๋ฐฉ๋ฒ:
- Checks-Effects-Interactions ํจํด ์ฌ์ฉ
- ReentrancyGuard ์ฌ์ฉ
- ์ํ ๋ณ๊ฒฝ์ ์ธ๋ถ ํธ์ถ ์ ์ ์๋ฃ
// ์์ ํ์ง ์์ ์ฝ๋
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
// ์ํ! ์ธ๋ถ ํธ์ถ ์ ์ ์ํ ๋ณ๊ฒฝ ์ ํจ
(bool success, ) = msg.sender.call{value: amount}("");
require(success);
balances[msg.sender] -= amount;
}
// ์์ ํ ์ฝ๋
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
// ๋จผ์ ์ํ ๋ณ๊ฒฝ
balances[msg.sender] -= amount;
// ๊ทธ ๋ค์ ์ธ๋ถ ํธ์ถ
(bool success, ) = msg.sender.call{value: amount}("");
require(success);
}
๊ฐ์ธํค ๊ด๋ฆฌ
๊ฐ์ธํค๋ฅผ ์ฝ๋์ ํ๋์ฝ๋ฉํ์ง ๋ง๊ณ ํ๊ฒฝ ๋ณ์๋ก ๊ด๋ฆฌํด.
2. KMS ์ฌ์ฉ
AWS KMS, Azure Key Vault ๊ฐ์ ํค ๊ด๋ฆฌ ์๋น์ค๋ฅผ ํ์ฉํด.
3. ํ๋์จ์ด ์ง๊ฐ
๋๋์ ์์ฐ์ Ledger, Trezor ๊ฐ์ ํ๋์จ์ด ์ง๊ฐ์ ๋ณด๊ดํด.
4. ๋ฉํฐ์๊ทธ ์ง๊ฐ
์ค์ํ ํธ๋์ญ์ ์ ์ฌ๋ฌ ์ฌ๋์ ์น์ธ์ด ํ์ํ๋๋ก ์ค์ ํด.
5. ํ ์คํธ๋ท ์ฐ์
ํญ์ ํ ์คํธ๋ท์์ ์ถฉ๋ถํ ํ ์คํธํ ํ ๋ฉ์ธ๋ท์ ๋ฐฐํฌํด.
์ค๋งํธ ์ปจํธ๋ํธ ๋ณด์ ์ฒดํฌ๋ฆฌ์คํธ
| ํญ๋ชฉ | ์ค๋ช |
|---|---|
| ์ ๊ทผ ์ ์ด | onlyOwner, ์ญํ ๊ธฐ๋ฐ ์ ๊ทผ ์ ์ด ๊ตฌํ |
| ์ ์ ์ค๋ฒํ๋ก์ฐ | Solidity 0.8.0+ ์ฌ์ฉ (์๋ ์ฒดํฌ) |
| ๊ฐ์ค ์ต์ ํ | ๋ฌดํ ๋ฃจํ ๋ฐฉ์ง, ๊ฐ์ค ํ๋ ๊ณ ๋ ค |
| ์ธ๋ถ ํธ์ถ | ์ ๋ขฐํ ์ ์๋ ์ปจํธ๋ํธ ํธ์ถ ์ฃผ์ |
| ํ์์คํฌํ ์์กด | block.timestamp๋ ์กฐ์ ๊ฐ๋ฅ, ์ฃผ์ํด์ ์ฌ์ฉ |
| ๊ฐ์ฌ | ์ ๋ฌธ ๋ณด์ ๊ฐ์ฌ ์ ์ฒด์ ์๋ขฐ |
โก ์ฑ๋ฅ ์ต์ ํ
๋ธ๋ก์ฒด์ธ์ ๋๋ฆฌ๊ณ ๋น์ธ! ๊ทธ๋์ ์ต์ ํ๊ฐ ์ ๋ง ์ค์ํด. ๊ฐ์ค๋น๋ฅผ ์ค์ด๊ณ ์ฑ๋ฅ์ ๋์ด๋ ๋ฐฉ๋ฒ์ ์์๋ณด์. ๐
๊ฐ์ค ์ต์ ํ ๊ธฐ๋ฒ
๋ธ๋ก์ฒด์ธ ์คํ ๋ฆฌ์ง๋ ๋น์ธ! ๊ฐ๋ฅํ๋ฉด ๋ฉ๋ชจ๋ฆฌ๋ calldata๋ฅผ ์ฌ์ฉํด.
2. ๋ณ์ ํจํน
uint256 ๋์ uint8, uint16 ๋ฑ ์์ ํ์ ์ ์ฌ์ฉํ๋ฉด ์คํ ๋ฆฌ์ง๋ฅผ ์ ์ฝํ ์ ์์ด.
3. ๋ฐฐ์ด ๋์ ๋งคํ
๋๋ถ๋ถ์ ๊ฒฝ์ฐ ๋ฐฐ์ด๋ณด๋ค ๋งคํ์ด ๊ฐ์ค๋น๊ฐ ์ ๊ฒ ๋ค์ด.
4. ์ด๋ฒคํธ ํ์ฉ
๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๋์ ์ด๋ฒคํธ๋ก ๋ก๊ทธ๋ฅผ ๋จ๊ธฐ๋ฉด ํจ์ฌ ์ ๋ ดํด.
5. ๋ฐฐ์น ์ฒ๋ฆฌ
์ฌ๋ฌ ํธ๋์ญ์ ์ ํ๋๋ก ๋ฌถ์ด์ ์ฒ๋ฆฌํ๋ฉด ๊ฐ์ค๋น๋ฅผ ์ ์ฝํ ์ ์์ด.
์คํ์ฒด์ธ ์ฒ๋ฆฌ
๋ชจ๋ ๊ฑธ ๋ธ๋ก์ฒด์ธ์์ ์ฒ๋ฆฌํ ํ์๋ ์์ด! ์คํ์ฒด์ธ์์ ์ฒ๋ฆฌํ๊ณ ๊ฒฐ๊ณผ๋ง ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋กํ๋ ๋ฐฉ์๋ ์์ด:
// ์๋ฐ ๋ฐฑ์๋์์ ๋ณต์กํ ๊ณ์ฐ ์ํ
public class OffChainProcessor {
public String processComplexCalculation(List<Data> data) {
// ๋ณต์กํ ๊ณ์ฐ์ ์๋ฐ์์ ์ํ
String result = performHeavyComputation(data);
// ๊ฒฐ๊ณผ์ ํด์๋ง ๋ธ๋ก์ฒด์ธ์ ์ ์ฅ
String resultHash = calculateHash(result);
// ๋ธ๋ก์ฒด์ธ์ ํด์ ์ ์ฅ
storeHashOnChain(resultHash);
// ์ค์ ๋ฐ์ดํฐ๋ IPFS๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ
storeResultOffChain(result);
return resultHash;
}
private String calculateHash(String data) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(data.getBytes(StandardCharsets.UTF_8));
return Numeric.toHexString(hash);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
}
๋ ์ด์ด 2 ์๋ฃจ์
์ด๋๋ฆฌ์ ๋ฉ์ธ๋ท์ด ๋๋ฌด ๋น์ธ๋ค๋ฉด ๋ ์ด์ด 2 ์๋ฃจ์ ์ ๊ณ ๋ คํด๋ด:
Arbitrum - Optimistic Rollup ๊ธฐ๋ฐ. ์ด๋๋ฆฌ์๊ณผ ๋์ ํธํ์ฑ.
Optimism - ๋ ๋ค๋ฅธ Optimistic Rollup. Coinbase๊ฐ ์ฌ์ฉ ์ค.
zkSync - Zero-Knowledge Rollup. ๋ ๋น ๋ฅด๊ณ ์์ ํด.
Web3j๋ ์ด๋ฐ ๋ ์ด์ด 2 ๋คํธ์ํฌ๋ ์ง์ํด! ์๋ํฌ์ธํธ๋ง ๋ฐ๊ฟ์ฃผ๋ฉด ๋ผ:
// Polygon Mumbai ํ
์คํธ๋ท
String polygonUrl = "https://rpc-mumbai.maticvigil.com/";
Web3j web3j = Web3j.build(new HttpService(polygonUrl));
// Arbitrum Goerli ํ
์คํธ๋ท
String arbitrumUrl = "https://goerli-rollup.arbitrum.io/rpc";
Web3j web3j = Web3j.build(new HttpService(arbitrumUrl));
๐งช ํ ์คํธ ์ ๋ต
๋ธ๋ก์ฒด์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ํ ์คํธ๊ฐ ์ ๋ง ์ค์ํด! ํ๋ฒ ๋ฐฐํฌํ๋ฉด ์์ ์ด ์ด๋ ต๊ฑฐ๋ . ์ฒ ์ ํ ํ ์คํธ ์ ๋ต์ ์ธ์๋ณด์. ๐ฏ
๋ก์ปฌ ๋ธ๋ก์ฒด์ธ ํ๊ฒฝ
๊ฐ๋ฐํ ๋๋ง๋ค ํ ์คํธ๋ท์ ๋ฐฐํฌํ๋ฉด ์๊ฐ๋ ์ค๋ ๊ฑธ๋ฆฌ๊ณ ๋ถํธํด. ๋ก์ปฌ์์ ๋ธ๋ก์ฒด์ธ์ ์คํํ ์ ์์ด!
1. Ganache ์ค์น: https://trufflesuite.com/ganache/
2. Ganache ์คํ (๊ธฐ๋ณธ ํฌํธ: 7545)
3. 10๊ฐ์ ํ ์คํธ ๊ณ์ ๊ณผ 100 ETH์ฉ ์๋ ์์ฑ
4. ์ฆ์ ํธ๋์ญ์ ํ์ธ (๋ธ๋ก ์๊ฐ 0์ด!)
// Ganache์ ์ฐ๊ฒฐ
String ganacheUrl = "http://localhost:7545";
Web3j web3j = Web3j.build(new HttpService(ganacheUrl));
// Ganache๊ฐ ์ ๊ณตํ๋ ํ
์คํธ ๊ณ์ ์ฌ์ฉ
String privateKey = "0x..."; // Ganache์์ ์ ๊ณต
Credentials credentials = Credentials.create(privateKey);
JUnit ํ ์คํธ ์์ฑ
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import static org.junit.jupiter.api.Assertions.*;
public class NFTMarketplaceTest {
private Web3j web3j;
private SimpleNFT nftContract;
private Credentials owner;
private Credentials buyer;
@BeforeEach
public void setUp() throws Exception {
// Ganache ์ฐ๊ฒฐ
web3j = Web3j.build(new HttpService("http://localhost:7545"));
// ํ
์คํธ ๊ณ์ ์ค์
owner = Credentials.create("0x..."); // Ganache ๊ณ์ 1
buyer = Credentials.create("0x..."); // Ganache ๊ณ์ 2
// ์ปจํธ๋ํธ ๋ฐฐํฌ
nftContract = SimpleNFT.deploy(
web3j,
owner,
new DefaultGasProvider()
).send();
}
@Test
public void testMintNFT() throws Exception {
// Given
String tokenURI = "ipfs://QmTest123";
// When
TransactionReceipt receipt = nftContract.mintNFT(
owner.getAddress(),
tokenURI
).send();
// Then
List<SimpleNFT.NFTMintedEventResponse> events =
nftContract.getNFTMintedEvents(receipt);
assertFalse(events.isEmpty());
assertEquals(tokenURI, events.get(0).tokenURI);
// ํ ํฐ ์์ ์ ํ์ธ
BigInteger tokenId = events.get(0).tokenId;
String tokenOwner = nftContract.ownerOf(tokenId).send();
assertEquals(owner.getAddress(), tokenOwner);
}
@Test
public void testListAndBuyNFT() throws Exception {
// NFT ๋ฐํ
TransactionReceipt mintReceipt = nftContract.mintNFT(
owner.getAddress(),
"ipfs://QmTest456"
).send();
BigInteger tokenId = nftContract.getNFTMintedEvents(mintReceipt)
.get(0).tokenId;
// NFT ํ๋งค ๋ฑ๋ก
BigInteger price = Convert.toWei("1", Convert.Unit.ETHER).toBigInteger();
nftContract.listNFT(tokenId, price).send();
// ํ๋งค ์ํ ํ์ธ
assertTrue(nftContract.isForSale(tokenId).send());
assertEquals(price, nftContract.tokenPrices(tokenId).send());
// ๊ตฌ๋งค์ ๊ณ์ ์ผ๋ก NFT ๊ตฌ๋งค
SimpleNFT buyerContract = SimpleNFT.load(
nftContract.getContractAddress(),
web3j,
buyer,
new DefaultGasProvider()
);
buyerContract.buyNFT(tokenId).send();
// ์์ ๊ถ ์ด์ ํ์ธ
String newOwner = nftContract.ownerOf(tokenId).send();
assertEquals(buyer.getAddress(), newOwner);
// ํ๋งค ์ํ ํ์ธ
assertFalse(nftContract.isForSale(tokenId).send());
}
@Test
public void testCannotBuyUnlistedNFT() {
// NFT ๋ฐํ๋ง ํ๊ณ ํ๋งค ๋ฑ๋ก ์ ํจ
TransactionReceipt receipt = nftContract.mintNFT(
owner.getAddress(),
"ipfs://QmTest789"
).send();
BigInteger tokenId = nftContract.getNFTMintedEvents(receipt)
.get(0).tokenId;
// ๊ตฌ๋งค ์๋ ์ ์คํจํด์ผ ํจ
SimpleNFT buyerContract = SimpleNFT.load(
nftContract.getContractAddress(),
web3j,
buyer,
new DefaultGasProvider()
);
assertThrows(Exception.class, () -> {
buyerContract.buyNFT(tokenId).send();
});
}
}
ํตํฉ ํ ์คํธ
์ค์ ํ ์คํธ๋ท์์๋ ํ ์คํธํด๋ด์ผ ํด. ๋ก์ปฌ๊ณผ ์ค์ ๋คํธ์ํฌ๋ ๋ค๋ฅผ ์ ์๊ฑฐ๋ !
@SpringBootTest
public class IntegrationTest {
@Autowired
private NFTMarketplaceService nftService;
@Test
@Disabled("์ค์ ํ
์คํธ๋ท์์๋ง ์คํ")
public void testFullWorkflow() throws Exception {
// 1. NFT ๋ฐํ
String tokenId = nftService.mintNFT(
"0x...",
"ipfs://QmRealTest"
);
assertNotNull(tokenId);
// 2. ํ๋งค ๋ฑ๋ก
nftService.listNFT(tokenId, "0.1");
// 3. ํ๋งค ๋ชฉ๋ก ์กฐํ
List<NFTInfo> listedNFTs = nftService.getListedNFTs();
assertTrue(listedNFTs.stream()
.anyMatch(nft -> nft.getTokenId().equals(tokenId)));
// ์ค์ ๊ตฌ๋งค๋ ํ๋ก ํธ์๋์์ ํ
์คํธ
}
}
๐ ์ค์ ํ๊ณผ ๋ฒ ์คํธ ํ๋ํฐ์ค
๋ง์ง๋ง์ผ๋ก ์ค์ ์์ ์ ์ฉํ ํ๋ค์ ์ ๋ฆฌํด๋ณผ๊ฒ! ์ด๊ฑด ๋ด๊ฐ ์ง์ ๊ฒฝํํ๋ฉด์ ๋ฐฐ์ด ๊ฒ๋ค์ด์ผ. ๐
๊ฐ๋ฐ ์ํฌํ๋ก์ฐ
Ganache๋ก ๋น ๋ฅด๊ฒ ๊ฐ๋ฐํ๊ณ ํ ์คํธํด.
Sepolia๋ Goerli์ ๋ฐฐํฌํด์ ์ค์ ํ๊ฒฝ๊ณผ ์ ์ฌํ๊ฒ ํ ์คํธํด.
๋ฉ์ธ๋ท ๋ฐฐํฌ ์ ์ ๋ฐ๋์ ๋ณด์ ๊ฐ์ฌ๋ฅผ ๋ฐ์.
์ถฉ๋ถํ ํ ์คํธ ํ ๋ฉ์ธ๋ท์ ๋ฐฐํฌํด. ํ๋ฒ ๋ฐฐํฌํ๋ฉด ์์ ๋ถ๊ฐ!
๋ฐฐํฌ ํ์๋ ๊ณ์ ๋ชจ๋ํฐ๋งํ๊ณ ์ด์ ์งํ๋ฅผ ๊ฐ์งํด.
์ ์ฉํ ๋๊ตฌ๋ค
| ๋๊ตฌ | ์ฉ๋ |
|---|---|
| Remix IDE | Solidity ๊ฐ๋ฐ ๋ฐ ํ ์คํธ |
| Hardhat | ์ค๋งํธ ์ปจํธ๋ํธ ๊ฐ๋ฐ ํ๋ ์์ํฌ |
| Etherscan | ํธ๋์ญ์ ๋ฐ ์ปจํธ๋ํธ ํ์ |
| OpenZeppelin | ๊ฒ์ฆ๋ ์ค๋งํธ ์ปจํธ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ |
| IPFS | ํ์ค์ํ ํ์ผ ์ ์ฅ |
| The Graph | ๋ธ๋ก์ฒด์ธ ๋ฐ์ดํฐ ์ธ๋ฑ์ฑ ๋ฐ ์ฟผ๋ฆฌ |
์ปค๋ฎค๋ํฐ์ ํ์ต ์์
- Web3j ๊ณต์ ๋ฌธ์: https://docs.web3j.io/
- Solidity ๊ณต์ ๋ฌธ์: https://docs.soliditylang.org/
์จ๋ผ์ธ ๊ฐ์
- Udemy์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ๊ฐ์๋ค
- Coursera์ Blockchain Specialization
- ์ฌ๋ฅ๋ท์์ ๋ธ๋ก์ฒด์ธ ๋ฉํ ๋ง ์ฐพ๊ธฐ! ๐
์ปค๋ฎค๋ํฐ
- Ethereum Stack Exchange
- Reddit r/ethdev
- Discord ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ๋ค
์ค์ํ๊ธฐ ์ฌ์ด ๊ฒ๋ค
ํญ์ ๋คํธ์ํฌ๋ฅผ ํ์ธํด! ์ค์๋ก ๋ฉ์ธ๋ท์์ ํ ์คํธํ๋ฉด ๋์ด ๋ ์๊ฐ.
2. ๊ฐ์ค๋น ๋ฏธ๊ณ ๋ ค
๋ณต์กํ ๋ก์ง์ ๊ฐ์ค๋น๊ฐ ์์ฒญ๋๊ฒ ๋์ฌ ์ ์์ด. ํญ์ ๊ฐ์ค ํ๋๋ฅผ ์ฒดํฌํด.
3. ๊ฐ์ธํค ๋ ธ์ถ
GitHub์ ๊ฐ์ธํค๋ฅผ ์ฌ๋ฆฌ๋ ์ค์๋ ์ ๋ ํ์ง ๋ง! .gitignore ์ค์ ํ์.
4. ํธ๋์ญ์ ๋๊ธฐ ์๊ฐ ๋ฌด์
๋ธ๋ก์ฒด์ธ์ ๋๋ ค. ๋น๋๊ธฐ ์ฒ๋ฆฌ์ ์ ์ ํ ํ์์์ ์ค์ ์ด ํ์ํด.
5. ์๋ฌ ์ฒ๋ฆฌ ๋ถ์กฑ
๋คํธ์ํฌ ์ค๋ฅ, ๊ฐ์ค ๋ถ์กฑ, ํธ๋์ญ์ ์คํจ ๋ฑ ๋ค์ํ ์๋ฌ ์ํฉ์ ์ฒ๋ฆฌํด์ผ ํด.
๐ ๋ง์น๋ฉฐ
์! ์ฌ๊ธฐ๊น์ง ์ฝ์๋ค๋ฉด ์ ๋ง ๋๋จํด! ๐ ์ฐ๋ฆฌ๋ ์๋ฐ์ Web3j๋ฅผ ์ฌ์ฉํด์ ๋ธ๋ก์ฒด์ธ DApp์ ๊ฐ๋ฐํ๋ ์ ์ฒด ๊ณผ์ ์ ์ดํด๋ดค์ด. ๊ธฐ๋ณธ ๊ฐ๋ ๋ถํฐ ์์ํด์ ์ค์ NFT ๋ง์ผํ๋ ์ด์ค๊น์ง ๋ง๋ค์ด๋ดค์ง!
๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ ์ฒ์์ ์ด๋ ต๊ฒ ๋๊ปด์ง ์ ์์ด. ์๋ก์ด ๊ฐ๋ ๋ ๋ง๊ณ , ๊ธฐ์กด ์น ๊ฐ๋ฐ๊ณผ๋ ๋ค๋ฅธ ์ฌ๊ณ ๋ฐฉ์์ด ํ์ํ๊ฑฐ๋ . ํ์ง๋ง ํ ๋ฒ ์ต์ํด์ง๋ฉด ์ ๋ง ์ฌ๋ฏธ์์ด! ํ์ค์ํ๋ ๋ฏธ๋๋ฅผ ์ง์ ๋ง๋ค์ด๊ฐ๋ ๋๋์ด๋๊น? ๐
- โ Web3j๋ ์๋ฐ์์ ์ด๋๋ฆฌ์๊ณผ ํต์ ํ๋ ๊ฐ๋ ฅํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
- โ ์ค๋งํธ ์ปจํธ๋ํธ๋ Solidity๋ก ์์ฑํ๊ณ ๋ธ๋ก์ฒด์ธ์ ๋ฐฐํฌ
- โ ์ง๊ฐ ๊ด๋ฆฌ์ ํธ๋์ญ์ ์ฒ๋ฆฌ๋ Web3j๋ก ์ฝ๊ฒ ๊ตฌํ
- โ ๋ณด์์ด ์ต์ฐ์ ! ๊ฐ์ธํค ๊ด๋ฆฌ์ ์ปจํธ๋ํธ ๊ฐ์ฌ๋ ํ์
- โ ํ ์คํธ๋ ๋ก์ปฌ(Ganache) โ ํ ์คํธ๋ท โ ๋ฉ์ธ๋ท ์์๋ก
- โ ๊ฐ์ค ์ต์ ํ์ ๋ ์ด์ด 2 ํ์ฉ์ผ๋ก ๋น์ฉ ์ ๊ฐ
- โ ์ปค๋ฎค๋ํฐ์ ํจ๊ป ์ฑ์ฅํ์!
๋ธ๋ก์ฒด์ธ ๊ธฐ์ ์ ๊ณ์ ๋ฐ์ ํ๊ณ ์์ด. ์๋ก์ด ํ๋กํ ์ฝ, ์๋ก์ด ๋ ์ด์ด 2 ์๋ฃจ์ , ์๋ก์ด ํ์ค๋ค์ด ๊ณ์ ๋์ค๊ณ ์์ง. ๊ทธ๋์ ํญ์ ๋ฐฐ์ฐ๋ ์์ธ๊ฐ ์ค์ํด! ๐
ํน์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ด ์ฒ์์ด๋ผ ๋ง๋งํ๋ค๋ฉด, ์ฌ๋ฅ๋ท์์ ๊ฒฝํ ๋ง์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์์๊ฒ ๋ฉํ ๋ง์ ๋ฐ์๋ณด๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ. ์ค์ ๊ฒฝํ์ด ์๋ ์ฌ๋์๊ฒ ์ง์ ๋ฐฐ์ฐ๋ฉด ์ํ์ฐฉ์ค๋ฅผ ์ค์ผ ์ ์๊ฑฐ๋ ! ๐
์, ์ด์ ๋๋ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์์ ์ธ๊ณ์ ์ฒซ๋ฐ์ ๋ด๋๋ ์ด! ์ฒ์์ ์ด๋ ค์ธ ์ ์์ง๋ง, ํ๋์ฉ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฐ๋ผํ๋ค ๋ณด๋ฉด ์ด๋์ ๋ฉ์ง DApp์ ๋ง๋ค๊ณ ์์ ๊ฑฐ์ผ. ๐ช
๋ธ๋ก์ฒด์ธ์ ๋จ์ํ ๊ธฐ์ ์ด ์๋๋ผ ์๋ก์ด ํจ๋ฌ๋ค์์ด์ผ. ์ค์ํ๋ ์์คํ ์์ ํ์ค์ํ๋ ์์คํ ์ผ๋ก์ ์ ํ. ์ด๊ฑด ์ธํฐ๋ท์ด ์ธ์์ ๋ฐ๊พผ ๊ฒ๋งํผ์ด๋ ํฐ ๋ณํ๊ฐ ๋ ๊ฑฐ์ผ. ๊ทธ๋ฆฌ๊ณ ๋๋ ์ง๊ธ ๊ทธ ๋ณํ์ ์ต์ ์ ์ ์ ์๋ ๊ฑฐ์ง! ๐
๋ง์ง๋ง์ผ๋ก ํ ๊ฐ์ง ์กฐ์ธ: ์คํจ๋ฅผ ๋๋ ค์ํ์ง ๋ง! ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ ์ํ์ฐฉ์ค์ ์ฐ์์ด์ผ. ํธ๋์ญ์ ์ด ์คํจํ๊ณ , ๊ฐ์ค๋น๋ฅผ ๋ญ๋นํ๊ณ , ๋ฒ๊ทธ๋ฅผ ๋ง๋๋ ๊ฑด ๋น์ฐํ ๊ณผ์ ์ด์ผ. ์ค์ํ ๊ฑด ๊ทธ๋๋ง๋ค ๋ฐฐ์ฐ๊ณ ์ฑ์ฅํ๋ ๊ฑฐ์ง. ๐ก
์, ์ด์ ์ฝ๋ ์๋ํฐ๋ฅผ ์ด๊ณ ๋๋ง์ DApp์ ๋ง๋ค์ด๋ด! ์ธ์์ ๋ฐ๊ฟ ์์ด๋์ด๋ ๋ฐ๋ก ๋์ ๋จธ๋ฆฟ์์ ์์์ง๋ ๋ชฐ๋ผ. ํ์ดํ ! ๐โจ
๋ธ๋ก์ฒด์ธ์ ๋ฏธ๋๋ ์ฐ๋ฆฌ๊ฐ ๋ง๋ค์ด๊ฐ๋๋ค!
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.