XRPL Docs (Korean)
  • XRPL Docs(Kor)
  • Introduction
    • XRP Ledger란?
    • XRP란?
    • Crypto Wallets
    • Transactions and Requests
    • Software Ecosystem
  • Use Cases
    • 결제(Payments)
      • P2P 결제(Peer-to-Peer Payments)
      • 예금 제한(Restricting Deposits)
      • 스마트 컨트랙트(Smart Contracts)
    • 토큰화(Tokenization)
      • 스테이블코인 발행인(Stablecoin Issuer)
      • NFT 마켓플레이스 개요(NFT Marketplace Overview)
    • 탈중앙화 금융(Decentralized Finance)
      • 알고리즘 트레이딩(Algorithmic Trading)
      • 거래소에 XRP 상장하기((List XRP as an Exchange)
  • Concepts
    • 소개
      • 컨센서스 소개
      • XRP
      • 소프트웨어 생태계
    • XRP Ledger 서버
      • rippled 서버 모드(rippled Server Modes)
      • 클러스터링(Clustering)
      • Ledger 역사
      • 피어 프로토콜(Peer Protocol)
      • 트랜잭션 검열 감지(Transaction Censorship Detection)
      • 병렬 네트워크(Parallel Networks)
      • 수정안(Amendments)
        • XRP Ledger에 코드를 기여하는 방법
        • 알려진 수정안
      • 클리오 서버(The Clio Server)
    • 컨센서스 네트워크(Consensus Protocol)
      • 컨센서스 구조(Consensus Structure)
      • 컨센서스 원칙과 규칙(Consensus Principles and Rules)
      • 공격과 실패 모드에 대한 컨센서스 보호(Consensus Protections Against Attacks and Failure Modes)
      • 불변성 체크
      • 부정 UNL
      • 트랜잭션 취소 정보
      • 트랜잭션 변조 가능성
      • 수수료 투표
      • 컨센서스 연구
    • Ledgers
      • Ledger 구조(Ledger Structure)
      • 개방형, 폐쇄형, 검증형 Ledgers(Open, Closed, and Validated Ledgers)
      • Ledger 마감 시간(Ledger Close Times)
    • 트랜잭션(Transactions)
      • 수수료(Fees)
      • 신뢰할 수 있는 트랜잭션 제출(Reliable Transaction Submission)
      • 보안 서명(Secure Signing)
      • 출발, 데스티네이션 태그(Source and Destination Tags)
      • 트랜잭션 비용(Transaction Cost)
      • 트랜잭션 대기열(Transaction Queue)
      • 결과의 불변성(Finality of Results)
        • 트랜잭션 결과 조회(Look Up Transaction Results)
        • Transaction Malleability
    • 결제 유형
      • XRP 직접 결제
      • 교차 화폐 결제
      • 수표
      • 에스크로
      • 부분 결제
      • 결제 채널
    • 토큰(Tokens)
      • Non-Fungible Tokens
        • NFT 정보 저장소(NFT Payload Storage)
        • XRP Ledger에서 NFT 토큰 거래(Trading NFTokens on the XRP Ledger)
        • NFT Reserve Requirements
        • 일괄 발행(Batch minting)
        • 다른 계정에게 NFT 발행 권한 부여(Authorizing Another Account to Mint Your NFTs)
        • NFT 경매 진행하기(Running an NFT Auction)
        • NFT를 컬렉션으로 발행하기(Minting NFTs into Collections)
        • NFT의 고정 공급 보장하기(Guaranteeing a Fixed Supply of NFTs)
        • NFT 관련 API(NFT APIs)
      • 신뢰선과 발급(Trust Lines and Issuing)
      • 승인된 신뢰선(Authorized Trust Lines)
      • 토큰 환수(Clawing Back Tokens)
      • Freezing Tokens(토큰 동결)
        • 동결에 대한 일반적인 오해(Common Misunderstandings about Freezes )
      • Rippling
      • 이체 수수료(Transfer Fees)
      • 경로(Paths)
      • Demurrage(과잉보유비용)
      • 탈중앙화 거래소(Decentralized Exchange)
        • 제안(Offers)
        • Auto-Bridging
        • Tick Size
        • AMM(Automated Market Makers)
    • 계정
      • 다중 서명
      • 티켓
      • 계정 유형
      • 계정 삭제
      • 준비금(Reserves)
      • 주소(Addresses)
      • 암호화 키(Cryptographic Keys)
      • 입금 승인(Deposit Authorization)
  • Tutorials
    • 퍼블릭 서버(Public Servers)
    • Python
      • Python으로 시작하기(Get Started Using Python)
      • python 모듈형 튜토리얼(Modular Tutorials in Python)
        • python을 이용한 Send Payments(Send Payments Using Python)
          • 계정 생성 및 XRP 전송(Create Accounts and Send XRP Using Python)
          • 신뢰 생성 및 Currency 전송 (Create Trust Line and Send Currency Using Python)
          • 시간 보류 에스크로 생성(Create Time-based Escrows Using Python)
        • python을 이용한 NFTs(NFTs Using Python)
          • NFTs 발행과 소각(Mint and Burn NFTs Using Python)
          • NFTs 전송 (Transfer NFTs Using Python)
          • NFT 판매 중개 (Broker an NFT Sale Using Python)
          • 공인 발행인 지정 (Assign an Authorized Minter Using Python)
          • NFTs 일괄 발행 (Batch Mint NFTs Using Python)
        • Python에서 데스크톱 지갑 구축(Build a Desktop Wallet in Python)
    • JavaScript
      • JavaScript로 시작하기(Get Started Using JavaScript)
      • JavaScript 모듈형 튜토리얼(Modular Tutorials in JavaScript)
        • JavaScript를 이용한 Send Payments(Send Payments Using JavaScript)
          • JavaScript를 이용한 계정 생성 및 XRP 전송(Create Accounts and Send XRP Using JavaScript)
          • JavaScript를 이용한 신뢰선 생성 및 화폐 전송(Create Trust Line and Send Currency Using JavaScript)
          • 시간 기반 에스크로 생성하기(Create Time-based Escrows Using JavaScript)
          • 조건부 에스크로 생성하기(Create Conditional Escrows Using JavaScript)
        • JavaScript를 이용한 NFTs(NFTs Using JavaScript)
          • JavaScript를 이용한 NFTs 발행 및 소각(Mint and Burn NFTs Using JavaScript)
          • JavaScript를 이용한 NFTs 전송(Transfer NFTs Using JavaScript)
          • JavaScript를 이용한 NFT 판매 중개(Broker an NFT Sale Using JavaScript)
          • JavaScript를 이용한 공인 발행인 지정(Assign an Authorized Minter Using JavaScript)
          • JavaScript를 이용한 NFTs 일괄 발행(Batch Mint NFTs Using JavaScript)
      • JavaScript를 이용한 브라우저 지갑 개발(Build a Browser Wallet in JavaScript)
      • JavaScript를 이용한 데스크탑 지갑 개발(Build a Desktop Wallet in JavaScript)
    • Java
      • Java로 시작하기(Get Started Using Java)
    • HTTP / Websocket APIs
      • HTTP/WebSocket API 사용 시작하기(Get Started Using HTTP / WebSocket APIs)
      • WebSocket으로 수신 결제 모니터링(Monitor Incoming Payments with WebSocket)
    • Tasks
      • 계정 설정 관리(Manage Account Settings)
        • 일반 키 쌍 할당
        • 일반 키 쌍 변경 또는 제거
        • 마스터 키 쌍 비활성화
        • 다중 서명 설정
        • 다중 서명 트랜잭션 전송
        • 데스티네이션 태그 필요
        • 오프라인 계정 설정 튜토리얼
        • 티켓 사용(Use Tickets)
      • XRP 보내기(Send XRP)
      • 특수 결제 유형 사용(Use Specialized Payment Types)
        • 에스크로 사용(Use escrow)
          • 시간 보류 에스크로 보내기(Send a Time-Held Escrow)
          • 조건부 보류 에스크로 보내기(Send a Conditionally-Held Escrow)
          • 만료된 에스크로 취소(Cancel an Expired Escrow)
          • 에스크로 조회(Look up Escrows)
          • 에스크로를 스마트 컨트랙트로 사용(Use an Escrow as a Smart Contract)
        • 결제 채널 사용(Use Payment Channels)
          • 결제 채널을 열어 거래소 간 네트워크 활성화(Open a Payment Channel to Enable an Inter-Exchange Network)
        • 수표 사용(Use Checks)
          • 수표 전송(Send a Check)
          • 정확한 금액의 수표 현금화(Cash a Check for an Exact Amount)
          • 유연한 금액의 수표 현금화(Cash a Check for a Flexible Amount)
          • 수표 취소(Cancel a Check)
          • 발신자별 수표 조회(Look Up Checks by Sender)
          • 수취인별 수표 조회(Look Up Checks by Recipient)
      • 토큰 사용(Use Tokens)
        • 대체가능한 토큰 발행(Issue a Fungible Token)
        • 탈중앙화 거래소에서 거래(Trade in the Decentralized Exchange)
        • 동결 금지 활성화
        • 글로벌 동결 시행
        • 신뢰선 동결하기
    • Apps 구축
      • JS에서 데스크톱 지갑 구축
      • JS에서 브라우저 지갑 구축
    • XRP Ledger 비즈니스
      • XRP 차트에 거래소 등록하기
      • 스테이블코인 발행자 되기
    • rippled 서버 관리
      • rippled 설치
        • 시스템 요구 사항
        • CentOS/Red Hat에 yum으로 설치하기
        • 우분투 또는 데비안 리눅스에 설치
        • 리눅스에서 자동 업데이트
        • CentOS/Red Hat에서 수동 업데이트
        • 우분투 또는 데비안에서 수동 업데이트
        • 리포팅 모드에서 rippled 빌드 및 실행
        • 용량 계획
        • rippled v1.3.x 마이그레이션 지침
      • rippled 구성
        • rippled를 검증인으로 실행하기
        • rippled를 스톡 서버로 실행
        • 수정안 투표 구성
        • 수정안 테스트
        • StatsD 구성
        • rippled를 병렬 네트워크에 연결하기
        • 온라인 삭제 구성
        • 권고 삭제 구성
        • 히스토리 샤딩 구성
        • 전체 히스토리 구성
        • gRPC 구성
        • 공개 서명 사용
      • 피어링 구성
        • 클러스터 rippled 서버
        • 비공개 서버 구성
        • 피어 크롤러 구성
        • 링크 압축 사용
        • 피어링을 위한 포트 포워드
        • 특정 피어에 수동으로 연결
        • 최대 피어 수 설정
        • 피어 예약 사용
      • stand-alone 모드에서 rippled 기능 테스트하기
        • stand-alone 모드에서 새 제네시스 ledger 시작하기
        • stand-alone 모드에서 저장된 ledger 불러오기
        • stand-alone 모드에서 ledger 진행하기
      • 문제 해결
        • rippled 문제 진단하기
        • 상태 확인 개입
        • 로그 메시지 이해
        • rippled 서버가 동기화되지 않음
        • rippled 서버가 수정이 차단됨
        • rippled 서버가 시작되지 않음
        • SQLite 트랜잭션 데이터베이스 페이지 크기 문제 해결
    • 클리오 서버 관리
      • 우분투 리눅스에 클리오 설치
  • References
    • XRP Ledger 프로토콜 참조(XRP Ledger Protocol Reference)
      • 기본 데이터 유형(Basic Data Types)
        • base58 인코딩(base58 Encodings)
        • 화폐 형식(Currency Formats)
        • NFToken
      • Ledger 데이터 형식(Ledger Data Formats)
        • Ledger 헤더(Ledger Header)
        • Ledger 객체 IDs
        • Ledger 객체 유형
          • AccountRoot
          • Amendments
          • AMM(experimental - 수정중)
          • Check
          • DepositPreauth
          • DirectoryNode
          • Escrow
          • FeeSettings
          • LedgerHashes
          • NegativeUNL
          • NFTokenOffer
          • NFTokenPage
          • Offer
          • PayChannel
          • RippleState
          • SignerList
          • Ticket
      • 트랜잭션 참조(Transaction Reference)
        • 트랜잭션 공통 필드(Transaction Common Fields)
        • 트랜잭션 유형(Transaction Types)
          • AccountSet
          • AccountDelete
          • AMMBid
          • AMMCreate
          • AMMDelete
          • AMMDeposit
          • CheckCancel
          • CheckCash
          • CheckCreate
          • DepositPreauth
          • EscrowCancel
          • EscrowCreate
          • EscrowFinish
          • NFTokenAcceptOffer
          • NFTokenBurn
          • NFTokenCancelOffer
          • NFTokenCreateOffer
          • NFTokenMint
          • OfferCancel
          • OfferCreate
          • Payment
          • PaymentChannelClaim
          • PaymentChannelCreate
          • PaymentChannelFund
          • SetRegularKey
          • SignerListSet
          • TicketCreate
          • TrustSet
        • Pseudo-Transactions
          • EnableAmendment
          • SetFee
          • UNLModify
        • 트랜잭션 결과(Transaction Results)
          • tec Codes
          • tef Codes
          • tel Codes
          • tem Codes
          • ter Codes
          • tes Success
        • 트랜잭션 메타데이터(Transaction Metadata)
      • Binary Format
    • 클라이언트 라이브러리
      • JavaScript / TypeScript 클라이언트 라이브러
        • ripple-lib 1.x에서 xrpl.js 2.x로의 마이그레이션 가이드
      • Python 클라이언트 라이브러리
      • Java 클라이언트 라이브러리
      • Ruby 클라이언트 라이브러리
    • HTTP / WebSocket APIs
      • API 규칙
        • 요청 형식
        • 응답 형식
        • 오류 형식
        • 마커 및 페이지네이션
        • 속도 제한
        • rippled 서버 상태
      • 공개 API 메소드
        • 계정 메소드
          • account_channels
          • account_currencies
          • account_info
          • account_lines
          • account_nfts
          • account_objects
          • account_offers
          • account_tx
          • gateway_balances
          • noripple_check
        • Ledger 메소드
          • ledger
          • ledger_closed
          • ledger_current
          • ledger_data
          • ledger_entry
        • 트랜잭션 메소드
          • submit
          • submit_multisigned
          • transaction_entry
          • tx
          • tx_history
        • 경로와 오더북 메소드
          • book_offers
          • deposit_authorized
          • nft_buy_offers
          • nft_sell_offers
          • path_find
          • ripple_path_find
        • 결제 채널 메소드
          • channel_authorize
          • channel_verify
        • 구독 메소드
          • 구독
          • 구독 취소
        • Server Info 메소드
          • fee
          • manifest
          • server_info (rippled)
          • server_state
        • 클리오 서버
          • server_info
          • ledger
          • nft_history
          • nft_info
        • 유틸리티 메소드
          • json
          • ping
          • random
      • 관리자 API 메소드
        • 키 생성 방법
          • validation_create
          • wallet_propose
        • 로깅 및 데이터 관리 메소드
          • can_delete
          • crawl_shards
          • download_shard
          • ledger_cleaner
          • ledger_request
          • log_level
          • logrotate
          • node_to_shard
        • 서버 컨트롤 메소드
          • ledger_accept
          • stop
          • validation_seed
        • 서명 메소드
          • sign
          • sign_for
        • 피어 관리 메소드
          • connect
          • peer_reservations_add
          • peer_reservations_del
          • peer_reservations_list
          • peers
        • 상태 및 디버깅 메소드
          • consensus_info
          • feature
          • fetch_info
          • get_counts
          • print
          • validator_info
          • validators
        • rippled 커맨드라인 사용 참조
        • 피어 포트 메소드
          • 상태 확인
          • 피어 크롤러
          • 유효성 검증인 목록 메소드
    • xrp-ledger.toml File
  • Infrastructure
    • 커맨드 라인 사용법(Commandline Usage)
    • Install rippled
      • System Requirements
      • Install on CentOS/RedHat with yum
      • Install on Ubuntu or Debian Linux
      • Update Automatically on Linux
      • Update Manually on CentOS/Red Hat
      • Update Manually on Ubuntu or Debian
      • Build and Run rippled in Reporting Mode
      • Capacity Planning
    • Configure rippled
      • Server Modes
        • Run rippled as a Validator
        • Run rippled as a Stock Server
      • Data Retention
        • Configure Full History
        • 온라인 삭제(Online Deletion)
        • Configure Online Deletion
        • Configure Advisory Deletion
        • 히스토리 샤딩(History Sharding)
        • Configure History Sharding
      • Configure Amendment Voting
      • Test Amendments
      • Configure StatsD
      • Connect Your rippled to a Parallel Network
      • Configure gRPC
      • Enable Public Signing
    • Peering
      • Cluster rippled Servers
      • Configure a Private Server
      • Configure the Peer Crawler
      • Enable Link Compression
      • Forward Ports for Peering
      • Manually Connect to a Specific Peer
      • Set Maximum Number of Peers
      • Use a Peer Reservation
    • Testing and Auditing
      • Start a New Genesis Ledger in Stand-Alone Mode
      • Load a Saved Ledger in Stand-Alone Mode
      • Advance the Ledger in Stand-Alone Mode
    • Troubleshooting
      • Diagnosing Problems with rippled
      • Health Check Interventions
      • Understanding Log Messages
      • rippled Server Doesn't Sync
      • rippled Server is Amendment Blocked
      • rippled Server Won't Start
    • Install Clio on Ubuntu Linux
    • Run a Private Network with Docker
Powered by GitBook
On this page
  • 학습 목표(Learning Goals)
  • 요구 사항(Requirements)
  • 설치(Installation)
  • 개발 시작(Start Building)
  • 1. XRP Ledger에 연결하기(Connect to the XRP Ledge)
  • 제작용 XRP Ledger에 연결 (Connect to the production XRP Ledger)
  • 2. 계정 가져오기(Get account)
  • XRP Ledger 쿼리(Query the XRP Ledger)
  • 4. 모든 것을 함께 사용하기(Putting it all together)
  • 응답 해석하기(Interpreting the response)
  • 계속 만들기(Keep on building)
  1. Tutorials
  2. Java

Java로 시작하기(Get Started Using Java)

이 튜토리얼에서는 XRP Ledger에 연결된 애플리케이션을 구축하는 기본 사항에 대해 안내하며, 이를 위해 XRP Ledger와 상호 작용하기 위해 만들어진 순수 Java 라이브러리인 xrpl4j를 사용합니다.

이 튜토리얼에서는 초보자를 대상으로 하며 완료하는데 30분 이상 걸리지 않아야 합니다.

학습 목표(Learning Goals)

이 튜토리얼에서 다음을 배울 수 있습니다:

  • XRP Ledger 기반 응용 프로그램의 기본 구성 요소.

  • xrpl4j를 사용하여 XRP Ledger에 연결하는 방법.

  • xrpl4j를 사용하여 Testnet에서 계정을 얻는 방법.

  • XRP Ledger에 있는 계정에 대한 정보를 조회하는 데 xrpl4j 라이브러리를 사용하는 방법.

  • 이러한 단계를 모두 결합하여 Java 앱을 생성하는 방법.

요구 사항(Requirements)

  • xrpl4j 라이브러리는 Java 1.8 이상을 지원합니다.

  • 프로젝트 관리 도구로는 Maven 또는 Gradle이 필요합니다.

설치(Installation)

xrpl4j 라이브러리는 Maven Central에서 사용할 수 있습니다. xrpl4j는 필요에 따라 가져올 수 있는 여러 요소소로 나뉩니다.

이 자습서에서는 xrpl4j-client, xrpl4j-address-codec, xrpl4j-keypairs 및 xrpl4j-model 모듈이 필요합니다.

Maven으로 설치하려면 프로젝트의 pom.xml 파일에 다음을 추가하고 mvn install을 실행하세요:

<dependencies>
    <dependency>
      <groupId>org.xrpl</groupId>
      <artifactId>xrpl4j-core</artifactId>
      <version>3.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.xrpl</groupId>
      <artifactId>xrpl4j-client</artifactId>
      <version>3.0.1</version>
    </dependency>
</dependencies>
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.xrpl</groupId>
      <artifactId>xrpl4j-bom</artifactId>
      <version>3.0.1</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

이 튜토리얼에서의 코드를 포함하는 전체 Maven 프로젝트인 xrpl4j 샘플 프로젝트를 확인하세요.

개발 시작(Start Building)

XRP Ledger에서 작업할 때는 계정에 XRP를 추가하거나, 탈중앙화 거래소와 통합하거나, 토큰을 발행하는 등의 작업을 관리해야 합니다. 이 자습서에서는 이러한 모든 사용 사례를 시작하는 데 공통적인 기본 패턴에 대해 안내하고 이를 구현하는 샘플 코드를 제공합니다.

거의 모든 XRP Ledger 프로젝트에서 다루어야 할 기본 단계는 다음과 같습니다:

  1. XRP Ledger에 연결하기.

  2. 계정 얻기.

  3. XRP Ledger 조회하기.

1. XRP Ledger에 연결하기(Connect to the XRP Ledge)

조회를 수행하고 트랜잭션을 제출하려면 XRP Ledger에 연결해야 합니다. xrpl4j를 사용하여 이를 수행하려면 XrplClient를 사용할 수 있습니다:

// Construct a network client
HttpUrl rippledUrl = HttpUrl.get("https://s.altnet.rippletest.net:51234/");
System.out.println("Constructing an XrplClient connected to " + rippledUrl);
XrplClient xrplClient = new XrplClient(rippledUrl);

제작용 XRP Ledger에 연결 (Connect to the production XRP Ledger)

이전 섹션의 샘플 코드는 돈이 실제 가치가 없는 테스트를 위한 병렬 네트워크인 Testnet에 연결하는 방법을 보여줍니다. 제작용 XRP Ledger과 통합할 준비가 되면 Mainnet에 연결해야 합니다. 두 가지 방법으로 할 수 있습니다:

  • 핵심 서버(rippled)를 설치하고 노드를 직접 실행합니다. 핵심 서버는 기본적으로 Mainnet에 연결하지만, 구성을 변경하여 Testnet 또는 Devnet을 사용할 수 있습니다. 자체 핵심 서버를 실행하는 좋은 이유가 있습니다. 자체 서버를 실행하면 다음과 같이 연결할 수 있습니다:

final HttpUrl rippledUrl = HttpUrl.get("http://localhost:5005/");
XrplClient xrplClient = new XrplClient(rippledUrl);

기본 값에 대한 자세한 정보는 예제 핵심 서버 구성 파일을 참조하십시오.

  • 사용 가능한 공개 서버 중 하나를 사용하여:

final HttpUrl rippledUrl = HttpUrl.get("https://s2.ripple.com:51234/");
XrplClient xrplClient = new XrplClient(rippledUrl);

2. 계정 가져오기(Get account)

XRP Ledger에서 값을 저장하고 트랜잭션을 실행하려면, 키 세트와 주소가 있는 계정이 필요합니다. 이 계정은 충분한 XRP로 자금이 지원되어야 합니다, 이를 계정 reserve라 합니다. 주소는 계정의 식별자이며, XRP Ledger에 제출하는 트랜잭션에 서명하기 위해 개인 키를 사용합니다. 제작용으로 사용한다면 키를 저장하고 안전한 서명 방법을 설정하는데 주의를 기울여야 합니다.

새 계정을 생성하려면, xrpl4j에서 DefaultWalletFactory를 제공합니다.

// Create a random KeyPair
KeyPair randomKeyPair = Seed.ed25519Seed().deriveKeyPair();
System.out.println("Generated KeyPair: " + randomKeyPair);

walletFactory.randomWallet(true).wallet()을 호출하면 Wallet 인스턴스가 반환됩니다:

System.out.println(testWallet);

// print output
Wallet {
    privateKey= -HIDDEN-,
    publicKey=ED90635A6F2A5905D3D5CD2C14905FFB2D838185993576CA4CEE24A920D0D6BD6B,
    classicAddress=raj5eirfEpbN9YzG9FzB8ZPNyjpFvH6ycV,
    xAddress=T76mQFr9zLGi2LCjVDgJ7mEQCk4767SdEL32mZFygpdGcFf,
    isTest=true
}

테스트와 개발 목적으로, XRP Ledger Testnet에 연결된 FaucetClient를 사용할 수 있습니다:

// Fund the account using the testnet Faucet
FaucetClient faucetClient = FaucetClient.construct(HttpUrl.get("https://faucet.altnet.rippletest.net"));
faucetClient.fundAccount(FundAccountRequest.of(classicAddress));
System.out.println("Funded the account using the Testnet faucet.");

XRP Ledger 쿼리(Query the XRP Ledger)

특정 계정, 특정 거래, 현재 또는 과거의 ledger 상태, 그리고 XRP Ledger의 분산형 거래소에 대한 정보를 얻기 위해 XRP Ledger를 쿼리할 수 있습니다. 이러한 쿼리를 실행하는 이유 중 하나는, 신뢰할 수 있는 거래 제출에 따른 최상의 방법을 준수하기 위해 계정 정보를 찾아보는 것입니다.

여기서는 이전 단계에서 얻은 계정 정보를 조회하기 위해 우리가 구성한 XrplClient를 사용하겠습니다.

// Look up your Account Info
AccountInfoRequestParams requestParams = AccountInfoRequestParams.of(classicAddress);
AccountInfoResult accountInfoResult = xrplClient.accountInfo(requestParams);

4. 모든 것을 함께 사용하기(Putting it all together)

이러한 구성 요소들을 사용하여, 우리는 다음과 같은 기능을 하는 Java 앱을 생성할 수 있습니다:

  1. Testnet에서 계정을 가져옵니다.

  2. XRP Ledger에 연결합니다.

  3. 생성한 계정에 대한 정보를 조회하고 출력합니다.

// Construct a network client
HttpUrl rippledUrl = HttpUrl.get("https://s.altnet.rippletest.net:51234/");
System.out.println("Constructing an XrplClient connected to " + rippledUrl);
XrplClient xrplClient = new XrplClient(rippledUrl);

// Create a random KeyPair
KeyPair randomKeyPair = Seed.ed25519Seed().deriveKeyPair();
System.out.println("Generated KeyPair: " + randomKeyPair);

// Derive the Classic and X-Addresses from testWallet
Address classicAddress = randomKeyPair.publicKey().deriveAddress();
XAddress xAddress = AddressCodec.getInstance().classicAddressToXAddress(classicAddress, true);
System.out.println("Classic Address: " + classicAddress);
System.out.println("X-Address: " + xAddress);

// Fund the account using the testnet Faucet
FaucetClient faucetClient = FaucetClient.construct(HttpUrl.get("https://faucet.altnet.rippletest.net"));
faucetClient.fundAccount(FundAccountRequest.of(classicAddress));
System.out.println("Funded the account using the Testnet faucet.");

// Look up your Account Info
AccountInfoRequestParams requestParams = AccountInfoRequestParams.of(classicAddress);
AccountInfoResult accountInfoResult = xrplClient.accountInfo(requestParams);

// Print the result
System.out.println(accountInfoResult);

앱을 실행하려면 Github에서 코드를 다운로드하고 IDE나 커맨드 라인에서 GetAccountInfo를 실행하면 됩니다.

git clone https://github.com/XRPLF/xrpl4j-sample.git
cd xrpl4j-sample
mvn compile exec:java -Dexec.mainClass="org.xrpl.xrpl4j.samples.GetAccountInfo"

이렇게 실행하면 아래와 비슷한 출력을 볼 수 있습니다:

Running the GetAccountInfo sample...
Constructing an XrplClient connected to https://s.altnet.rippletest.net:51234/
Generated KeyPair: KeyPair{
  privateKey=PrivateKey{value=[redacted], destroyed=false}, 
  publicKey=PublicKey{value=UnsignedByteArray{unsignedBytes=List(size=33)}, 
  base58Value=aKGgrZL2WTc85HJSkQGuKfinem5oMH1uCJankSWFATGUhqvygxir, 
  base16Value=EDFB1073327CCBDA342AD685AF1C04530294866B9CB10C21126DC004BFDBA287D1, 
  keyType=ED25519
  }
}
Classic Address: rBXHGshqXu3Smy9FUsQTmo49bGpQUQEm3X
X-Address: T7yMiiJJCmgY2yg5WB2davUedDeBFAG5B8r9KHjKCxDdvv3
Funded the account using the Testnet faucet.
AccountInfoResult{
  status=success, 
  accountData=AccountRootObject{
    ledgerEntryType=ACCOUNT_ROOT, 
    account=rDNwS2t4afhBogKqSFFmsDi1k7gmeGhz4p, 
    balance=10000000000, 
    flags=0, 
    ownerCount=0,
    previousTransactionId=0000000000000000000000000000000000000000000000000000000000000000, 
    previousTransactionLedgerSequence=0, 
    sequence=37649083, 
    signerLists=[],
    index=F607809578C2A413774B9A240480B8B7B10C3E296CA609337D2F41813F566B92
  }, 
  ledgerCurrentIndex=37649083, 
  validated=false
}

응답 해석하기(Interpreting the response)

대부분의 경우, AccountInfoResult에 포함된 응답 필드 중 주로 검사하고자 하는 것은 다음과 같습니다:

  • accountData.sequence — 이것은 계정에 대한 다음 유효한 트랜잭션의 시퀀스 번호입니다. 트랜잭션을 준비할 때 이 시퀀스 번호를 명시해야 합니다.

  • accountData.balance — 이것은 계정의 XRP 잔액으로, 드랍 단위로 표시됩니다. 이를 사용하여 (결제를 하려는 경우) 충분한 XRP를 보유하고 있는지, 그리고 주어진 트랜잭션에 대한 현재 거래 비용을 충족시키는지 확인할 수 있습니다.

  • validated — 반환된 데이터가 유효한 렛저로부터 가져온 것인지를 나타냅니다. 트랜잭션을 검사할 때, 결과가 확정적인 것인지를 확인한 후에 트랜잭션을 추가로 처리하는 것이 중요합니다. validated가 true라면 결과가 변하지 않을 것임을 확실히 알 수 있습니다. 트랜잭션 처리에 대한 모범 사례에 대한 자세한 정보는 Reliable Transaction Submission을 참조하십시오.

모든 응답 필드에 대한 자세한 설명은 account_info를 참조하십시오.

계속 만들기(Keep on building)

이제 xrpl-py를 사용하여 XRP Ledger에 연결하고, 계정을 가져오고, 그 정보를 조회하는 방법을 알았으니, xrpl-py를 이용하여 다음 작업도 수행할 수 있습니다:

  • XRP 보내기

  • 계정에 대한 안전한 서명 설정하기

PreviousJavaNextHTTP / Websocket APIs

Last updated 1 year ago