forked from zulucrypto/stellar-api
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path04-submit-transaction.php
executable file
·36 lines (27 loc) · 1.17 KB
/
04-submit-transaction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require __DIR__ . '/../vendor/autoload.php';
use ZuluCrypto\StellarSdk\Keypair;
use ZuluCrypto\StellarSdk\Server;
use ZuluCrypto\StellarSdk\XdrModel\Operation\PaymentOp;
$server = Server::testNet();
// GAHC2HBHXSRNUT5S3BMKMUMTR3IIHVCARBFAX256NONXYKY65R2C5267
// You may need to fund this account if the testnet has been reset:
// https://www.stellar.org/laboratory/#account-creator?network=test
$sourceKeypair = Keypair::newFromSeed('SDU5L4Q7ZPW7AOKJTHZABI4QVD2YXPR4K2AFO7DD7HBYTO3PQPODGBER');
$destinationAccountId = 'GA2C5RFPE6GCKMY3US5PAB6UZLKIGSPIUKSLRB6Q723BM2OARMDUYEJ5';
// Verify that the destination account exists. This will throw an exception
// if it does not
$destinationAccount = $server->getAccount($destinationAccountId);
// Build the payment transaction
$transaction = \ZuluCrypto\StellarSdk\Server::testNet()
->buildTransaction($sourceKeypair->getPublicKey())
->addOperation(
PaymentOp::newNativePayment($destinationAccountId, 1)
)
;
// Sign and submit the transaction
$response = $transaction->submit($sourceKeypair->getSecret());
print "Response:" . PHP_EOL;
print_r($response->getRawData());
print PHP_EOL;
print 'Payment succeeded!' . PHP_EOL;