XRP 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 28쪽 중 3쪽

ment purposes, you can use the fundWallet() helper function on the XRP Ledger Testnet : ? php // Use the Composer autoloader require __DIR__ . '/vendor/autoload.php' ; // Imports use XRPL_PHP\Client\JsonRpcClient ; use XRPL_PHP\Models\Account\AccountInfoRequest ; use XRPL_PHP\Wallet\Wallet ; use function XRPL_PHP\Sugar\fundWallet ; // Create a client using the Testnet $client = new JsonRpcClient ( "https://s.altnet.rippletest.net:51234" ); // Create a new wallet $wallet = Wallet :: generate (); // Fund (and activate) the wallet fundWallet ($client, $wallet); 3. Query the XRP Ledger You can query the XRP Ledger to get information about a specific account , a specific transaction , the state of a current or a historical ledger , and the XRP Ledger's decentralized exchange . You need to make these queries, among other reasons, to look up account info to follow best practices for reliable transaction submission . Here, we'll use the JsonRpcClient we constructed to look up information about the account we got in the previous step. // Create an AccountInfoRequest method $accountInfoRequest = new AccountInfoRequest ( account : $wallet -> getAddress (), ledgerIndex : 'validated' ); // Send the request to the XRPL $accountInfoResponse = $client -> syncRequest ($accountInfoRequest); // Print formatted response print_r ($accountInfoResponse); 4. Starting the script Now, we have a simple application that: Creates an account on the Testnet. Connects to the XRP Ledger. Looks up and prints information about the account you created. To run the app, you can copy the code from this website's GitHub Repository and run it from the command line: composer require hardcastle/xrpl_php php get-account-info.php You should see output similar to this example: XRPL_PHP\Models\Account\AccountInfoResponse Object ( [id:protected] => [result:protected] => Array ( [account_data] => Array ( [Account] => rDTRjR6sWrRmGe18KMVwBuL212gLpArVLy [Balance] => 10000000000 [Flags] => 0 [LedgerEntryType] => AccountRoot [OwnerCount] => 0 [PreviousTxnID] => AE18C0B30DE740490E66E92D9F45162C8860A6D9FCF279CF7A51FAFE05F573FB [PreviousTxnLgrSeq] => 42719256 [Sequence] => 42719256 [index] => 4DD9F7FAE7365B7A917932D6453DBA9B223AA4FF7193691EF6E5EE230519F4CA ) [account_flags] => Array ( [defaultRipple] => [depositAuth] => [disableMasterKey] => [disallowIncomingCheck] => [disallowIncomingNFTokenOffer] => [disallowIncomingPayChan] => [disallowIncomingTrustline] => [disallowIncomingXRP] => [globalFreeze] => [noFreeze] => [passwordSpent] => [requireAuthorization] => [requireDestinationTag] => ) [ledger_hash] => 57F0CB8311CDEAE9AC60854CC482990CE971D1FD36DB1CC215B7A6634E27E739 [ledger_index] => 42719256 [status] => success [validated] => 1 ) [warnings:protected] => [status:protected] => success [type:protected] => response ) Interpreting the response The response fields contained in AccountInfoResponse that you want to inspect in most cases are: ['account_data']['Sequence'] — This is the sequence number of the next valid transaction for the account. You need to specify the sequence number when you prepare transactions. ['account_data']['Balance'] — This is the account's balance of XRP, in drops. You can use this to confirm that you have enough XRP to send (if you're making a payment) and to meet the current transaction cost for a given transaction. ['validated'] — Indicates whether the returned data is from a validated ledger . When inspecting transactions, it's important to confirm that the results are final before further processing the transaction. If validated is true then you know for sure the results won't change. For more information about best practices for transaction processing, see Reliable Transaction Submission . For a detailed description of every response field, see account_info . Keep on building Now that you know how to use XRPL_PHP to connect to the XRP Ledger, get an account, and look up information about it, you can also use XRPL_PHP to: Send XRP . Set up secure signing for your account. ## /docs/tutorials/get-started/get-started-go Get Started Using Go Library Copy This tutorial walks you through the basics of building an XRP Ledger-connected application using xrpl-go , a pure Go library built to interact with the XRP Ledger. This tutorial is intended for beginners and should take no longer than 30 minutes to complete. Learning Goals In this tutorial, you'll learn: The basic building blocks of XRP Ledger-based applications. How to connect to the XRP Ledger using xrpl-go . How to get an account on the Testnet using xrpl-go . How to use the xrpl-go library to look up information about an account on the XRP Ledger. Requirements To follow this tutorial, you should have Go version 1.25.13 or later installed. Download latest Go version . Installation The xrpl-go library is available on pkg.go.dev . Start a new project (or use an existing one) and install the xrpl-go library via Go modules: # Initialize your module (if you haven't already) go mod init your-module-name # Fetch the latest version of xrpl-go go get github.com/Peersyst/xrpl-go@latest Start Building When you're working with the XRP Ledger, there are a few things you'll need to manage, whether you're adding XRP to your account , integrating with the decentralized exchange , or issuing tokens . This tutorial walks you through basic patterns common to getting started with all of these use cases and provides sample code for implementing them. Here are the basic steps you'll need to cover for almost any XRP Ledger project: Connect to the XRP Ledger. Get an account. Query the XRP Ledger. 1. Connect to the XRP Ledger To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with xrpl-go , you have two main options: Via WebSocket: func main () { // Define the network client client := websocket. NewClient (websocket. NewClientConfig (). WithHost ( "wss://s.altnet.rippletest.net:51233" ). WithFaucetProvider (faucet. NewTestnetFaucetProvider ()), ) // Disconnect the client when done. (Defer executes at the end of the function) defer client. Disconnect () // Connect to the network if err := client. Connect (); err != nil { panic (err) } // ... custom code goes here } Via RPC: func main () { // Define the network client configuration cfg, err := rpc. NewClientConfig ( "https://s.altnet.rippletest.net:51234/" , rpc. WithFaucetProvider (faucet. NewTestnetFaucetProvider ()), ) if err != nil { panic (err) } // Initiate the network client client := rpc. NewClient (cfg) // Ping the network (used to avoid Go unused variable error, but useful to check connectivity) _, err = client. Ping ( & utility . PingRequest {}) if err != nil { panic (err) } // ... custom code goes here } Connect to the production XRP Ledger The sample code in the previous section shows you how to connect to the Testnet, which is a parallel network for testing where the money has no real value. When you're ready to integrate with the production XRP Ledger, you'll need to connect to the Mainnet. You can do that in two ways: By installing the core server ( xrpld ) and running a node yourself. The core server connects to the Mainnet by default, but you can change the configuration to use Testnet or Devnet . There are good reasons to run your own core server . If you run your own server, you can connect to it like so: import " github.com/Peersyst/xrpl-go/xrpl/websocket " const MY_SERVER = "ws://localhost:6006/" func main () { client := websocket. NewClient (websocket. NewClientConfig (). WithHost (MY_SERVER)) // ... custom code goes here } See the example core server config file for more information about default values. By using one of the available public servers : import " github.com/Peersyst/xrpl-go/xrpl/websocket " const PUBLIC_SERVER = "wss://xrplcluster.com/" func main () { client := websocket. NewClient (websocket. NewClientConfig (). WithHost (PUBLIC_SERVER)) // ... custom code goes here } 2. Get account In xrpl-go , account creation and key management live in the wallet package, and on Testnet you can use the built-in faucet provider on your WebSocket (or RPC) client to fund a brand-new account immediately. On Testnet, you can fund a new ED25519 account like this: w, err := wallet. New (crypto. ED25519 ()) if err != nil { fmt. Println (err) return } if err := client. FundWallet ( & w); err != nil { fmt. Println (err) return } This constructor returns a Go Wallet value with the following fields: type Wallet struct { PublicKey string // the hex-encoded public key PrivateKey string // the hex-encoded private key ClassicAddress types . Address // the XRPL “r…” address Seed string // the base58 seed } If you already have a seed encoded in base58 , you can make a Wallet instance from it like this: w, err := wallet. FromSeed ( "sn3nxiW7v8KXzPzAqzyHXbSSKNuN9" , "" ) 3. Query the XRP Ledger You can query the XRP Ledger to get information about a specific account , a specific transaction , the state of a current or a historical ledger , and the XRP Ledger's decentralized exchange . You need to make these queries, among other reasons, to look up account info to follow best practices for reliable transaction submission . Use the Client's Request() method to access the XRP Ledger's WebSocket API . For example: // Get the latest validated ledger led, err := client. GetLedger ( & ledger . Request { Transactions: true , LedgerIndex: common.Validated, }) if err != nil { panic (err) } fmt. Println ( "Latest validated ledger:" , led) // Get the first transaction hash from the ledger if len (led.Ledger.Transactions) > 0 { txHash := led.Ledger.Transactions[ 0 ].( string ) // type assertion may be needed // Query the transaction details txResp, err := client. Request ( & transactions . TxRequest { Transaction: txHash, }) if err != nil { panic (err) } fmt. Println ( "First transaction in the ledger:" ) fmt. Println (txResp) } } Or, use the getter methods from the websocket or rpc packages: // Get info from the ledger about the address we just funded acc_info, err := client. GetAccountInfo ( & account . InfoRequest { Account: w. GetAddress (), }) if err != nil { panic (err) } fmt. Println ( "Account Balance:" , acc_info.AccountData.Balance) fmt. Println ( "Account Sequence:" , acc_info.AccountData.Sequence) Keep on Building Now that you know how to use xrpl-go to connect to the XRP Ledger, get an account, and look up information about it, you can also: Send XRP . ## /docs/use-cases/payments RLUSD Ripple's enterprise-grade stablecoin, is live on XRPL and fully backed by USD deposits. Built for institutions, it enables fast, compliant, low-cost cross-border payments. RLUSD ## /docs/concepts/payment-types/direct-xrp-payments Direct XRP Payments Copy The basis of any financial system is transferring value. The quickest and simplest method on the XRP Ledger is a direct XRP payment from one account to another. Unlike other payment methods that require multiple transactions to complete, a direct XRP payment executes in one transaction with no intermediaries, and typically completes in 8 seconds or less. You can only make direct payments when XRP is the currency sent and received. Direct XRP Payment Lifecycle The sender creates a Payment transaction , which defines the parameters of the payment. The transaction is a direct XRP payment if XRP is the currency sent and received. Transaction processing checks the parameters and circumstances of the transaction; if any check fails, the payment fails. All fields are formatted correctly. The sending address is a funded account in the XRP Ledger. All provided signatures are valid for the sending address. The destination address is different than the sending address. The sender has a high enough XRP balance to send the payment. Transaction processing checks the receiving address; if any check fails, the payment fails. If the receiving address is funded, the engine makes additional checks based on their settings, such as Deposit Authorization . If the receiving address isn't funded, it checks if the payment will deliver enough XRP to meet the minimum account reserve requirement. If the reserve is met, a new account is created for the address and its starting balance is the amount received. The ledger debits and credits the corresponding accounts. Note The sender is also debited the XRP transaction cost . See Also Tutorials: Send XRP (Interactive Tutorial) Monitor Incoming Payments with WebSocket References: Payment transaction Transaction Results account_info method - for checking XRP balances ## /docs/concepts/payment-types/cross-currency-payments Cross-Currency Payments Copy The XRP Ledger enables you to make cross-currency payments of XRP and tokens. Cross-currency payments within the XRP Ledger are fully atomic, meaning the payment fully executes or no part of the payment executes at all. By default, cross-currency payments deliver a fixed amount to their destination at a variable cost to their source. Cross-currency payments can also be partial payments that deliver a variable amount within a set sending limit. Prerequisites By definition, a cross-currency payment involves at least two currencies, which means that at least one currency involved must be a non-XRP token . There must be at least one Path between the sender and receiver, and the total liquidity across all paths must be enough to execute the payment. Cross-currency payments convert from one currency to another by consuming Offers in the XRP Ledger's decentralized exchange . Auto-Bridging Cross-currency payments that exchange one token for another token can automatically use XRP to bridge the tokens, when it decreases the cost of the payment. For example, a payment sending from USD to MXN automatically converts USD to XRP and then XRP to MXN if doing so is cheaper than converting USD to MXN directly. Larger trades can use a combination of direct (USD-MXN) and auto-bridged (USD-XRP-MXN) conversions. For more information, see Auto-Bridging . See Also Concepts: Tokens Decentralized Exchange Paths References: Payment transaction type path_find method ripple_path_find method Interpreting Metadata of Cross-Currency Payments ## /docs/concepts/payment-types/escrow Escrow Copy Traditionally, an escrow is a contract between two parties to facilitate financial transactions. An impartial third party receives and holds funds, and only releases them to the intended recipient when conditions specified by the contract are met. This method ensures both parties meet their obligations. The XRP Ledger takes escrow a step further, replacing the third party with an automated system built into the ledger. An escrow locks up XRP or fungible tokens, which can't be used or destroyed until conditions are met. Requires the TokenEscrow amendment . Loading... Token Escrow The TokenEscrow amendment extends escrow functionality to fungible tokens, which means Trust Line Tokens and Multi-Purpose Tokens (MPTs) can be held in escrow. For Trust Line Tokens to be held in escrow, the issuing account must have the Allow Trust Line Locking flag enabled, which allows tokens issued by the account to be held in escrow. For MPTs, the issuer needs to enable the Can Escrow and Can Transfer flags when creating the token issuance, so that the tokens can be held in escrow and transferred. While issuers can't create escrows with their own issued tokens, they can serve as recipients. When an issuer receives escrowed tokens, the process works the same way as a direct payment. If a token requires authorization, the sender must be pre-authorized by the issuer before creating an escrow and must also be authorized to receive the tokens back when an expired escrow is canceled, regardless of who submits the cancellation transaction. The recipient must be pre-authorized before the escrow can be finished. Types of Escrow The XRP Ledger supports three types of escrow: Time-based Escrow: Funds only become available after a certain amount of time passes. Conditional Escrow: This escrow is created with a corresponding condition and fulfillment. The condition serves as a lock on the funds and won't release until the correct fulfillment key is provided. Combination Escrow: This escrow combines the features of time-based and conditional escrow. The escrow is completely inaccessible until the specified time passes, after which the funds can be released by providing the correct fulfillment. Escrow Lifecycle The lifecycle of an escrow is as follows: The sender creates an escrow using the EscrowCreate transaction. This transaction defines: An amount of XRP or fungible tokens to lock up. The conditions to release the funds. For XRP escrows this can include a time when the escrow can complete, a cryptographic condition that must be fulfilled, and optionally a time when the escrow expires. For token escrows similar conditions apply, but an expiration time is mandatory . The recipient of the funds. Any applicable transfer rates or fees are captured at creation time and will apply when the escrow completes, ensuring predictability for the recipient. When the transaction is processed successfully, the XRP Ledger creates an Escrow object that holds the escrowed funds. The recipient sends an EscrowFinish transaction to deliver the funds. If the conditions are met, this destroys the Escrow object and delivers the funds to the recipient. Additionally, any missing trust lines or MPT entries may be auto-created for recipients if authorization isn't required. Note If the escrow has an expiration time and isn't successfully finished before then, the escrow becomes expired. An expired escrow remains in the ledger until an EscrowCancel transaction cancels it, returning the escrowed funds to the sender. Escrow States The following diagram shows the states an Escrow can progress through: The diagram shows three different cases for three possible combinations of the escrow's "finish-after" time ( FinishAfter field), crypto-condition ( Condition field), and expiration time ( CancelAfter field): Note While XRP escrows can sometimes exist without an expiration time, token escrows must always have an expiration time ( CancelAfter field). Time-based Escrow (left): With only a finish-after time, the escrow is created in the Held state. After the specified time has passed, it becomes Ready and anyone can finish it. If the escrow has an expiration time and no one finishes it before that time passes, then the escrow becomes Expired . In the expired state, an escrow cannot be finished, and anyone can cancel it. If the escrow does not have a CancelAfter field, it never expires and cannot be canceled. Combination Escrow (center): If the escrow specifies both a crypto-condition ( Condition field) and a "finish-after" time ( FinishAfter field), the escrow is Held until its finish-after time has passed. Then it becomes Conditionally Ready , and can finish it if they supply the correct fulfillment to the crypto-condition. If the escrow has an expiration time ( CancelAfter field), and no one finishes it before that time passes, then the escrow becomes Expired . In the expired state, an escrow cannot be finished, and anyone can cancel it. If the escrow does not have a CancelAfter field, it never expires and cannot be canceled. Conditional Escrow (right): If the escrow specifies a crypto-condition ( Condition field) and not a finish-after time, the escrow becomes Conditionally Ready immediat
프로젝트로 돌아가기