exinone / mixin-sdk-php
Mixin-Network SDK for PHP, modify from ExinOne/laravel-mixin-sdk
Installs: 2 347
Dependents: 3
Suggesters: 0
Security: 0
Stars: 24
Watchers: 9
Forks: 11
Open Issues: 0
Requires
- php: ^7.2 || ^8.0
- ext-bcmath: *
- ext-gmp: *
- ext-json: *
- ext-openssl: *
- ext-sodium: *
- ext-zlib: *
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^6.3 || ^7.0
- paragonie/sodium_compat: 1.20
- phpseclib/phpseclib: ^2.0
- ramsey/uuid: ^3.8 || ^4
- web-token/jwt-easy: ^2.2
- web-token/jwt-key-mgmt: ^2.2
- web-token/jwt-signature-algorithm-eddsa: ^2.2
- wrench/wrench: ^2.0
Requires (Dev)
- phpunit/phpunit: ^7.0 || ^8.0
- symfony/var-dumper: ^4.2
- dev-master
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- v1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.2.21
- v1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/safe-mainnet
- dev-feature/add-aud
- dev-feature/add-multisigs-requests
- dev-feature/add-snapshots-trace
- dev-feature/add-chains
- dev-feature/fix-batch-message
- dev-feature/ticker
- dev-feature/fix-multisigs-outputs
- dev-feature/add-assets-multisig
- dev-feature/kurisu-upgrade-multisig-experience-210406
- dev-feature/add-multisigs-outputs
This package is not auto-updated.
Last update: 2025-01-07 14:44:12 UTC
README
Mixin-Network SDK for PHP
Requirement
Composer
PHP
>= 7.0
Installation
$ composer require exinone/mixin-sdk-php -vvv
Use
Example
// config format $config0 = [ "app_id" => "d4155247-xxxx-xxxx-aa8a-775333b12406", "session_id" => "7a633a3f-xxxx-xxxx-99b9-ae43c88be4be", "server_public_key" => "556b82842exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa6d8ad8af3f2649474", "session_private_key" => "154cd8dceaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx24d070b1acc880a13b", "spend_key" => "f86d9dd3faxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc64e8bc7c5aef6a0a4", "client_secret" => "fdbe66249axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcc4519a4ea20d48b7e" ]; // old format is also supported $config1 = [ 'mixin_id' => '7000101633', 'client_id' => '982afd4e-92dd-4430-98cf-d308442ea04d', 'client_secret' => 'b0a9adf1b358501b1fb6065c6292b09dbc675d5734225f86e0ec14a71d0fd38a', 'pin' => '125334', 'pin_token' => 'RzgyepFhLbMx+zLw6ogYzZ5k+kmlo8gQ2f4+1uwGMi1HgvMexGdFdeny0ffuBl7gXgPqi1GpUDPWPNrgAIjwGIFu+rHSre1G7JA5ET6tgIYoC+OI2dF0PmNK0qtkjK+qpGpSCt8nFbTfgyHjFENAp4hLZEIhuhzSPPmkkhXGlAU=', 'session_id' => '8a70b414-bdef-46f3-9738-186c1095da61', 'private_key' => <<<EOF -----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQCZAkpYA7eH38GbzIX653dxBAEanrSSdYbzQYIV/kKbULYSB43X 5hWfCFpNJ6FoIUjHAzrNyqJMvSS6LwAA+R4w5GYv8en1Ga1blKbziCMvZsRJ65bP F2cPbPQUYNWZpZRsyFlMZCjVVytA1a+HWba5FzGBXiEEzd5BVo9truxGKQIDAQAB AoGBAJHpVj4ipUWEgtvxKR9A1m1G9UqOaAJ2409cfBI/GwOD72y4GXL2rk2vKHYF Qe3MN9vY353aC/YENV77bRSAfGF+lAuw3hQOFfMvKfRUmVaB5V4kEaF1+z9jPHwh QcSpqyAsMClEnyMxbNrFih4tQGlGUydHI3xv1wK+53MjncwBAkEA98GvzldsLW7E dhwXLba3KN/GvLZLcljLyHjctUxCU8EywD73UM1lJuayWvYdLfzFe0p9cDjvS8Gx sbYg3eE2qQJBAJ4ZkqVbdCAyUBpjaIO9QzxsL77zCgayrQTvWv0QQgJputO7S2rs i/iCmt1bZ3IAnfVnDUJfAaxSL6VU1T6Fw4ECQQCtUvrCx7YOMqeOWSh9+o04MxS9 gGpXnHcz0BnXW3orTcVLaMFr7cUN6eZsbDENswAUuI/4qlv+C4tcX6Wuk5fBAkA+ EggzB37GDTrJwXGNF0dId6kfLMgo7QlkwJxWcoWX8O66pfPsHMavYIdwlKw+Y+Og Lz9TaX18rB+sp2u5SkcBAkBIsC/AJNhf1xILLAkkpycJ7rc864Y1JbmKk+I5fXid vA4vKPqu2ZnD0O4YbGmciuTRPgeJqAt8bbHq/xOfL0lE -----END RSA PRIVATE KEY----- EOF , //import your private_key ]; $mixinSdk = new \ExinOne\MixinSDK\MixinSDK(); // use setConfig method to save config $mixinSdk->setConfig('myConfig-A',$config0); $mixinSdk->setConfig('myConfig-B',$config1); // then you can $mixinSdk->use('myConfig-A')->user()->readProfile(); //------- // Or more simple way, using the 'use' method , chained with other methods $mixinSdk->use('myConfig-A',$config)->user()->readProfile(); // then you can $mixinSdk->use('myConfig-A')->user()->readProfile();
Run
Exceptions
If MixinNetwork response with an error,An Exception ExinOne\MixinSDK\Exceptions\MixinNetworkRequestException
will be
thrown. Developers need to capture and handle this exception.
try { // If the transfer fails here, an error will be thrown. $mixinSdk->wallet()->transfer($asset_id, $opponent_id, $pin, $amount, $memo); } catch (MixinNetworkRequestException $e) { // Here errCode and errMessage are the same as MixinNetwork, refer to the following link. $errCode = $e->getCode(); $errMessage = $e->getMessage(); ... } catch (\Throwable $e) { ... }
Other Exceptions
WARNING
-
You can config
iterator
in the following way. Theiterator
is used when a PIN is encrypted. Generally,iterator
should not be modified. If you want ot modify this variable, be sure to know what you are doing. More details on iterator$iterator = [time()]; // if use it by $mixinSdk->pin()->updatePin($oldPin,$pin), // $iterator need have two element (count($iterator) == 2) $mixinSdk->wallet()->setIterator($iterator)->transfer($asset_id, $opponent_id, $pin, $amount, $memo); // By default, ( microtime(true) . RANDOM NUMBERS ) * 1000000000 is used as iterator
-
Setting Http Request timeout
$mixinSdk->wallet()->setTimeout(10)->transfer($asset_id, $opponent_id, $pin, $amount, $memo); // The default timeout is 20 s
-
Get raw Recponse content
$mixinSdk->wallet()->setRaw(true)->transfer($asset_id, $opponent_id, $pin, $amount, $memo); // Return MixinNetwork raw Response content
Alternatives
LICENSE
MIT