์คํฌ๋ฆฝํธ ์คํ ๋ช
๋ น์ด
#1) ํน์ Credential ์์ ์๋ง ์ ๊ทผ ๊ฐ๋ฅํ Domain ์์ฑ
$npx ts-node xrpl/PermissionedDomains/createDomain.ts
#2) Domain ์ญ์
$npx ts-node xrpl/PermissionedDomains/deleteDomain.ts
#3) ํด๋น Domain์ ์ ๊ทผ ๊ฐ๋ฅํ Credential ๋ฐ ์์ ์ ๋ฆฌ์คํธ ๋ณด๊ธฐ (Optional)
$npx ts-node xrpl/PermissionedDomains/AcceptedCredentials.ts
#์ฌ๊ธฐ์๋ ์์ฑ ํ ์ถ๋ ฅ๋๋ DomainID(created): 2A65BCCE9715703A09460B44812BB65D41B9406A42D0CC66979E385C5788#### ๋ฅผ ๋๋จธ์ง ์คํฌ๋ฆฝํธ์ ๋ฃ์ด์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
Bash
๋ณต์ฌ
1. Permissioned Domain์ด๋?
Permissioned Domain์ ์ ๊ทผ ์ ์ฑ
(Access Policy)์ ์จ์ฒด์ธ์ ๋ฑ๋กํ๋ ๊ธฐ๋ฅ์ด๋ค.
์ค์ค๋ก๋ ์๋ฌด ํ๋๋ ํ์ง ์์ง๋ง, ๋ค๋ฅธ ๋ฆฌ์์ค(์: Permissioned DEX, Lending Vault ๋ฑ)์ ๋๋ฉ์ธ ID๋ฅผ ์ฐ๊ฒฐํ๋ฉด
ํด๋น ๋ฆฌ์์ค๊ฐ ์ด ๋๋ฉ์ธ์ ๊ท์น์ ๋ฐ๋ผ ํธ๋์ญ์
์ ํ์ฉํ๊ฑฐ๋ ๊ฑฐ๋ถํ ์ ์๋ค.
โข
๋๋ฉ์ธ์ ๊ท์น = AcceptedCredentials
1~10๊ฐ์ โํ์ฉ ์๊ฒฉโ์ ๋์ดํ๋ค.
๊ฐ ์๊ฒฉ์ ๋ฐ๊ธ์(Issuer)์ CredentialType(hex)์ ์กฐํฉ์ด๋ค.
โข
์ ๊ทผ ํ์ฉ ์กฐ๊ฑด
ํธ๋์ญ์
์ ๋ณด๋ด๋ ๊ณ์ ์ด ์ด ๋๋ฉ์ธ์์ ํ์ฉํ Credential์ ์ต์ 1๊ฐ ์ด์ ๊ฐ์ง๊ณ ์์ด์ผ ํ๋ค.
ํด๋น Credential์ ์๋ฝ๋จ(accepted) ์ํ์ด๋ฉฐ ๋ง๋ฃ๋์ง ์์์ผ ํ๋ค.
2. ์ ํ์ํ๊ฐ?
โข
๊ท์ ์ค์
๊ธ์ต ์๋น์ค, KYC/AML ์๊ตฌ์ฌํญ์ด ์๋ ํ๋ก์ ํธ์์ ํ์.
โข
์ ์ฑ
๋ถ๋ฆฌ
์ ์ฑ
๋ณ๊ฒฝ ์, ๋ฆฌ์์ค ์ฝ๋๋ ์ฃผ์๋ฅผ ์์ ํ ํ์ ์์ด ๋๋ฉ์ธ ๊ท์น๋ง ์
๋ฐ์ดํธํ๋ฉด ๋๋ค.
โข
์ด์ ์ ์ฐ์ฑ
๋ฐ๊ธ/์๋ฝ/๋ง๋ฃ๋ฅผ ํตํด ์ค์๊ฐ์ผ๋ก ์ ๊ทผ์ ๋ชฉ๋ก์ด ๋ณ๋๋ ์ ์๋ค.
โข
์์ ๊ถ ๋ช
ํ
๋๋ฉ์ธ์ ๋ง๋ ๊ณ์ (์ค๋)๋ง ๊ท์น ๋ณ๊ฒฝยท์ญ์ ๊ฐ๋ฅ.
3. ์๋๋ฆฌ์ค: createDomain โ deleteDomain
์๋๋ฆฌ์ค์์๋ ๋๋ฉ์ธ ์์ฑ๊ณผ ์ญ์ ๋ง ๋ค๋ฃฌ๋ค.
Credential ๋ฐ๊ธ/์๋ฝ ์๋๋ฆฌ์ค์ ์กฐํฉํ๋ฉด, ๋๋ฉ์ธ์ ์ค์ ์ ๊ทผ์ ํ ํจ๊ณผ๊น์ง ํ์ธํ ์ ์๋ค.
Step 1. ๋๋ฉ์ธ ์์ฑ
โข
์ฃผ์ฒด: ADMIN(๋๋ฉ์ธ ์ค๋)
โข
ํ๋: PermissionedDomainSet ํธ๋์ญ์
์ ์ก
โข
๋ด์ฉ:
โฆ
AcceptedCredentials: {Issuer: ADMIN, CredentialType: "KYC(hex)"}
โ ADMIN์ด ๋ฐ๊ธํ KYC Credential์ ๊ฐ์ง ๊ณ์ ๋ง ์ด ๋๋ฉ์ธ์ ์ ๊ทผ ๊ฐ๋ฅ
import { Client, Wallet, Transaction } from "xrpl"
import path from "path"
import dotenv from "dotenv"
// .env ๋ก๋ (ADMIN_SEED ํ์)
dotenv.config({ path: path.join(__dirname, "..", ".env") })
// ๋ฌธ์์ด์ hex ์ธ์ฝ๋ฉํ๋ ํฌํผ ํจ์
const toHex = (s: string) => Buffer.from(s, "utf8").toString("hex")
export async function createDomain() {
const client = new Client("wss://s.devnet.rippletest.net:51233")
await client.connect()
const ADMIN_SEED = process.env.ADMIN_SEED
if (!ADMIN_SEED) throw new Error("Missing env: ADMIN_SEED")
// ๋ฐํ์(Admin) ์ง๊ฐ ๋ก๋
const admin = Wallet.fromSeed(ADMIN_SEED)
try {
// PermissionedDomainSet ํธ๋์ญ์
๊ตฌ์ฑ
const tx: Transaction = {
TransactionType: "PermissionedDomainSet",
Account: admin.address,
// ์๋ก์ด Domain ์์ฑ ์ DomainID๋ ์๋ต
AcceptedCredentials: [
{
Credential: {
Issuer: admin.address,
CredentialType: toHex("KYC"), // "KYC" โ hex ์ธ์ฝ๋ฉ
},
},
],
}
// ํธ๋์ญ์
์๋ ๋ณด์ & ์๋ช
const prepared = await client.autofill(tx)
const signed = admin.sign(prepared)
// ์ ์ถ ๋ฐ ๊ฒฐ๊ณผ ๋๊ธฐ
const result: any = await client.submitAndWait(signed.tx_blob)
// ์ ์ฒด ์๋ต ๋ก๊ทธ ์ถ๋ ฅ
console.log(JSON.stringify(result, null, 2))
// meta ๋ฐ์ดํฐ์์ ์์ฑ๋ PermissionedDomain ๊ฐ์ฒด ํ์
const out = result.result ?? result
const created = (out.meta?.AffectedNodes || []).find(
(n: any) => n.CreatedNode?.LedgerEntryType === "PermissionedDomain"
)
const domainId =
created?.CreatedNode?.LedgerIndex ||
created?.CreatedNode?.NewFields?.DomainID ||
null
if (domainId) {
console.log("โ
DomainID(created):", domainId)
} else {
console.warn("โ ๏ธ Could not locate DomainID in meta. Check node support/fields.")
}
return result
} catch (err) {
console.error("โ ๋๋ฉ์ธ ์์ฑ ์คํจ:", err)
throw err
} finally {
await client.disconnect()
console.log("๐ ์ฐ๊ฒฐ ์ข
๋ฃ")
}
}
// ์ง์ ์คํ ์ ๋์
if (require.main === module) {
createDomain().catch((e) => {
console.error(e)
process.exit(1)
})
}
TypeScript
๋ณต์ฌ
โข
์ฝ์์ ์์ฑ๋ ๋๋ฉ์ธ ID(๋ฐ๋ก ๋ณต์ฌํด ๋๋ฉ์ธ ์ญ์ ๋ฐ Credential ์กฐํ ๋ฑ์ ์ฌ์ฉ)
DomainID(created): 2A65BCCE9715703A09460B44812BB65D41B9406A42D0CC66979E385C5788####
Bash
๋ณต์ฌ
โข
DomainID : Permissioned Domain์ ๊ณ ์ ํ๊ฒ ์๋ณํ๋ 32๋ฐ์ดํธ(256๋นํธ) ํด์ ๊ฐ์ผ๋ก, 64์๋ฆฌ hex ๋ฌธ์์ด๋ก ํ์๋จ
Step 2. ๋๋ฉ์ธ ์ญ์
โข
์ฃผ์ฒด: ADMIN
โข
ํ๋: PermissionedDomainDelete ํธ๋์ญ์
์ ์ก
โข
๋ด์ฉ: DomainID ์ง์ โ ํด๋น ๋๋ฉ์ธ์ ์ ์ฑ
์์ฒด๊ฐ ์ฌ๋ผ์ง
import { Client, Wallet, Transaction } from "xrpl"
import path from "path"
import dotenv from "dotenv"
// .env ๋ก๋ (ADMIN_SEED ํ์)
dotenv.config({ path: path.join(__dirname, "..", ".env") })
export async function deleteDomain() {
const client = new Client("wss://s.devnet.rippletest.net:51233")
await client.connect()
const ADMIN_SEED = process.env.ADMIN_SEED
if (!ADMIN_SEED) throw new Error("Missing env: ADMIN_SEED")
// ๋ฐํ์(Admin) ์ง๊ฐ ๋ก๋
const admin = Wallet.fromSeed(ADMIN_SEED)
// โ
createDomain ์คํ ๊ฒฐ๊ณผ ๋ก๊ทธ์์ ๋ณต์ฌํ DomainID ์
๋ ฅ
const DOMAIN_ID =
"2A65BCCE9715703A09460B44812BB65D41B9406A42D0CC66979E385C5788####"
try {
// PermissionedDomainDelete ํธ๋์ญ์
๊ตฌ์ฑ
const tx: Transaction = {
TransactionType: "PermissionedDomainDelete",
Account: admin.address,
DomainID: DOMAIN_ID,
}
// ํธ๋์ญ์
์๋ ๋ณด์ & ์๋ช
const prepared = await client.autofill(tx)
const signed = admin.sign(prepared)
// ์ ์ถ ๋ฐ ๊ฒฐ๊ณผ ๋๊ธฐ
const result = await client.submitAndWait(signed.tx_blob)
// ์ ์ฒด ์๋ต ์ถ๋ ฅ
console.log(JSON.stringify(result, null, 2))
return result
} catch (err) {
console.error("โ ๋๋ฉ์ธ ์ญ์ ์คํจ:", err)
throw err
} finally {
await client.disconnect()
console.log("๐ ์ฐ๊ฒฐ ์ข
๋ฃ")
}
}
// ์ง์ ์คํ ์ ๋์
if (require.main === module) {
deleteDomain().catch((e) => {
console.error(e)
process.exit(1)
})
}
TypeScript
๋ณต์ฌ
(์ต์ )Step 3. ํน์ ๋๋ฉ์ธ์ Accepted Credentials ์ ๋ณด ์กฐํ
import { Client } from "xrpl"
async function inspectDomain() {
// XRPL Devnet ์ฐ๊ฒฐ
const client = new Client("wss://s.devnet.rippletest.net:51233")
await client.connect()
try {
// createDomain ์คํ ๋ก๊ทธ์์ ๋ณต๋ถํ DomainID
const DOMAIN_ID =
"5771BD9BD9B9BC01816103C9E435E54630AFF83B607DC9BCB0005D'''''''''"
// ledger_entry ๋ช
๋ น์ผ๋ก Domain ๊ฐ์ฒด ์กฐํ
const r = await client.request({
command: "ledger_entry",
index: DOMAIN_ID,
})
// ๊ฒฐ๊ณผ๋ฅผ JSON ํฌ๋งท์ผ๋ก ์ถ๋ ฅ
console.log(JSON.stringify(r, null, 2))
} catch (err) {
console.error("โ ๋๋ฉ์ธ ์กฐํ ์คํจ:", err)
} finally {
// ์ฐ๊ฒฐ ์ข
๋ฃ
await client.disconnect()
console.log("๐ ์ฐ๊ฒฐ ์ข
๋ฃ")
}
}
// ์ง์ ์คํ๋ ๊ฒฝ์ฐ ํจ์ ์คํ
inspectDomain().catch((e) => {
console.error(e)
process.exit(1)
})
TypeScript
๋ณต์ฌ
โข
ํด๋น ๋๋ฉ์ธ์ AcceptedCredentials ์ ๋ณด๋ฅผ ์ฝ์์ ์ถ๋ ฅ

