terranc/laravel-web3

Laravel SDK wrapper for the Web3 PHP API client that interacts with the Ethereum blockchain.

Fund package maintenance!
Ko Fi

1.1.1 2021-07-25 08:51 UTC

This package is not auto-updated.

Last update: 2024-11-11 23:13:22 UTC


README

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Laravel Web3 is a Laravel SDK wrapper for the Web3 PHP API client that interacts with the Ethereum blockchain.

🤝 Supporting

Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.

If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.

ko-fi

🚀 Installation

You can install the package via composer:

composer require terranc/laravel-web3 --ignore-platform-reqs

Publish the config:

$ php artisan vendor:publish --provider="RenokiCo\LaravelWeb3\LaravelWeb3ServiceProvider" --tag="config"

🙌 Usage

The client configuration can be found in the config/web3.php file. Each call will be made from the \Web3\Web3 class:

use RenokiCo\LaravelWeb3\Web3Facade;

Web3Facade::eth()->provider->execute(function ($err, $data) {
    //
});

Multiple connections

The package supports multiple connections configurations. If you wish to select a specific one (not the default one), call connection before getting the cluster.

use RenokiCo\LaravelWeb3\Web3Facade;

Web3Facade::connection('http2')->eth()->provider->execute(function ($err, $data) {
    //
});

Additional methods

The following methods are also available to start with:

use RenokiCo\LaravelWeb3\Web3Facade;

Web3Facade::eth(); // equivalent of $web3->eth
Web3Facade::net();  // equivalent of $web3->net
Web3Facade::personal();  // equivalent of $web3->personal
Web3Facade::shh();  // equivalent of $web3->shh
Web3Facade::utils();  // equivalent of $web3->utils

Working with Contracts

You can also initialize contracts with the same configuration:

use RenokiCo\LaravelWeb3\Web3Facade;

Web3Facade::contract($abi, 'latest')
    ->bytecode($bytecode)
    ->new($params, $callback);

🐛 Testing

vendor/bin/phpunit

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.

🎉 Credits