This is a Laravel package that provides authentication context functionality using Proton. It allows you to easily integrate Proton login functionality into your Laravel application.
-
Add the following dependency in the composer.json
"repositories": [ { "type": "vcs", "url": "https://github.com/phoenixwade/proton_lareval" } ], "require": { "home-bloks/proton-auth-context": "dev-main" },
-
Run the following command to add the package in the vendor folder
composer update
-
Run the Proton authentication command:
php artisan proton:auth
-
Install the required npm packages:
npm install
-
Compile the assets:
for the development:npm run dev
OR
for production or server:npm run build
-
Update your
vite.config.js
file by adding the following code:import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), react(), ], });
-
Update your root JavaScript (entry point for react) file (e.g.,
App.jsx
,app.jsx
,Main.jsx
) with the following code:import ReactDOM from "react-dom/client"; import ProtonLoginButton from "./components/ProtonLoginButton"; import { AuthContextProvider } from "./store/auth.context.jsx"; ReactDOM.createRoot(document.getElementById("root")).render( <> <AuthContextProvider> <ProtonLoginButton /> </AuthContextProvider> </> );
-
Add the following code to your root template header before closing the
</head>
tag (welcome.blade.php by default):@viteReactRefresh @vite(['resources/js/app.jsx'])
Note: Make sure the
@vite('resources/js/app.jsx')
file matches the root JavaScript file you updated. -
Place the following code where you want to add the
ProtonLoginButton
component:<div id="root"></div>
You can change the
id
attribute according to your setup in the root JavaScript file. -
update your .env with following varibales:
VITE_MAINNET_ACCOUNT=account_name
VITE_MAINNET_CHAIN_NETWORK_ENDPOINTS=https://protontestnet.greymass.com
VITE_MAINNET_CHAIN_ID=71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd