sawirricardo / laravel-web3
Send your laravel apps to the moon with web3 enabled 🚀
Fund package maintenance!
sawirricardo
Requires
- php: ^8.0
- illuminate/contracts: ^8.37 | ^9.0
- kornrunner/keccak: ^1.1
- simplito/elliptic-php: ^1.0
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.18
- pestphp/pest-plugin-laravel: ^1.1
- spatie/laravel-ray: ^1.23
- vimeo/psalm: ^4.8
README
Laravel Web3 helps you to kickstart your web3 apps.
- No more headache with handling wallet changing address and sync with laravel back-end.
- Just do it
- Really, just do the steps below and be done.
Support this
Investing on Laravel-Web3 is defintely a good move from you. You can support by donating to my wallet
- Wallet 0x3F20d326E5DA8ab6D27d9b2DdD350baB1e589d87
- PayPal https://www.paypal.com/paypalme/sawirricardo.
Installation
You can install the package via composer:
composer require sawirricardo/laravel-web3
You can publish and run the migrations with:
php artisan vendor:publish --provider="Sawirricardo\LaravelWeb3\LaravelWeb3ServiceProvider" --tag="laravel-web3-migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Sawirricardo\LaravelWeb3\LaravelWeb3ServiceProvider" --tag="laravel-web3-config"
This is the contents of the published config file:
return [ 'network' => env('WEB3_NETWORK', 'localhost'), 'infura_id' => env('WEB3_INFURA_ID', ''), ];
Add this to your .env
WEB3_NETWORK=localhost #mainnet, mumbai, etc WEB_INFURA_ID=xxxxxxxxxxxxxxxxxx MIX_WEB3_NETWORK="${WEB3_NETWORK}" MIX_WEB3_INFURA_ID="${WEB_INFURA_ID}"
Then, add "account" to \App\Models\User fillables
// app/Models/User.php protected $fillable = [ 'email','name','password', 'account' //Add this ];
Also add this to your layout HTML
<body> <!-- it's best to drop this at the below --> <script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js" type="application/javascript" ></script> <script type="text/javascript" src="https://unpkg.com/web3modal@1.9.0/dist/index.js" ></script> <script type="text/javascript" src="https://unpkg.com/@walletconnect/web3-provider@1.6.5/dist/umd/index.min.js" ></script> <x-laravelweb3Scripts /> </body>
Usage
@guest <button onclick="laravelWeb3.onConnect()">Connect to wallet</button> @endguest @auth <button onclick="laravelWeb3.onDisconnect()">Disconnect wallet</button> @endauth
// return provider object by Ethers JS // Run wild, my friends const etherProvider = laravelWeb3.getProvider(); // LaravelWeb3 automatically register laravelWeb3 to window object for you to play. console.log({window.laravelWeb3});
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.