PHPackages                             alicompu/solana-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alicompu/solana-php-sdk

ActiveLibrary[API Development](/categories/api)

alicompu/solana-php-sdk
=======================

Solana PHP SDK for interacting with the Solana blockchain

055HTML

Since Apr 28Pushed 1y agoCompare

[ Source](https://github.com/alicompu/solana-php-sdk)[ Packagist](https://packagist.org/packages/alicompu/solana-php-sdk)[ RSS](/packages/alicompu-solana-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

Solana PHP SDK
==============

[](#solana-php-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b26df3fd08f82d5e088f51c7e3c9eb120340df575cf97dbd4f54b7372e1f05ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617474657374746f2f736f6c616e612d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/attestto/solana-php-sdk)[![GitHub Tests Action Status](https://github.com/Attestto-com/solana-php-sdk/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/Attestto-com/solana-php-sdk/actions/workflows/run-tests.yml)[![Coverage (CodeCov)](https://camo.githubusercontent.com/79ff74f8ab461022e85f2b22d66848458213373f81338ace3eeeddafba0bb589/68747470733a2f2f636f6465636f762e696f2f6769746875622f417474657374746f2d636f6d2f736f6c616e612d7068702d73646b2f67726170682f62616467652e7376673f746f6b656e3d4d31324c45435a395145)](https://codecov.io/github/Attestto-com/solana-php-sdk)

```
    ____  __  ______     _____ ____  __    ___    _   _____       _____ ____  __ __
   / __ \/ / / / __ \   / ___// __ \/ /   /   |  / | / /   |     / ___// __ \/ //_/
  / /_/ / /_/ / /_/ /   \__ \/ / / / /   / /| | /  |/ / /| |     \__ \/ / / / ,getAccountInfo('4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA');
var_dump($accountInfo);
```

For all the possible methods, see the [API documentation](https://docs.solana.com/developing/clients/jsonrpc-api).

### Directly using the RPC client

[](#directly-using-the-rpc-client)

The `Connection` class is just a light convenience layer on top of the RPC client. You can, if you want, use the client directly, which allows you to work with the full `Response` object:

```
use Attestto\SolanaPhpSdk\SolanaRpcClient;

$client = new SolanaRpcClient(SolanaRpcClient::MAINNET_ENDPOINT);
$accountInfoResponse = $client->call('getAccountInfo', ['4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA']);
$accountInfoBody = $accountInfoResponse->json();
$accountInfoStatusCode = $accountInfoResponse->getStatusCode();
```

### Transactions

[](#transactions)

Here is working example of sending a transfer instruction to the Solana blockchain, you may overrride the Endpoint with a custom RPC endpoint.:

```
$client = new SolanaRpcClient(SolanaRpcClient::DEVNET_ENDPOINT);
$connection = new Connection($client);
$fromPublicKey = KeyPair::fromSecretKey([...]);
$toPublicKey = new PublicKey('J3dxNj7nDRRqRRXuEMynDG57DkZK4jYRuv3Garmb1i99');
$instruction = SystemProgram::transfer(
    $fromPublicKey->getPublicKey(),
    $toPublicKey,
    6
);

$transaction = new Transaction(null, null, $fromPublicKey->getPublicKey());
$transaction->add($instruction);

$txHash = $connection->sendTransaction($transaction, $fromPublicKey);
```

### Borsh Deserialize &amp; Deserialize

[](#borsh-deserialize--deserialize)

For Borsh serialization/deseralization to work, a class::SCHEMA object reflecting the Program Structs, based on the program IDL must be passed or defined. e.g.

```
class DidData
{

    use BorshObject; //trait
    public $keyData;

    public const SCHEMA = [
        VerificationMethodStruct::class => VerificationMethodStruct::SCHEMA[VerificationMethodStruct::class],
        ServiceStruct::class => ServiceStruct::SCHEMA[ServiceStruct::class],
        self::class => [
            'kind' => 'struct',
            'fields' => [
                ['offset', 'u64'],
                ['version', 'u8'],
                ['bump', 'u8'],
                ['nonce', 'u64'],
                ['initialVerificationMethod', 'string'],
                ['flags', 'u16'],
                ['methodType', 'u8'],
                ['keyData', ['u8']],
                ['verificationMethods', [VerificationMethodStruct::class]],
                ['services', [ServiceStruct::class]],
                ['nativeControllers', ['pubKey']],
                ['otherControllers', ['string']],
            ],
        ],
    ];

    public static function fromBuffer(array $buffer): self
    {
        return Borsh::deserialize(self::SCHEMA, self::class, $buffer);
    }
}
```

BORSH USAGE (PHP implementation)
--------------------------------

[](#borsh-usage-php-implementation)

To get a better understanding on the implementation and usage, please refer to the following references:

- [PHP Borsh Test](https://github.com/Attestto-com/solana-php-sdk/blob/master/tests/Unit/BorshTest.php)
- [PHP Borsh Class](https://github.com/Attestto-com/solana-php-sdk/blob/master/src/Borsh/Borsh.php)
- [PHP Borsh Trait](https://github.com/Attestto-com/solana-php-sdk/blob/master/src/Borsh/BorshObject.php)

example usage ***(This will be improved, WIP)***:

```
/**
     * deserializeDidData
     *
     * @param string $dataBase64 The base64 encoded data of the DID data account
     * @return DidData The deserialized DID data object
     * @example DidSolProgram::deserializeDidData('TVjvjfsd7fMA/gAAAA...');
     */
    static function deserializeDidData($dataBase64)
    {

        $base64String = base64_decode($dataBase64);
        $uint8Array = array_values(unpack('C*', $base64String));
        $didData = DidData::fromBuffer($uint8Array); // See above code block

        $keyData = $didData->keyData;

        $binaryString = pack('C*', ...$keyData);

        $b58 = new Base58();
        $base58String = $b58->encode($binaryString);
        $didData->keyData = $base58String;
        return $didData;
    }
```

Notes:
------

[](#notes)

- Most of the Magic is done in the [BorshDesealizable.php](https://github.com/Attestto-com/solana-php-sdk/blob/master/src/Borsh/BorshDeserializable.php) Trait.
- This project is in alpha, the code to generate instructions is still being worked on `$instruction = SystemProgram::abc()`
- This project is maintained by a single dev, so any feedback, ideas, comments are appreciated.

Roadmap (WIP)
-------------

[](#roadmap-wip)

1. Borsh serialize and deserialize. [Done](https://github.com/Attestto-com/solana-php-sdk/tree/master/src/Borsh) - [Test(s)](https://github.com/Attestto-com/solana-php-sdk/blob/master/tests/Unit/BorshTest.php) - [Coverage](https://app.codecov.io/github/Attestto-com/solana-php-sdk/tree/master/src%2FBorsh)
2. Improved documentation. [WIP](#) - This document + [Documentation Index](https://github.com/Attestto-com/solana-php-sdk/tree/master/docs) ()
3. Build out more of the Connection, Message, SystemProgram, TokenProgram, MetaplexProgram classes. [WIP](https://github.com/Attestto-com/solana-php-sdk/tree/master/src) - [Tests](https://github.com/Attestto-com/solana-php-sdk/tree/master/tests/Unit) - [Coverage](https://app.codecov.io/github/Attestto-com/solana-php-sdk/tree/master/src)4. \[ \] Connection::class 5. \[x\] getLatestBlokchash::class \[Source\] - \[Test\] - \[Coverage\] 6. \[ \] getMinimumBalanceForRentExemption() 7. \[ \] getTokenAccountBalance() 6. \[ \] TransactionMessage::class 7. \[ \] compileToV0Message() 8. \[ \] VersionedTransaction::class 9. \[ \] SPL-TOKEN Program 10. \[ \] getOrCreateAssociatedTokenAccount() 11. \[ \] getAssociatedTokenAddressSync() 12. \[ \] createAssociatedTokenAccountInstruction() 11. \[ \] createSyncNativeInstruction() - \[Test\]\[Coverage\]
4. Improve abstractions around working with binary data. [Done?](https://github.com/Attestto-com/solana-php-sdk/tree/master/src/Borsh) - [Test(s)](https://github.com/Attestto-com/solana-php-sdk/blob/master/tests/Unit/BorshTest.php) - [Coverage](https://app.codecov.io/github/Attestto-com/solana-php-sdk/tree/master/src%2FBorsh)
5. Optimizations:

    1. Leverage PHP more.
    2. Better cache `$recentBlockhash` when sending transactions.
6. Suggestions? Open an [Issue](https://github.com/Attestto-com/solana-php-sdk/issues) or [Pull Request](https://github.com/Attestto-com/solana-php-sdk/pulls) :D

Testing &amp; Code Coverage
---------------------------

[](#testing--code-coverage)

WIP -- Working on coverage and deprecations. See [Coverage Report](https://app.codecov.io/github/Attestto-com/solana-php-sdk).

- Configuration [phpunit.xml](https://github.com/Attestto-com/solana-php-sdk/blob/master/phpUnit.xml)
- composer.json

```
   "scripts": {
        "test": "vendor/bin/phpunit tests --coverage-clover=coverage.xml --coverage-filter src/",
        "format": "vendor/bin/php-cs-fixer fix --allow-risk=yes"
    },
```

[![GitHub Tests Action Status](https://github.com/Attestto-com/solana-php-sdk/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/Attestto-com/solana-php-sdk/actions/workflows/run-tests.yml)[![Coverage (CodeCov)](https://camo.githubusercontent.com/79ff74f8ab461022e85f2b22d66848458213373f81338ace3eeeddafba0bb589/68747470733a2f2f636f6465636f762e696f2f6769746875622f417474657374746f2d636f6d2f736f6c616e612d7068702d73646b2f67726170682f62616467652e7376673f746f6b656e3d4d31324c45435a395145)](https://codecov.io/github/Attestto-com/solana-php-sdk)

```
composer test
```

OR

```
/verdor/bin/phpunit tests [options]
```

Contributing - Yes Please! :-P
------------------------------

[](#contributing---yes-please--p)

- Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
- I will change my profile pic once we get a 2nd mantainer onboard :-)

Security
--------

[](#security)

If you discover any security related issues, please email the maintainers (see composer.json) instead of using the issue tracker.

Credits
-------

[](#credits)

- [Matt Stauffer](https://github.com/mattstauffer) (Original creator)
- [Zach Vander Velden](https://github.com/exzachlyvv) (Metadata wizard)
- [Neverything](https://github.com/verze-app/solana-php-sdk/graphs/contributors) (Previous Maintainer)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6fea4dd7cd52da1eeaca19257159f1ffd87de2506cde1c1c1d83a33ab46de54f?d=identicon)[2014najafi](/maintainers/2014najafi)

---

Top Contributors

[![chongkan](https://avatars.githubusercontent.com/u/4944252?v=4)](https://github.com/chongkan "chongkan (64 commits)")[![alicompu](https://avatars.githubusercontent.com/u/21305305?v=4)](https://github.com/alicompu "alicompu (1 commits)")[![steveluscher](https://avatars.githubusercontent.com/u/13243?v=4)](https://github.com/steveluscher "steveluscher (1 commits)")

### Embed Badge

![Health badge](/badges/alicompu-solana-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/alicompu-solana-php-sdk/health.svg)](https://phpackages.com/packages/alicompu-solana-php-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M453](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
