Skip to content

Instantly share code, notes, and snippets.

@askaaqib
Created November 25, 2020 05:13
Show Gist options
  • Save askaaqib/b96183ea8cdad3a0656f0d1e86480420 to your computer and use it in GitHub Desktop.
Save askaaqib/b96183ea8cdad3a0656f0d1e86480420 to your computer and use it in GitHub Desktop.
Submit Transaction - Stellar PHP API
<?php
declare(strict_types=1);
require "../vendor/autoload.php";
use ZuluCrypto\StellarSdk\Keypair;
use ZuluCrypto\StellarSdk\Server;
use ZuluCrypto\StellarSdk\XdrModel\Operation\PaymentOp;
echo "<pre>";
$server = Server::testNet();
// GCCZACJX7DHEWGK5WJ2ONRGAJN2RBGGCX3OO4NF66JMJ4MNACKED577A
// 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('SAEQX6CGO34D4GMT75O3A7ABEXOQSRBXIC7RPHI5YIP2TF6SEGGAPOPQ');
$destinationAccountId = 'GDWSSMELSCPAVRBSDJRXE5TZL2SLNK42MTCUR3SR22HKVYCKF5RMINGK';
// 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, 2)
)
;
// 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment