https://github.com/soneso/stellar-php-sdk
The Soneso open source Stellar SDK for PHP provides APIs to build and sign transactions, connect and query Horizon.
https://github.com/soneso/stellar-php-sdk
blockchain stellar
Last synced: about 1 month ago
JSON representation
The Soneso open source Stellar SDK for PHP provides APIs to build and sign transactions, connect and query Horizon.
- Host: GitHub
- URL: https://github.com/soneso/stellar-php-sdk
- Owner: Soneso
- License: apache-2.0
- Created: 2021-08-15T12:19:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-14T20:12:55.000Z (about 2 years ago)
- Last Synced: 2024-03-14T23:17:43.795Z (about 2 years ago)
- Topics: blockchain, stellar
- Language: PHP
- Homepage:
- Size: 1.71 MB
- Stars: 25
- Watchers: 11
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Stellar SDK for PHP](https://github.com/Soneso/stellar-php-sdk)
[](https://packagist.org/packages/soneso/stellar-php-sdk)
[](https://packagist.org/packages/soneso/stellar-php-sdk)
[](https://codecov.io/gh/Soneso/stellar-php-sdk)
[](https://deepwiki.com/Soneso/stellar-php-sdk)
Build and sign Stellar transactions, query [Horizon](https://developers.stellar.org/docs/data/apis/horizon), and interact with [Soroban](https://developers.stellar.org/docs/build/smart-contracts/overview) smart contracts via RPC. Communicate with anchors and external services using built-in support for 18 SEPs.
## Installation
```bash
composer require soneso/stellar-php-sdk
```
Requires PHP 8.0+.
## Quick examples
### Send a payment
Transfer XLM between accounts:
```php
$payment = (new PaymentOperationBuilder($receiverId, Asset::native(), '100'))->build();
$tx = (new TransactionBuilder($account))->addOperation($payment)->build();
$tx->sign($senderKeyPair, Network::testnet());
$sdk->submitTransaction($tx);
```
### Trust an asset
Enable your account to receive a token (like USDC):
```php
$asset = Asset::createNonNativeAsset('USDC', $issuerAccountId);
$trustOp = (new ChangeTrustOperationBuilder($asset))->build();
$tx = (new TransactionBuilder($account))->addOperation($trustOp)->build();
$tx->sign($accountKeyPair, Network::testnet());
$sdk->submitTransaction($tx);
```
### Call a smart contract
Invoke a Soroban contract method:
```php
$client = SorobanClient::forClientOptions(new ClientOptions(
sourceAccountKeyPair: $keyPair,
contractId: 'CABC...',
network: Network::testnet(),
rpcUrl: 'https://soroban-testnet.stellar.org'
));
$result = $client->invokeMethod('hello', [XdrSCVal::forSymbol('World')]);
```
For complete walkthroughs, see the [documentation](docs/).
## Documentation
| Guide | Description |
|-------|-------------|
| [Quick start](docs/quick-start.md) | Your first transaction in 15 minutes |
| [Getting started](docs/getting-started.md) | Keys, accounts, and fundamentals |
| [SDK usage](docs/sdk-usage.md) | Transactions, operations, Horizon queries, streaming |
| [Soroban](docs/soroban.md) | Smart contract deployment and interaction |
| [SEPs](docs/sep/) | Anchor integration, authentication, KYC, etc. |
[API reference](https://soneso.github.io/stellar-php-sdk/)
## Compatibility
- [Horizon API compatibility matrix](compatibility/horizon/COMPATIBILITY_MATRIX.md)
- [RPC API compatibility matrix](compatibility/rpc/RPC_COMPATIBILITY_MATRIX.md)
- [SEP support matrices](compatibility/sep/)
## Feedback
If you're using this SDK, feedback helps improve it:
- [Report a bug](https://github.com/Soneso/stellar-php-sdk/issues/new?template=bug_report.yml)
- [Request a feature](https://github.com/Soneso/stellar-php-sdk/issues/new?template=feature_request.yml)
- [Start a discussion](https://github.com/Soneso/stellar-php-sdk/discussions)
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License
Apache 2.0. See [LICENSE](LICENSE).