Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lunarfoundation/web3forauth0actions

Web3ForAuth0Actions allows developers to quickly introduce web3 capabilities into Auth0 Actions.
https://github.com/lunarfoundation/web3forauth0actions

actions auth0 crypto lunar web3

Last synced: about 2 months ago
JSON representation

Web3ForAuth0Actions allows developers to quickly introduce web3 capabilities into Auth0 Actions.

Awesome Lists containing this project

README

        


Lunar Foundation Logo


Lunar Foundation


The future of money is digital.




[![NPM Package][npm-badge]][npm-pkg-link]

## 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](https://marketplace.auth0.com/integrations/siwe) (SIWE).

## Getting Started

1. Open your Auth0 management console and navigate to 'Actions | Library' in the left-hand sidebar.
2. Click "Build Custom" in the header.
- Select "Login / Post Login".
- Select "Node 16" for the Runtime.
- Click the "Create" button.
3. Click on the "Dependencies" icon in the grey editor (the box icon).
- Type "web3-for-auth0-actions" in the textbox and click "Create".
4. Paste in the following code :
```javascript
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);
}
};
```
5. Click "Deploy" in the top right-hand corner.
6. Click "Flows" under "Actions" in the left-hand side bar.
7. Click "Login".
8. On the right-hand side, under "Add Action", select "Custom".
9. Drag your new Action into the Flow area.
10. Click "Apply"
11. Profit!!!

You now have some functioning badassery!

[npm-badge]: https://img.shields.io/npm/v/web3-for-auth0-actions?color=%236639E4&logo=NPM&style=for-the-badge
[npm-pkg-link]: https://www.npmjs.com/package/web3-for-auth0-actions