it-healer / laravel-ethereum
A library for Laravel that allows you to create and manage the Ethereum cryptocurrency.
Requires
- php: ^8.2
- ext-gmp: *
- brick/math: *
- furqansiddiqui/bip39-mnemonic-php: ^0.2.1
- illuminate/contracts: ^10.0|^11.0|^12.0
- kornrunner/ethereum-address: ^0.3.0
- kornrunner/ethereum-offline-raw-tx: ^0.8.0
- minter/minter-php-bip-44: ^1.2
- spatie/laravel-package-tools: ^1.92.0
README
Laravel Ethereum Module is a Laravel package for work with cryptocurrency Ethereum, with the support ERC-20 tokens. It allows you to generate HD wallets using mnemonic phrase, validate addresses, get addresses balances and resources, preview and send ETH/ERC-20 tokens. You can automate the acceptance and withdrawal of cryptocurrency in your application.
Requirements
The following versions of PHP are supported by this version.
- PHP 8.2 and older
- Laravel 10 or older
- PHP Extensions: GMP, BCMath, CType.
Installation
You can install the package via composer:
composer require it-healer/laravel-ethereum
After you can run installer using command:
php artisan ethereum:install
And run migrations:
php artisan migrate
Register Service Provider and Facade in app, edit config/app.php
:
'providers' => ServiceProvider::defaultProviders()->merge([ ..., \ItHealer\LaravelEthereum\EthereumServiceProvider::class, ])->toArray(), 'aliases' => Facade::defaultAliases()->merge([ ..., 'Ethereum' => \ItHealer\LaravelEthereum\Facades\Ethereum::class, ])->toArray(),
For Laravel 10 you edit file app/Console/Kernel
in method schedule(Schedule $schedule)
add:
$schedule->command('ethereum:sync') ->everyMinute() ->runInBackground();
or for Laravel 11+ add this content to routes/console.php
:
use Illuminate\Support\Facades\Schedule; ... Schedule::command('ethereum:sync') ->everyMinute() ->runInBackground();
Examples
First you need to add Ethereum Nodes, you can register account in ANKR.COM get take HTTPS Endpoint with API key for Ethereum blockchain:
use \ItHealer\LaravelEthereum\Facades\Ethereum; Ethereum::createNode('My node', 'https://rpc.ankr.com/eth/{API_KEY}');
Second you need add Ethereum Explorer, you can register account in Etherscan.io API and take Endpoint with API key:
use \ItHealer\LaravelEthereum\Facades\Ethereum; Ethereum::createExplorer('My explorer', 'https://api.etherscan.io/api', '{API_KEY}');
You can create ERC-20 Token:
use \ItHealer\LaravelEthereum\Facades\Ethereum; $contractAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7'; Ethereum::createToken($contractAddress);
Now you can create new Wallet:
use \ItHealer\LaravelEthereum\Facades\Ethereum; $wallet = Ethereum::createWallet('My wallet');
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.