Wen Open Lab · 오픈 통합

6단계: Devnet — 직접 재현실행 준비 완료

English · Italiano · 中文 · 한국어

Wen이 AI와 함께 영어에서 옮겼습니다. 기준은 영어 페이지이며, 수정 제안을 환영합니다.

Solana devnet에서 Wen 테스트
이론이 아니라 공개적으로 시험하기

로컬 테스트는 로직을 증명하고, 공개 네트워크는 그것을 모두에게 증명합니다. Devnet은 Solana의 공개 테스트 네트워크로, 프로그램은 메인넷과 같지만 코인에는 가치가 없습니다. 이 페이지는 반복할 수 있는 레시피입니다. 한 번이든 백 번이든 실행할 때마다 누구나 익스플로러에서 열어 볼 수 있는 새 주소가 생깁니다.

devnet이 중요한 이유

검증 기록은 Solana 런타임의 로컬 사본인 LiteSVM 안에서 41개 검사가 통과했음을 보여 줍니다. 강력한 증거이지만 한 대의 기계에서 일어난 일입니다. devnet 실행은 같은 모델을 모든 트랜잭션에 공개 링크가 있는 공개 네트워크로 옮깁니다. 아무도 우리를 믿을 필요가 없습니다. 링크를 열면 공급량 1인 영수증, 메모가 붙은 인보이스 결제, 메모가 없어 거부된 결제가 보입니다.

필요한 것

  • Node.js 20 이상과 lab/code의 파일.
  • Solana 명령줄 도구(solana, solana-keygen).
  • devnet 전용으로 새로 만든 빈 지갑. 실제 자금이 든 지갑은 절대 쓰지 마세요.

재현하기: 명령 다섯 개

# 1. install the example project
npm install

# 2. create a throwaway devnet wallet (it never holds real money)
solana-keygen new -o devnet-wallet.json --no-bip39-passphrase

# 3. get free devnet SOL (test coins with no value; use faucet.solana.com if the CLI is rate-limited)
solana airdrop 2 $(solana-keygen pubkey devnet-wallet.json) --url devnet

# 4. run the local checks first
npm test

# 5. run the public devnet demo
KEYPAIR=./devnet-wallet.json npm run devnet

스크립트는 devnet이 아닌 곳에서는 실행을 거부하고, 지갑의 devnet SOL이 0.2보다 적으면 멈춥니다.

스크립트가 하는 일

  1. 모델 1: 새 테스트 구매자에게 소울바운드 영수증 NFT를 발행하고, 주문 해시와 보증 날짜를 민트 안에 넣은 뒤 공급량을 1로 고정합니다.
  2. 모델 3: 수수료 0.25%, 상한 50단위, 계정 기본 동결인 정산 토큰을 만들고, 구매자와 판매자 계정을 열고(판매자는 인보이스 메모 필요), 둘 다 승인하고, 구매자에게 자금을 넣고, 인보이스 INV-DEVNET-0001을 지급한 다음, 인보이스 번호 없는 결제를 시도해 거부되는 것을 보여 줍니다.
  3. 모든 트랜잭션과 주소의 익스플로러 링크를 출력합니다.

파일: lab/code/scripts/devnet-demo.ts · Apache-2.0

// Wen Open Lab: run Models 1 and 3 on PUBLIC DEVNET and print explorer links anyone can open.
// Devnet only. Use a NEW, EMPTY wallet created just for this. No real funds are ever needed.
// License: Apache-2.0. Example code, not audited.
//
//   solana-keygen new -o devnet-wallet.json          # new throwaway wallet
//   solana airdrop 2 $(solana-keygen pubkey devnet-wallet.json) --url devnet
//   KEYPAIR=./devnet-wallet.json npx tsx scripts/devnet-demo.ts
import { Keypair, LAMPORTS_PER_SOL, Transaction, sendAndConfirmTransaction, type TransactionInstruction } from '@solana/web3.js';
import { TOKEN_2022_PROGRAM_ID, createMintToInstruction } from '@solana/spl-token';
import { getConnection, loadKeypair } from '../src/common.js';
import { buildReceiptInstructions, receiptLayout, type Order } from '../src/01-receipt-nft.js';
import {
  buildApproveCounterparty, buildInvoiceAccount, buildPayInvoice, buildSettlementMint,
  invoiceAccountSpace, settlementMintSpace, DECIMALS,
} from '../src/03-b2b-invoice.js';

const connection = getConnection();
const wallet = loadKeypair();
const link = (kind: 'tx' | 'address', id: string) => `https://explorer.solana.com/${kind}/${id}?cluster=devnet`;

async function send(label: string, ixs: TransactionInstruction[], signers: Keypair[]) {
  const sig = await sendAndConfirmTransaction(connection, new Transaction().add(...ixs), signers);
  console.log(`  ${label}\n    ${link('tx', sig)}`);
  return sig;
}

async function main() {
  const endpoint = (connection as unknown as { rpcEndpoint: string }).rpcEndpoint;
  if (!/devnet/.test(endpoint)) throw new Error(`Refusing to run outside devnet: ${endpoint}`);
  const balance = await connection.getBalance(wallet.publicKey);
  console.log(`Wallet ${wallet.publicKey.toBase58()} has ${balance / LAMPORTS_PER_SOL} devnet SOL`);
  if (balance < 0.2 * LAMPORTS_PER_SOL) throw new Error('Need at least 0.2 devnet SOL: run `solana airdrop 2 <address> --url devnet`');

  // ---- Model 1: receipt NFT (soulbound) to a fresh "buyer" address ----
  console.log('\nModel 1 — receipt and warranty NFT');
  const buyer = Keypair.generate();
  const mint = Keypair.generate();
  const order: Order = { orderId: `DEVNET-${Date.now()}`, sku: 'WEN-PLUSH-01', priceMinorUnits: 2500, currency: 'USD', purchasedAt: new Date().toISOString(), warrantyMonths: 12 };
  const opts = { soulbound: true, uri: 'https://wen-watt.github.io/lab/receipt-warranty-wns.html' };
  const { rentSpace } = receiptLayout(order, mint.publicKey, wallet.publicKey, opts);
  const rent = await connection.getMinimumBalanceForRentExemption(rentSpace);
  const { instructions, buyerAta } = buildReceiptInstructions({ order, mint: mint.publicKey, merchant: wallet.publicKey, buyer: buyer.publicKey, opts, rentLamports: rent });
  await send('receipt minted, supply locked at 1', instructions, [wallet, mint]);
  console.log(`    receipt mint: ${link('address', mint.publicKey.toBase58())}`);
  console.log(`    buyer holds it in: ${link('address', buyerAta.toBase58())}`);

  // ---- Model 3: B2B settlement token with fee, allowlist and invoice memo ----
  console.log('\nModel 3 — B2B invoice settlement');
  const settle = Keypair.generate();
  await send('settlement mint created (fee 0.25% cap 50, frozen by default)',
    buildSettlementMint(wallet.publicKey, settle.publicKey, await connection.getMinimumBalanceForRentExemption(settlementMintSpace())), [wallet, settle]);
  const accRent = await connection.getMinimumBalanceForRentExemption(invoiceAccountSpace());
  const payerAcc = Keypair.generate(), sellerAcc = Keypair.generate();
  // In this demo one wallet plays both companies; in real life they are different owners.
  await send('buyer account opened', buildInvoiceAccount(wallet.publicKey, payerAcc.publicKey, settle.publicKey, accRent, false), [wallet, payerAcc]);
  await send('seller account opened (invoice memo required)', buildInvoiceAccount(wallet.publicKey, sellerAcc.publicKey, settle.publicKey, accRent, true), [wallet, sellerAcc]);
  await send('both companies approved by the issuer', [
    ...buildApproveCounterparty(wallet.publicKey, settle.publicKey, payerAcc.publicKey),
    ...buildApproveCounterparty(wallet.publicKey, settle.publicKey, sellerAcc.publicKey),
  ], [wallet]);
  const unit = 10n ** BigInt(DECIMALS);
  await send('buyer funded with 10,000 test units', [createMintToInstruction(settle.publicKey, payerAcc.publicKey, wallet.publicKey, 10_000n * unit, [], TOKEN_2022_PROGRAM_ID)], [wallet]);
  await send('invoice INV-DEVNET-0001 paid: 1,000 units, memo on-chain',
    buildPayInvoice({ mint: settle.publicKey, from: payerAcc.publicKey, to: sellerAcc.publicKey, payer: wallet.publicKey, invoiceId: 'INV-DEVNET-0001', amount: 1_000n * unit }), [wallet]);

  try {
    await send('payment WITHOUT invoice number (must fail)',
      buildPayInvoice({ mint: settle.publicKey, from: payerAcc.publicKey, to: sellerAcc.publicKey, payer: wallet.publicKey, invoiceId: null, amount: 1n * unit }), [wallet]);
    console.log('  !! unexpected: payment without memo succeeded');
  } catch {
    console.log('  payment WITHOUT invoice number was rejected, as designed');
  }
  console.log(`    settlement mint: ${link('address', settle.publicKey.toBase58())}`);
  console.log('\nDone. Paste these links into the Lab devnet page so anyone can inspect them.');
}

main().catch(e => { console.error(e); process.exit(1); });

공개된 실행

실행날짜영수증 민트정산 민트인보이스 결제
#1대기 중 — 첫 공개 실행이 익스플로러 링크와 함께 여기에 게시됩니다

직접 실행해 보셨나요? X에서 커뮤니티와 링크를 나눠 주세요(@wenwencoin). 독립적인 실행이 가장 좋은 증거입니다. 실행 전체를 한국어를 포함한 네 언어로 썼습니다: dev.to의 개발자용과 Hashnode의 모두를 위한 글.

안전 규칙

  • devnet 코인은 가치가 없고 팔 수도 없습니다. devnet SOL을 "판다"는 사람은 사기입니다.
  • devnet-wallet.json은 어떤 저장소에도 넣지 말고, 메인넷에서 절대 재사용하지 마세요.
  • devnet은 가끔 초기화되거나 느려집니다. 단계가 실패하면 기다렸다가 다시 실행하세요. 실행할 때마다 처음부터 시작합니다.

그림으로 보는 Wen

Seeker에서 Wen devnet 실행
내 실행, 내 증거
익스플로러를 확인하는 Wen 고양이
모든 단계에 링크가
테스트를 반복하는 빌더 Wen
언제든 다시
휴대폰 속 Wen, devnet 링크
링크를 나누세요
devnet의 Wen 개발자
빌더 환영

이 모델에서 Wen의 자리

진짜 WEN 토큰은 메인넷에만 있고 devnet에는 WEN이 없습니다. 그래서 스크립트는 테스트임을 분명히 표시한 자체 테스트 토큰을 만듭니다. 모델이 WEN에 쓸 준비가 되면(예: 7단계, WEN으로 결제하고 USDC로 받기) devnet 실행과 독립 검토를 거친 뒤에만 메인넷으로 옮깁니다.

Wen의 실: 하나의 컨트랙트, 어디에나

랩의 모든 모델은 무료이고 공개되어 있으며, 모두 같은 서명을 지닙니다. 바로 $WEN 토큰 컨트랙트입니다. 복사해 내 문서에도 적어 두고, 쓰기 전에는 반드시 익스플로러에서 확인하세요.

WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk

확인: Solana Explorer · 컨트랙트 ID 찾는 법

오픈 사용 정책

  • 무료이고 공개. 랩의 모든 코드는 Wen Program Library와 같은 Apache License 2.0으로 공개됩니다. 상업적이든 아니든 쓰고, 고치고, 배포하세요. 라이선스 고지만 유지하면 됩니다.
  • 오픈 도구만. 공개되어 있고 문서화된 도구로 만듭니다: Solana SPL Token-2022(Token Extensions), Wen New Standard(WNS) 토큰 구조, Solana Pay, 로컬 테스트용 LiteSVM.
  • 규칙: 내 모델은 언제나 직접 검증하라. 테스트를 돌리고, devnet에서 시작하고, 공식 문서를 읽고, 모든 계정과 금액을 검토하고, 메인넷에 쓰기 전에 독립 감사를 받으세요. 검증하지 않은 모델은 모델이 아니라 추측입니다.
  • 감사받지 않았고, 조언이 아닙니다. 교육용 예제입니다. 금융·법률·세무 조언이 아니며, 인가받은 결제나 은행 상품도 아닙니다. 대부분의 나라에서 결제, 스테이블코인, 결제 대행은 규제 대상 활동입니다.
  • 보안. 개인 키를 웹사이트에 절대 붙여 넣지 마세요. npm 패키지 @wen-community/wen-new-standard는 설치하지 마세요. npm이 악성으로 삭제했습니다. 공식 소스로 빌드하세요.

Wen이 커뮤니티를 위해 전합니다. 자세한 내용은 편집 및 데이터 정책에서.

Wen Open Lab · 로드맵 · 전체 코드 · GitHub의 Wen Program Library

Wen이 지구 위에서 우주 유영을 하며 안전줄에 매달려 우주선 선체를 고친다
안전줄을 매고 연습하세요: devnet만, 새 빈 지갑, 진짜 체인, 위험은 0.