mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-25 14:15:50 +00:00
Content for getting-started-in-php.md and send-xrp.md
This commit is contained in:
@@ -7,3 +7,4 @@ For more context, see the Get Started tutorial for your preferred language:
|
||||
- [Python](https://xrpl.org/get-started-using-python.html)
|
||||
- [Java](https://xrpl.org/get-started-using-java.html)
|
||||
- [JavaScript](https://xrpl.org/get-started-using-javascript.html)
|
||||
- [PHP](https://xrpl.org/get-started-using-php.html)
|
||||
|
||||
18
content/_code-samples/get-started/php/base.php
Normal file
18
content/_code-samples/get-started/php/base.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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
|
||||
fundWallet($client, $wallet);
|
||||
5
content/_code-samples/get-started/php/composer.json
Normal file
5
content/_code-samples/get-started/php/composer.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"hardcastle/xrpl_php": "^0.8.5"
|
||||
}
|
||||
}
|
||||
28
content/_code-samples/get-started/php/get-acct-info.php
Normal file
28
content/_code-samples/get-started/php/get-acct-info.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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);
|
||||
|
||||
$accountInfoRequest = new AccountInfoRequest(
|
||||
account: $wallet->getAddress(),
|
||||
ledgerIndex: 'validated'
|
||||
);
|
||||
|
||||
$accountInfoResponse = $client->syncRequest(($accountInfoRequest));
|
||||
|
||||
print_r($accountInfoResponse);
|
||||
Reference in New Issue
Block a user