starknet-php / starknet.php
PHP sdk that allows you to interact with StarkNet L2 network
Requires
- php: ^8.0
- ext-bcmath: *
- guzzlehttp/guzzle: ^7.4
- kornrunner/keccak: ^1.1
- mdanter/ecc: 1.0
- phpseclib/phpseclib: ^3.0.12
- simplito/elliptic-php: 1.0.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.3.2
- mockery/mockery: ^1.4.4
- pestphp/pest: ^1.21.1
- phpstan/phpstan: ^1.2.0
- symfony/var-dumper: ^5.4.0
This package is auto-updated.
Last update: 2024-04-21 10:25:46 UTC
README
starknet.php is a PHP sdk that allows you to interact with StarkNet from a PHP application.
This project is a work-in-progress. Code and documentation are currently under development and are subject to change
Install
Requires PHP 8.0+
Install starknet.php
via the Composer package manager:
composer require starknet-php/starknet.php
Usage
The following code can be used with a public and private key to create a signer
$wallet_address = '0x0006be19b8a602c2013deb97e2ad12b358d2f3fb2e3d4c1e96f047cb68fd8a8' // your wallet address $pk = '' // your private key $network = 'testnet' // can be testnet || mainnet $signer = new Signer($pk, $network, $wallet_address);
The following code can be used to interact with a contract
$contract = '0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10' // the contract address to interact with $method = Stark::getSelectorFromName('transfer') // the method to call $calldata = ['0x060eb76c275ce5188b9e30b212776a68e037674331437fc028b072102b6fe181', '1200000000000000000', '0'] // the parameters to call with [to, amount, max] $signer->addTransaction([ 'type' => 'INVOKE_FUNCTION', 'contract_address' => $contract, 'entry_point_selector' => $method, 'calldata' => $calldata, ]);
Testing
Tests were created using the pest testing package. To call tests run
./vendor/bin/pest
Contributing
Please see CONTRIBUTING for more details.
Security
If you discover any security related issues, please email asciik@protonmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.