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
  • 사용 방법
  • 신뢰선 생성
  • 발행된 Currency Token 보내기
  • 실전 예제
  • ripplex2-send-currency.js
  • 2.create-trustline-send-currency.html
  1. Tutorials
  2. JavaScript
  3. JavaScript 모듈형 튜토리얼(Modular Tutorials in JavaScript)
  4. JavaScript를 이용한 Send Payments(Send Payments Using JavaScript)

JavaScript를 이용한 신뢰선 생성 및 화폐 전송(Create Trust Line and Send Currency Using JavaScript)

PreviousJavaScript를 이용한 계정 생성 및 XRP 전송(Create Accounts and Send XRP Using JavaScript)Next시간 기반 에스크로 생성하기(Create Time-based Escrows Using JavaScript)

Last updated 1 year ago

이번 페이지에서 아래의 5가지를 배울 수 있습니다:

  1. 타사 계정으로 자금을 이체할 수 있도록 계정을 구성합니다.

  2. 거래에 사용할 통화 유형을 설정합니다.

  3. Standby account과 Operational account사이에 신뢰선을 생성합니다.

  4. 계정 간에 발행된 통화를 전송합니다.

  5. 모든 통화에 대한 계정 잔액을 표시합니다.

Note:

Quickstart Samples가 없다면, 이후 예제들을 시도할 수 없습니다.

사용 방법

토큰 테스트 Harness를 열고 계정을 가져옵니다:

  1. 브라우저에서 2.create-trustline-send-currency.html를 엽니다.

  2. 테스트 계정을 가져옵니다.

    1. 계정 seed가 있는 경우

      1. Seeds 필드에 계정 seed를 붙여넣습니다.

      2. Get Accounts from Seeds를 클릭합니다

    2. 계정 seed가 없는 경우

      1. Get New Standby Account를 클릭합니다.

      2. Get New Operational Account를 클릭합니다.

신뢰선 생성

계정 간 신뢰선을 생성하려면:

  1. Amount 필드에 최대 전송 한도를 입력합니다.

  2. Destination 필드에 목적지 계정 값을 입력합니다.

  3. Create Trustline을 클릭합니다.

발행된 Currency Token 보내기

신뢰선을 생성한 후에 발행된 Currency Token을 전송하려면:

  1. Amount를 입력합니다.

  2. Destination을 입력합니다.

  3. Currency 유형을 입력합니다.

  4. Send Currency를 클릭합니다.

실전 예제

ripplex2-send-currency.js

Configure Account

법정 화폐를 송금할 때, 실제 자금 이체는 XRP와 같이 동시에 이루어지지 않습니다. 화폐가 다른 화폐로 제3자에게 이전되는 경우, 원래 계정에 영향을 미치는 화폐의 평가절하가 발생할 수 있습니다. 이러한 상황을 피하기 위해 rippling으로 알려진 화폐의 이러한 상승 및 하강 평가는 기본적으로 허용되지 않습니다. 한 계좌에서 이체된 화폐는 동일한 계좌로만 다시 이체할 수 있습니다. 타사로의 화폐 전송을 활성화하려면 riffDefault 값을 true로 설정해야 합니다. 토큰 테스트 Harness에는 rippling을 활성화하거나 비활성화하는 확인란이 제공됩니다.

// *******************************************************
// **************** Configure Account ********************
// *******************************************************

async function configureAccount(type, defaultRippleSetting) {

계정 지갑을 가져옵니다.

  if (type=='standby') {
    my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  } else {
    my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
    resultField = 'operationalResultField'
  }
  results += '\nRipple Default Setting: ' + defaultRippleSetting
  resultField.value = results

트랜잭션을 준비합니다.rippleDefault인수가 true이면 asfDefaultRipple플래그를 설정합니다. 잘못된 경우 asfDefaultRipple 플래그를 지웁니다.

  let settings_tx = {}
  if (defaultRippleSetting) {
    settings_tx = {
      "TransactionType": "AccountSet",
      "Account": my_wallet.address,
      "SetFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
    } 
    results += '\n Set Default Ripple flag.' 
    } else {
      settings_tx = {
      "TransactionType": "AccountSet",
      "Account": my_wallet.address,
      "ClearFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
    }
    results += '\n Clear Default Ripple flag.' 
  }
  results += '\nSending account setting.'   
  resultField.value = results

트랜잭션의 기본값을 자동으로 입력합니다.

  const prepared = await client.autofill(settings_tx)

트랜잭션에 서명합니다.

  const signed = my_wallet.sign(prepared)

트랜잭션을 제출하고 결과를 기다립니다.

  const result = await client.submitAndWait(signed.tx_blob)

결과를 보고합니다.

  if (result.result.meta.TransactionResult == "tesSUCCESS") {
    results += '\nAccount setting succeeded.'
    document.getElementById(resultField).value = results
  } else {
    throw 'Error sending transaction: ${result}'
    results += '\nAccount setting failed.'
    resultField.value = results
  }     
  client.disconnect()
} // End of configureAccount()

Create Trust Line

신뢰선을 사용하면 두 계정이 설정된 한도까지 정의된 currency를 거래할 수 있습니다. 이를 통해 참가자들은 최대 금액에 합의된 알려진 기업 간의 모든 교환을 보장할 수 있습니다.

// *******************************************************
// ***************** Create TrustLine ********************
// *******************************************************

async function createTrustline() {
  let net = getNet()
  const client = new xrpl.Client(net)
  results = 'Connecting to ' + getNet() + '....'
  standbyResultField.value = results

  await client.connect()
  results += '\nConnected.'
  standbyResultField.value = results

standby 와 operational 지갑들을 가져옵니다.

  const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)

standby currency 필드에서 currency 코드를 캡처합니다.

  const currency_code = standbyCurrencyField.value

양식 필드에서 currency 코드 및 (제한) 금액을 캡처하여 트랜잭션을 정의합니다.

  const trustSet_tx = {
    "TransactionType": "TrustSet",
    "Account": standbyDestinationField.value,
    "LimitAmount": {
      "currency": standbyCurrencyField.value,
      "issuer": standby_wallet.address,
      "value": standbyAmountField.value
    }
  }

기본 매개 변수를 자동으로 채워 트랜잭션을 준비합니다.

  const ts_prepared = await client.autofill(trustSet_tx)

트랜잭션에 서명합니다.

  const ts_signed = operational_wallet.sign(ts_prepared)
  results += '\nCreating trust line from operational account to standby account...'
  standbyResultField.value = results

트랜잭션을 제출하고 결과를 기다립니다.

  const ts_result = await client.submitAndWait(ts_signed.tx_blob)

결과를 보고합니다.

  if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
    results += '\nTrustline established between account \n' +
      standbyDestinationField.value + ' \n and account\n' + standby_wallet.address + '.'
    standbyResultField.value = results
  } else {
    results += '\nTrustLine failed. See JavaScript console for details.'
    document.getElementById('standbyResultField').value = results     
    throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
  }
} //End of createTrustline()

Send Issued Currency

계정에서 자신의 계정으로 신뢰선을 만든 후에는 설정된 한도까지 해당 계정으로 발급된 currency 토큰을 보낼 수 있습니다.

// *******************************************************
// *************** Send Issued Currency ******************
// *******************************************************

async function sendCurrency() {

ledger와 연결합니다.

  let net = getNet()
  const client = new xrpl.Client(net)
  results = 'Connecting to ' + getNet() + '....'
  document.getElementById('standbyResultField').value = results

  await client.connect()

  results += '\nConnected.'
  standbyResultField.value = results

계정 지갑을 가져옵니다.

  const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
  const currency_code = standbyCurrencyField.value
  const issue_quantity = standbyAmountField.value

  const send_token_tx = {
    "TransactionType": "Payment",
    "Account": standby_wallet.address,
    "Amount": {
      "currency": standbyCurrencyField.value,
      "value": standbyAmountField.value,
      "issuer": standby_wallet.address
    },
    "Destination": standbyDestinationField.value
  }

기본값을 자동으로 채워 트랜잭션을 준비합니다.

  const pay_prepared = await client.autofill(send_token_tx)

트랜잭션에 서명합니다.

  const pay_signed = standby_wallet.sign(pay_prepared)
  results += 'Sending ${issue_quantity} ${currency_code} to ' +
    standbyDestinationField.value + '...'
  standbyResultField.value = results

트랜잭션을 제출하고 결과를 기다립니다.

  const pay_result = await client.submitAndWait(pay_signed.tx_blob)

결과를 보고합니다.

  if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
    results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
    standbyResultField.value = results
  } else {
    results += 'Transaction failed: See JavaScript console for details.'
    standbyResultField.value = results
    throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
  }
  standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
  operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
  getBalances()
  client.disconnect()
} // end of sendCurrency()

Get Balances

// *******************************************************
// ****************** Get Balances ***********************
// *******************************************************

async function getBalances() {

ledger와 연결합니다.

  let net = getNet()
  const client = new xrpl.Client(net)
  results = 'Connecting to ' + getNet() + '....'
  standbyResultField.value = results
  await client.connect()   
  results += '\nConnected.'
  standbyResultField.value = results

계정 지갑을 가져옵니다.

  const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)   
  results = "\nGetting standby account balances...\n"

standby account에 대한 요청을 정의하고 보낸 다음 결과를 기다립니다.

  const standby_balances = await client.request({
    command: "gateway_balances",
    account: standby_wallet.address,
    ledger_index: "validated",
    hotwallet: [operational_wallet.address]
  })

결과를 보고합니다.

  results += JSON.stringify(standby_balances.result, null, 2)
  standbyResultField.value = results

operational account에 대한 요청을 정의하고 전송한 다음 결과를 기다립니다.

  results += "\nGetting operational account balances...\n"
  const operational_balances = await client.request({
    command: "gateway_balances",
    account: operational_wallet.address,
    ledger_index: "validated"
  })

결과를 보고합니다.

  results += JSON.stringify(operational_balances.result, null, 2)
  operationalResultField.value = results

현재 XRP 잔액으로 양식을 업데이트합니다.

  operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
  standbyResultField.value = results
  standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))

ledger에서 연결을 끊습니다.

  client.disconnect()
} // End of getBalances()

Reciprocal Transactions

각 트랜잭션에 대해 operational account에 대해 접두사 oP가 있는 상호 트랜잭션이 수반됩니다. 코드 해설은 standby account의 해당 기능을 참조하십시오. getBalance() 요청은 두 계정의 잔액을 보고하기 때문에 상호 트랜잭션이 없습니다.

// *******************************************************
// ************ Create Operational TrustLine *************
// *******************************************************

async function oPcreateTrustline() {
  let net = getNet()
  const client = new xrpl.Client(net)
  results = 'Connecting to ' + getNet() + '....'
  operationalResultField.value = results

  await client.connect()
  results += '\nConnected.'
  operationalResultField.value = results

  const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
  const trustSet_tx = {
    "TransactionType": "TrustSet",
    "Account": operationalDestinationField.value,
    "LimitAmount": {
      "currency": operationalCurrencyField.value,
      "issuer": operational_wallet.address,
      "value": operationalAmountField.value
    }
  }
  const ts_prepared = await client.autofill(trustSet_tx)
  const ts_signed = standby_wallet.sign(ts_prepared)
  results += '\nCreating trust line from operational account to ' +
   operationalDestinationField.value + ' account...'
  operationalResultField.value = results
  const ts_result = await client.submitAndWait(ts_signed.tx_blob)
  if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
    results += '\nTrustline established between account \n' + operational_wallet.address +
      ' \n and account\n' + operationalDestinationField.value + '.'
    operationalResultField.value = results
  } else {
    results += '\nTrustLine failed. See JavaScript console for details.'
    operationalResultField.value = results     
    throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
  }
} //End of oPcreateTrustline

// *******************************************************
// ************* Operational Send Issued Currency ********
// *******************************************************

async function oPsendCurrency() {
  let net = getNet()
  const client = new xrpl.Client(net)
  results = 'Connecting to ' + getNet() + '....'
  operationalResultField.value = results

  await client.connect()        
  results += '\nConnected.'
  operationalResultField.value = results

  const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
  const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
  const currency_code = operationalCurrencyField.value
  const issue_quantity = operationalAmountField.value

  const send_token_tx = {
    "TransactionType": "Payment",
    "Account": operational_wallet.address,
    "Amount": {
      "currency": currency_code,
      "value": issue_quantity,
      "issuer": operational_wallet.address
    },
    "Destination": operationalDestinationField.value
  }

  const pay_prepared = await client.autofill(send_token_tx)
  const pay_signed = operational_wallet.sign(pay_prepared)
  results += 'Sending ${issue_quantity} ${currency_code} to ' +
    operationalDestinationField.value + '...'
  operationalResultField.value = results
  const pay_result = await client.submitAndWait(pay_signed.tx_blob)
  if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
    results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
    operationalResultField.value = results
  } else {
    results += 'Transaction failed: See JavaScript console for details.'
    operationalResultField.value = results
    throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
  }
  standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
  operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
  getBalances()
  client.disconnect()
} // end of oPsendCurrency()

2.create-trustline-send-currency.html

새 기능을 지원하도록 양식을 업데이트합니다.

<html>
  <head>
    <title>Token Test Harness</title>
    <link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
    <style>
       body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
       h1{font-weight: bold;}
       input, button {padding: 6px;margin-bottom: 8px;}
       button{font-weight: bold;font-family: "Work Sans", sans-serif;}
       td{vertical-align: middle;}
    </style>    
    <script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
    <script src='ripplex1-send-xrp.js'></script>
    <script src='ripplex2-send-currency.js'></script>
    <script>
      if (typeof module !== "undefined") {
        const xrpl = require('xrpl')
      }
    </script>
  </head>

<!-- ************************************************************** -->
<!-- ********************** The Form ****************************** -->
<!-- ************************************************************** -->

  <body>
    <h1>Token Test Harness</h1>
    <form id="theForm">
      Choose your ledger instance:  
      &nbsp;&nbsp;
      <input type="radio" id="tn" name="server"
        value="wss://s.altnet.rippletest.net:51233" checked>
      <label for="testnet">Testnet</label>
      &nbsp;&nbsp;
      <input type="radio" id="dn" name="server"
        value="wss://s.devnet.rippletest.net:51233">
      <label for="devnet">Devnet</label>
      <br/><br/>
      <button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
      <br/>
      <textarea id="seeds" cols="40" rows= "2"></textarea>
      <br/><br/>
      <table>
        <tr valign="top">
          <td>
            <table>
              <tr valign="top">
                <td>
                <td>
                  <button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
                  <table>
                    <tr valign="top">
                      <td align="right">
                        Standby Account
                      </td>
                      <td>
                        <input type="text" id="standbyAccountField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Public Key
                      </td>
                      <td>
                        <input type="text" id="standbyPubKeyField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Private Key
                      </td>
                      <td>
                        <input type="text" id="standbyPrivKeyField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Seed
                      </td>
                      <td>
                        <input type="text" id="standbySeedField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        XRP Balance
                      </td>
                      <td>
                        <input type="text" id="standbyBalanceField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Amount
                      </td>
                      <td>
                        <input type="text" id="standbyAmountField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Destination
                      </td>
                      <td>
                        <input type="text" id="standbyDestinationField" size="40"></input>
                        <br>
                      </td>
                    </tr>
                    <tr valign="top">
                      <td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
                      <td>
                        <input type="checkbox" id="standbyDefault" checked="true"/>
                        <label for="standbyDefault">Allow Rippling</label>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Currency
                      </td>
                      <td>
                        <input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
                      </td>
                    </tr>
                  </table>
                  <p align="left">
                    <textarea id="standbyResultField" cols="80" rows="20" ></textarea>
                  </p>
                </td>
                </td>
                <td>
                  <table>
                    <tr valign="top">
                      <td align="center" valign="top">
                        <button type="button" onClick="sendXRP()">Send XRP&#62;</button>
                        <br/><br/>
                        <button type="button" onClick="createTrustline()">Create TrustLine</button>
                        <br/>
                        <button type="button" onClick="sendCurrency()">Send Currency</button>
                        <br/>
                        <button type="button" onClick="getBalances()">Get Balances</button>
                      </td>
                    </tr>
                    </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
          <td>
            <table>
              <tr>
                <td>
                <td>
                  <table>
                    <tr>
                      <td align="center" valign="top">
                        <button type="button" onClick="oPsendXRP()">&#60; Send XRP</button>
                        <br/><br/>
                        <button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
                        <br/>
                        <button type="button" onClick="oPsendCurrency()">Send Currency</button>
                        <br/>
                        <button type="button" onClick="getBalances()">Get Balances</button>
                      </td>
                      <td valign="top" align="right">
                        <button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
                        <table>
                          <tr valign="top">
                            <td align="right">
                              Operational Account
                            </td>
                            <td>
                              <input type="text" id="operationalAccountField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Public Key
                            </td>
                            <td>
                              <input type="text" id="operationalPubKeyField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Private Key
                            </td>
                            <td>
                              <input type="text" id="operationalPrivKeyField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Seed
                            </td>
                            <td>
                              <input type="text" id="operationalSeedField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              XRP Balance
                            </td>
                            <td>
                              <input type="text" id="operationalBalanceField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Amount
                            </td>
                            <td>
                              <input type="text" id="operationalAmountField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Destination
                            </td>
                            <td>
                              <input type="text" id="operationalDestinationField" size="40"></input>
                              <br>
                            </td>
                          </tr>
                          <tr>
                            <td>
                            </td>
                            <td align="right">
                            <input type="checkbox" id="operationalDefault" checked="true"/>
                              <label for="operationalDefault">Allow Rippling</label>
                              <button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
                            </td>
                          </tr>
                          <tr>
                            <td align="right">
                              Currency
                            </td>
                            <td>
                              <input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
                            </td>
                          </tr>
                        </table>
                        <p align="right">
                          <textarea id="operationalResultField" cols="80" rows="20" ></textarea>
                        </p>
                      </td>
                      </td>
                    </tr>
                    </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </form>
  </body>
</html>

아카이브를 다운로드하여 각 샘플을 브라우저에서 시도해볼 수 있습니다.

Currency 필드에 를 입력합니다.

아카이브를 다운로드하여 각 샘플을 브라우저에서 시도해볼 수 있습니다.

Quickstart Samples
currency 코드
Quickstart Samples