Skip to content

Starknet-php/starknet.php

Repository files navigation

starknet.php ✨🐘

starknet.php is a PHP sdk that allows you to interact with StarkNet from a PHP application.

starkware License

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 [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

PHP package that allows you to interact with StarkNet L2 network

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages