XRP 백서

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

=== 'PermissionedDomain' ) { domainID = modifiedNode.CreatedNode.LedgerIndex break } } if ( ! domainID) { console. error ( "Couldn't find a created PermissionedDomain in transaction " + "metadata. This is not typical." ) client. disconnect () process. exit ( 3 ) } console. log ( 'Domain ID of created domain:' , domainID) client. disconnect () You need to know the Domain ID to modify or delete the domain, as well as when setting up a permissioned DEX or anything else that uses the permissioned domain for access. Note The sample code saves the domain owner account's address and seed, along with the configured issuer address and generated domain ID, to a JSON file for use with other sample scripts. Saving secret keys in plaintext on disk is not ideal from a security perspective, but it's acceptable for Testnet accounts with no real-world value. You should use a more robust system when working with Mainnet accounts. Other Tasks Other tasks you might do with a permissioned domain include modifying it to change the set of accepted credentials, or deleting it. The code samples below omit the redundant setup steps for these tasks, but you can see the full source code for specifics. Modify a Permissioned Domain To modify an existing domain, send a PermissionedDomainSet transaction like the one that created it, except this time you actually do specify the DomainID field. JavaScript Python // Modify a permissioned domain ----------------------------------------------- // To demonstrate updating the domain, this tutorial uses a different credential // type (issued by the same issuer, unless you modified setup.json) const credentialType = stringToHex ( "new-credential-type" ) const pDomainSet = { TransactionType: "PermissionedDomainSet" , Account: wallet.address, DomainID: domainID, AcceptedCredentials: [ { Credential: { Issuer: issuerAddress, CredentialType: credentialType } } ] } console. log ( 'Submitting transaction' , JSON . stringify (pDomainSet, null , 2 )) const response = await client. submitAndWait (pDomainSet, { wallet, autofill: true }) console. log (response) const resultCode = response.result.meta.TransactionResult if (resultCode !== 'tesSUCCESS' ) { console. error ( `PermissionedDomainSet failed with code ${ resultCode }` ) client. disconnect () process. exit ( 3 ) } console. log ( 'Successfully modified permissioned domain.' ) client. disconnect () Delete a Permissioned Domain To delete a permissioned domain that you own, send a PermissionedDomainDelete transaction with the DomainID of the domain to delete. JavaScript Python // Delete a permissioned domain ----------------------------------------------- const pDomainDel = { TransactionType: "PermissionedDomainDelete" , Account: wallet.address, DomainID: domainID } console. log ( 'Submitting transaction' , JSON . stringify (pDomainDel, null , 2 )) const response = await client. submitAndWait (pDomainDel, { wallet, autofill: true }) console. log (response) const resultCode = response.result.meta.TransactionResult if (resultCode !== 'tesSUCCESS' ) { console. error ( `PermissionedDomainDelete failed with code ${ resultCode }` ) client. disconnect () process. exit ( 3 ) } console. log ( 'Successfully deleted permissioned domain.' ) client. disconnect () See Also Concepts: Credentials Permissioned Domains Permissioned DEXes Single Asset Vaults Tutorials: Manage Credentials Build a Credential Issuing Service in JavaScript Build a Credential Issuing Service in Python Trade in the Decentralized Exchange References: PermissionedDomainSet transaction PermissionedDomainDelete transaction PermissionedDomain entry ## /docs/tutorials/get-started/get-started-java Get Started Using Java Library Copy This tutorial walks you through the basics of building an XRP Ledger-connected application using xrpl4j , a pure Java 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 xrpl4j . How to get an account on the Testnet using xrpl4j . How to use the xrpl4j library to look up information about an account on the XRP Ledger. How to put these steps together to create a Java app. Requirements The xrpl4j library supports Java 1.8 and later. A project management tool such as Maven or Gradle . Installation The xrpl4j library is available on Maven Central . xrpl4j is split into multiple artifacts, which can be imported as needed. In this tutorial, you need the xrpl4j-client , xrpl4j-address-codec , xrpl4j-keypairs , and xrpl4j-model modules. To install with Maven, add the following to your project's pom.xml file and then run mvn install : < 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 > < 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 > Check out the xrpl4j sample project for a full Maven project containing the code from this tutorial. 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 xrpl4j , you can use an 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); Connect to the production XRP Ledger The sample code in the previous section shows you how to connect to the Testnet, which is one of the available parallel networks . 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: final HttpUrl rippledUrl = HttpUrl.get("http://localhost:5005/"); XrplClient xrplClient = new XrplClient(rippledUrl); See the example core server config file for more information about default values. By using one of the available public servers : final HttpUrl rippledUrl = HttpUrl.get("https://s2.ripple.com:51234/"); XrplClient xrplClient = new XrplClient(rippledUrl); 2. Get account To store value and execute transactions on the XRP Ledger, you need to get an account: a set of keys and an address that's been funded with enough XRP to meet the account reserve . The address is the identifier of your account and you use the private key to sign transactions that you submit to the XRP Ledger. For production purposes, you should take care to store your keys and set up a secure signing method . To generate a new account, xrpl4j provides the DefaultWalletFactory . // Create a random KeyPair KeyPair randomKeyPair = Seed. ed25519Seed (). deriveKeyPair (); System.out. println ( "Generated KeyPair: " + randomKeyPair); The result of a call to walletFactory.randomWallet(true).wallet() is a Wallet instance : System.out. println (testWallet); // print output Wallet { privateKey = - HIDDEN - , publicKey = ED90635A6F2A5905D3D5CD2C14905FFB2D838185993576CA4CEE24A920D0D6BD6B, classicAddress = raj5eirfEpbN9YzG9FzB8ZPNyjpFvH6ycV, xAddress = T76mQFr9zLGi2LCjVDgJ7mEQCk4767SdEL32mZFygpdGcFf, isTest = true } For testing and development purposes, you can use a FaucetClient connected to the XRP Ledger Testnet : // 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." ); 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 XrplClient we constructed to look up information about the account we got in the previous step. // Look up your Account Info AccountInfoRequestParams requestParams = AccountInfoRequestParams. of (classicAddress); AccountInfoResult accountInfoResult = xrplClient. accountInfo (requestParams); 4. Putting it all together Using these building blocks, we can create a Java app that: Gets an account on the Testnet. Connects to the XRP Ledger. Looks up and prints information about the account you created. // 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); To run the app, you can download the code from Github and run GetAccountInfo either from your IDE or from the command line. git clone https://github.com/XRPLF/xrpl4j-sample.git cd xrpl4j-sample mvn compile exec:java -Dexec.mainClass= "org.xrpl.xrpl4j.samples.GetAccountInfo" You should see output similar to this example: 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 The response fields contained in AccountInfoResult that you want to inspect in most cases are: accountData.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. accountData.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 xrpl4j to connect to the XRP Ledger, get an account, and look up information about it, you can also use xrpl4j to: Send XRP . Set up secure signing for your account. ## /docs/infrastructure/installation Installation Copy Install and update the core XRP Ledger server ( xrpld ) or the API server (Clio). System Requirements Hardware and software requirements for running xrpld or Clio. Install on Red Hat Enterprise Linux Install a precompiled xrpld binary on Red Hat Enterprise Linux. Install on Ubuntu or Debian Linux Install a precompiled xrpld binary on Ubuntu Linux. Install Clio on Ubuntu Linux Install a precompiled Clio binary on Ubuntu Linux. Update Automatically on Linux Set up automatic updates for xrpld on Linux. Update Manually on Red Hat Enterprise Linux Manually update xrpld on CentOS or Red Hat Enterprise Linux. Update Manually on Ubuntu or Debian Manually update xrpld on Ubuntu Linux. Migrate from rippled to xrpld Migrate a node operator's installation from the rippled package to the renamed xrpld package introduced in 3.2.0. Build xrpld on Linux, Mac, or Windows Build xrpld on Linux, Mac (macOS), or Windows Capacity Planning Plan system specs and tune configuration for xrpld in production environments.
프로젝트로 돌아가기