mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-14 08:45:50 +00:00
Improved samples and documentation
This commit is contained in:
96
assets/img/logos/php.svg
Normal file
96
assets/img/logos/php.svg
Normal file
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg height="383.5975" id="svg3430" version="1.1" viewBox="0 0 711.20123 383.5975" width="711.20123" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<title id="title3510">Official PHP Logo</title>
|
||||
<metadata id="metadata3436">
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title>Official PHP Logo</dc:title>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Colin Viebrock</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:description/>
|
||||
<dc:contributor>
|
||||
<cc:Agent>
|
||||
<dc:title/>
|
||||
</cc:Agent>
|
||||
</dc:contributor>
|
||||
<cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/"/>
|
||||
<dc:rights>
|
||||
<cc:Agent>
|
||||
<dc:title>Copyright Colin Viebrock 1997 - All rights reserved.</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:rights>
|
||||
<dc:date>1997</dc:date>
|
||||
</cc:Work>
|
||||
<cc:License rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction"/>
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#Distribution"/>
|
||||
<cc:requires rdf:resource="http://creativecommons.org/ns#Notice"/>
|
||||
<cc:requires rdf:resource="http://creativecommons.org/ns#Attribution"/>
|
||||
<cc:permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks"/>
|
||||
<cc:requires rdf:resource="http://creativecommons.org/ns#ShareAlike"/>
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs id="defs3434">
|
||||
<clipPath clipPathUnits="userSpaceOnUse" id="clipPath3444">
|
||||
<path d="M 11.52,162 C 11.52,81.677 135.307,16.561 288,16.561 l 0,0 c 152.693,0 276.481,65.116 276.481,145.439 l 0,0 c 0,80.322 -123.788,145.439 -276.481,145.439 l 0,0 C 135.307,307.439 11.52,242.322 11.52,162" id="path3446"/>
|
||||
</clipPath>
|
||||
<radialGradient cx="0" cy="0" fx="0" fy="0" gradientTransform="matrix(363.05789,0,0,-363.05789,177.52002,256.30713)" gradientUnits="userSpaceOnUse" id="radialGradient3452" r="1" spreadMethod="pad">
|
||||
<stop id="stop3454" offset="0" style="stop-opacity:1;stop-color:#aeb2d5"/>
|
||||
<stop id="stop3456" offset="0.3" style="stop-opacity:1;stop-color:#aeb2d5"/>
|
||||
<stop id="stop3458" offset="0.75" style="stop-opacity:1;stop-color:#484c89"/>
|
||||
<stop id="stop3460" offset="1" style="stop-opacity:1;stop-color:#484c89"/>
|
||||
</radialGradient>
|
||||
<clipPath clipPathUnits="userSpaceOnUse" id="clipPath3468">
|
||||
<path d="M 0,324 576,324 576,0 0,0 0,324 Z" id="path3470"/>
|
||||
</clipPath>
|
||||
<clipPath clipPathUnits="userSpaceOnUse" id="clipPath3480">
|
||||
<path d="M 0,324 576,324 576,0 0,0 0,324 Z" id="path3482"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="g3438" transform="matrix(1.25,0,0,-1.25,-4.4,394.29875)">
|
||||
<g id="g3440">
|
||||
<g clip-path="url(#clipPath3444)" id="g3442">
|
||||
<g id="g3448">
|
||||
<g id="g3450">
|
||||
<path d="M 11.52,162 C 11.52,81.677 135.307,16.561 288,16.561 l 0,0 c 152.693,0 276.481,65.116 276.481,145.439 l 0,0 c 0,80.322 -123.788,145.439 -276.481,145.439 l 0,0 C 135.307,307.439 11.52,242.322 11.52,162" id="path3462" style="fill:url(#radialGradient3452);stroke:none"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="g3464">
|
||||
<g clip-path="url(#clipPath3468)" id="g3466">
|
||||
<g id="g3472" transform="translate(288,27.3594)">
|
||||
<path d="M 0,0 C 146.729,0 265.68,60.281 265.68,134.641 265.68,209 146.729,269.282 0,269.282 -146.729,269.282 -265.68,209 -265.68,134.641 -265.68,60.281 -146.729,0 0,0" id="path3474" style="fill:#777bb3;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="g3476">
|
||||
<g clip-path="url(#clipPath3480)" id="g3478">
|
||||
<g id="g3484" transform="translate(161.7344,145.3066)">
|
||||
<path d="m 0,0 c 12.065,0 21.072,2.225 26.771,6.611 5.638,4.341 9.532,11.862 11.573,22.353 1.903,9.806 1.178,16.653 -2.154,20.348 C 32.783,53.086 25.417,55 14.297,55 L -4.984,55 -15.673,0 0,0 Z m -63.063,-67.75 c -0.895,0 -1.745,0.4 -2.314,1.092 -0.57,0.691 -0.801,1.601 -0.63,2.48 L -37.679,81.573 C -37.405,82.982 -36.17,84 -34.734,84 L 26.32,84 C 45.508,84 59.79,78.79 68.767,68.513 77.792,58.182 80.579,43.741 77.05,25.592 75.614,18.198 73.144,11.331 69.709,5.183 66.27,-0.972 61.725,-6.667 56.198,-11.747 49.582,-17.939 42.094,-22.429 33.962,-25.071 25.959,-27.678 15.681,-29 3.414,-29 l -24.722,0 -7.06,-36.322 c -0.274,-1.41 -1.508,-2.428 -2.944,-2.428 l -31.751,0 z" id="path3486" style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
<g id="g3488" transform="translate(159.2236,197.3071)">
|
||||
<path d="m 0,0 16.808,0 c 13.421,0 18.083,-2.945 19.667,-4.7 2.628,-2.914 3.124,-9.058 1.435,-17.767 C 36.012,-32.217 32.494,-39.13 27.452,-43.012 22.29,-46.986 13.898,-49 2.511,-49 L -9.523,-49 0,0 Z m 28.831,35 -61.055,0 c -2.872,0 -5.341,-2.036 -5.889,-4.855 l -28.328,-145.751 c -0.342,-1.759 0.12,-3.578 1.259,-4.961 1.14,-1.383 2.838,-2.183 4.63,-2.183 l 31.75,0 c 2.873,0 5.342,2.036 5.89,4.855 l 6.588,33.895 22.249,0 c 12.582,0 23.174,1.372 31.479,4.077 8.541,2.775 16.399,7.48 23.354,13.984 5.752,5.292 10.49,11.232 14.08,17.657 3.591,6.427 6.171,13.594 7.668,21.302 3.715,19.104 0.697,34.402 -8.969,45.466 C 63.965,29.444 48.923,35 28.831,35 m -45.633,-90 19.313,0 c 12.801,0 22.336,2.411 28.601,7.234 6.266,4.824 10.492,12.875 12.688,24.157 2.101,10.832 1.144,18.476 -2.871,22.929 C 36.909,3.773 28.87,6 16.808,6 L -4.946,6 -16.802,-55 M 28.831,29 C 47.198,29 60.597,24.18 69.019,14.539 77.44,4.898 79.976,-8.559 76.616,-25.836 75.233,-32.953 72.894,-39.46 69.601,-45.355 66.304,-51.254 61.999,-56.648 56.679,-61.539 50.339,-67.472 43.296,-71.7 35.546,-74.218 27.796,-76.743 17.925,-78 5.925,-78 l -27.196,0 -7.531,-38.75 -31.75,0 28.328,145.75 61.055,0" id="path3490" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
<g id="g3492" transform="translate(311.583,116.3066)">
|
||||
<path d="m 0,0 c -0.896,0 -1.745,0.4 -2.314,1.092 -0.571,0.691 -0.802,1.6 -0.631,2.48 L 9.586,68.061 C 10.778,74.194 10.484,78.596 8.759,80.456 7.703,81.593 4.531,83.5 -4.848,83.5 L -27.55,83.5 -43.305,2.428 C -43.579,1.018 -44.814,0 -46.25,0 l -31.5,0 c -0.896,0 -1.745,0.4 -2.315,1.092 -0.57,0.691 -0.801,1.601 -0.63,2.48 l 28.328,145.751 c 0.274,1.409 1.509,2.427 2.945,2.427 l 31.5,0 c 0.896,0 1.745,-0.4 2.315,-1.091 0.57,-0.692 0.801,-1.601 0.63,-2.481 L -21.813,113 2.609,113 c 18.605,0 31.221,-3.28 38.569,-10.028 7.49,-6.884 9.827,-17.891 6.947,-32.719 L 34.945,2.428 C 34.671,1.018 33.437,0 32,0 L 0,0 Z" id="path3494" style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
<g id="g3496" transform="translate(293.6611,271.0571)">
|
||||
<path d="m 0,0 -31.5,0 c -2.873,0 -5.342,-2.036 -5.89,-4.855 l -28.328,-145.751 c -0.342,-1.759 0.12,-3.578 1.26,-4.961 1.14,-1.383 2.838,-2.183 4.63,-2.183 l 31.5,0 c 2.872,0 5.342,2.036 5.89,4.855 l 15.283,78.645 20.229,0 c 9.363,0 11.328,-2 11.407,-2.086 0.568,-0.611 1.315,-3.441 0.082,-9.781 l -12.531,-64.489 c -0.342,-1.759 0.12,-3.578 1.26,-4.961 1.14,-1.383 2.838,-2.183 4.63,-2.183 l 32,0 c 2.872,0 5.342,2.036 5.89,4.855 l 13.179,67.825 c 3.093,15.921 0.447,27.864 -7.861,35.5 -7.928,7.281 -21.208,10.82 -40.599,10.82 l -20.784,0 6.143,31.605 C 6.231,-5.386 5.77,-3.566 4.63,-2.184 3.49,-0.801 1.792,0 0,0 m 0,-6 -7.531,-38.75 28.062,0 c 17.657,0 29.836,-3.082 36.539,-9.238 6.703,-6.16 8.711,-16.141 6.032,-29.938 l -13.18,-67.824 -32,0 12.531,64.488 c 1.426,7.336 0.902,12.34 -1.574,15.008 -2.477,2.668 -7.746,4.004 -15.805,4.004 l -25.176,0 -16.226,-83.5 -31.5,0 L -31.5,-6 0,-6" id="path3498" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
<g id="g3500" transform="translate(409.5498,145.3066)">
|
||||
<path d="m 0,0 c 12.065,0 21.072,2.225 26.771,6.611 5.638,4.34 9.532,11.861 11.574,22.353 1.903,9.806 1.178,16.653 -2.155,20.348 C 32.783,53.086 25.417,55 14.297,55 L -4.984,55 -15.673,0 0,0 Z m -63.062,-67.75 c -0.895,0 -1.745,0.4 -2.314,1.092 -0.57,0.691 -0.802,1.601 -0.631,2.48 L -37.679,81.573 C -37.404,82.982 -36.17,84 -34.733,84 L 26.32,84 C 45.509,84 59.79,78.79 68.768,68.513 77.793,58.183 80.579,43.742 77.051,25.592 75.613,18.198 73.144,11.331 69.709,5.183 66.27,-0.972 61.725,-6.667 56.198,-11.747 49.582,-17.939 42.094,-22.429 33.962,-25.071 25.959,-27.678 15.681,-29 3.414,-29 l -24.723,0 -7.057,-36.322 c -0.275,-1.41 -1.509,-2.428 -2.946,-2.428 l -31.75,0 z" id="path3502" style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
<g id="g3504" transform="translate(407.0391,197.3071)">
|
||||
<path d="M 0,0 16.808,0 C 30.229,0 34.891,-2.945 36.475,-4.7 39.104,-7.614 39.6,-13.758 37.91,-22.466 36.012,-32.217 32.493,-39.13 27.452,-43.012 22.29,-46.986 13.898,-49 2.511,-49 L -9.522,-49 0,0 Z m 28.831,35 -61.054,0 c -2.872,0 -5.341,-2.036 -5.889,-4.855 L -66.44,-115.606 c -0.342,-1.759 0.12,-3.578 1.259,-4.961 1.14,-1.383 2.838,-2.183 4.63,-2.183 l 31.75,0 c 2.872,0 5.342,2.036 5.89,4.855 l 6.587,33.895 22.249,0 c 12.582,0 23.174,1.372 31.479,4.077 8.541,2.775 16.401,7.481 23.356,13.986 5.752,5.291 10.488,11.23 14.078,17.655 3.591,6.427 6.171,13.594 7.668,21.302 3.715,19.105 0.697,34.403 -8.969,45.467 C 63.965,29.444 48.924,35 28.831,35 m -45.632,-90 19.312,0 c 12.801,0 22.336,2.411 28.601,7.234 6.267,4.824 10.492,12.875 12.688,24.157 2.102,10.832 1.145,18.476 -2.871,22.929 C 36.909,3.773 28.87,6 16.808,6 L -4.946,6 -16.801,-55 M 28.831,29 C 47.198,29 60.597,24.18 69.019,14.539 77.441,4.898 79.976,-8.559 76.616,-25.836 75.233,-32.953 72.894,-39.46 69.601,-45.355 66.304,-51.254 61.999,-56.648 56.679,-61.539 50.339,-67.472 43.296,-71.7 35.546,-74.218 27.796,-76.743 17.925,-78 5.925,-78 l -27.196,0 -7.53,-38.75 -31.75,0 28.328,145.75 61.054,0" id="path3506" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -16,3 +16,11 @@ $wallet = Wallet::generate();
|
||||
|
||||
// Fund (and activate) the wallet
|
||||
fundWallet($client, $wallet);
|
||||
|
||||
// print wallet properties
|
||||
print_r([
|
||||
'publicKey' => $wallet->getPublicKey(),
|
||||
'privateKey' => $wallet->getPrivateKey(),
|
||||
'classicAddress' => $wallet->getAddress(),
|
||||
'seed' => $wallet->getSeed()
|
||||
]);
|
||||
|
||||
@@ -18,11 +18,14 @@ $wallet = Wallet::generate();
|
||||
// Fund (and activate) the wallet
|
||||
fundWallet($client, $wallet);
|
||||
|
||||
// Create an AccountInfoRequest method
|
||||
$accountInfoRequest = new AccountInfoRequest(
|
||||
account: $wallet->getAddress(),
|
||||
ledgerIndex: 'validated'
|
||||
);
|
||||
|
||||
$accountInfoResponse = $client->syncRequest(($accountInfoRequest));
|
||||
// Send the request to the XRPL
|
||||
$accountInfoResponse = $client->syncRequest($accountInfoRequest);
|
||||
|
||||
// Print formatted response
|
||||
print_r($accountInfoResponse);
|
||||
@@ -136,26 +136,7 @@ print_r([
|
||||
|
||||
For testing and development purposes, you can use the `fundWallet()` helper function on the XRP Ledger [Testnet](parallel-networks.html):
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Use the Composer autoloader
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Imports
|
||||
use XRPL_PHP\Client\JsonRpcClient;
|
||||
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
|
||||
$fundWalletResponse = fundWallet($client, $wallet);
|
||||
```
|
||||
{{ include_code("_code-samples/get-started/php/get-account-info.php", start_with="<?php", end_before="// Create an AccountInfoRequest", language="php") }}
|
||||
|
||||
### 3. Query the XRP Ledger
|
||||
|
||||
@@ -163,37 +144,7 @@ You can query the XRP Ledger to get information about [a specific account](accou
|
||||
|
||||
Here, we'll use the [`JsonRpcClient` we constructed](#1-connect-to-the-xrp-ledger) to look up information about the [account we got](#2-get-account) in the previous step.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Use the Composer autoloader
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Imports
|
||||
use XRPL_PHP\Client\JsonRpcClient;
|
||||
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
|
||||
$fundWalletResponse = fundWallet($client, $wallet);
|
||||
|
||||
// Create an AccountInfo request "method"
|
||||
$accountInfoRequest = new AccountInfoRequest(
|
||||
account: $wallet->getAddress(),
|
||||
ledgerIndex: 'validated'
|
||||
);
|
||||
|
||||
// Send AccountInfo request
|
||||
$accountInfoResponse = $client->syncRequest(($accountInfoRequest));
|
||||
|
||||
print_r($accountInfoResponse);
|
||||
```
|
||||
{{ include_code("_code-samples/get-started/php/get-account-info.php", language="php", start_with="// Create an AccountInfoRequest") }}
|
||||
|
||||
### 4. Starting the script
|
||||
|
||||
@@ -207,7 +158,7 @@ To run the app, you can copy the code from [this website's GitHub Repository]({{
|
||||
|
||||
```console
|
||||
composer require hardcastle/xrpl_php
|
||||
php get-acct-info.php
|
||||
php get-account-info.php
|
||||
```
|
||||
|
||||
You should see output similar to this example:
|
||||
|
||||
@@ -139,10 +139,11 @@ _Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Prepare", end_before="// Sign", language="java") }}
|
||||
|
||||
_Java_
|
||||
_PHP_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/php/send-xrp.php", start_with="// Transaction definition", end_before="// Sign", language="php") }}
|
||||
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
{{ start_step("Prepare") }}
|
||||
@@ -190,7 +191,7 @@ _Java_
|
||||
start_with="// Sign", end_before="// Submit", language="java" ) }}
|
||||
|
||||
|
||||
_Java_
|
||||
_PHP_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/php/send-xrp.php",
|
||||
start_with="// Sign", end_before="// Submit", language="php" ) }}
|
||||
@@ -211,7 +212,7 @@ The result of the signing operation is a transaction object containing a signatu
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### {{n.next()}}. Submit the Signed Blob
|
||||
### 5. Submit the Signed Blob
|
||||
|
||||
Now that you have a signed transaction, you can submit it to an XRP Ledger server, which relays it through the network. It's also a good idea to take note of the latest validated ledger index before you submit. The earliest ledger version that your transaction could get into as a result of this submission is one higher than the latest validated ledger when you submit it. Of course, if the same transaction was previously submitted, it could already be in a previous ledger. (It can't succeed a second time, but you may not realize it succeeded if you aren't looking in the right ledger versions.)
|
||||
|
||||
@@ -257,7 +258,7 @@ example transaction</button>
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### 5. Wait for Validation
|
||||
### 6. Wait for Validation
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For more information on expiration of unconfirmed transactions, see [Reliable Transaction Submission](reliable-transaction-submission.html).)
|
||||
|
||||
@@ -294,7 +295,7 @@ _PHP_
|
||||
{{ end_step() }}
|
||||
|
||||
|
||||
### 6. Check Transaction Status
|
||||
### 7. Check Transaction Status
|
||||
|
||||
To know for sure what a transaction did, you must look up the outcome of the transaction when it appears in a validated ledger version.
|
||||
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
"href": "javascript.html",
|
||||
"img": "./assets/img/logos/javascript.svg",
|
||||
},
|
||||
{
|
||||
"title": "PHP",
|
||||
"description": "Using the XRPL_PHP client library.",
|
||||
"href": "php.html",
|
||||
"img": "./assets/img/logos/php.svg",
|
||||
},
|
||||
{
|
||||
"title": "HTTP & Websocket APIs",
|
||||
"description": "Access the XRP Ledger directly through the APIs of its core server.",
|
||||
@@ -158,7 +164,7 @@
|
||||
{% else %}
|
||||
<h4 class="card-title h5">{{title}}</h4>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<p class="card-text">{{description}}</p>
|
||||
</div>
|
||||
<div class="card-footer"> </div>
|
||||
|
||||
Reference in New Issue
Block a user