web3-for-auth0-actions
v0.0.8
Published
Web3ForAuth0Actions allows developers to quickly introduce web3 capabilities into Auth0 Actions.
Downloads
11
Readme
Web3ForAuth0Actions
Brought to you by the Lunar Foundation. https://lunar.io
A library for web3 functionality that can be leveraged in Auth0 Actions. Requires Sign In With Ethereum (SIWE).
Getting Started
- Open your Auth0 management console and navigate to 'Actions | Library' in the left-hand sidebar.
- Click "Build Custom" in the header.
- Select "Login / Post Login".
- Select "Node 16" for the Runtime.
- Click the "Create" button.
- Click on the "Dependencies" icon in the grey editor (the box icon).
- Type "web3-for-auth0-actions" in the textbox and click "Create".
- Paste in the following code :
exports.onExecutePostLogin = async (event, api) => {
// SHEPARD: If you have other apps that don't use this Action, exclude those from execution via Rules or Actions.
if (event.client.client_id !== 'YOUR APP ID HERE') return;
const { Web3ForAuth0Actions } = require("web3-for-auth0-actions");
const ContractAddress = "YOUR CONTRACT ADDRESS HERE";
Web3ForAuth0Actions.DebugMode = true;
// SHEPARD: Chain Id '56' is the BNB Chain Mainnet.
let [isValidReturn, returnMessage] = await Web3ForAuth0Actions.validateWalletBalance(event, 56, 1, ContractAddress);
console.log(`IsValidReturn: ${isValidReturn}`);
console.log(`ReturnMessage: ${returnMessage}`);
// SHEPARD: Bounce anyone that doesn't have the minimum balance in their wallet.
if (!isValidReturn) {
api.access.deny(returnMessage);
}
};
- Click "Deploy" in the top right-hand corner.
- Click "Flows" under "Actions" in the left-hand side bar.
- Click "Login".
- On the right-hand side, under "Add Action", select "Custom".
- Drag your new Action into the Flow area.
- Click "Apply"
- Profit!!!
You now have some functioning badassery!