# 📖 SDK Docs
Arcana Network provides two SDKs, the Chain Abstraction (CA) SDK and the Auth SDK. The CA SDK resolves liquidity fragmentation. It enables developers to let users spend a unified token balance across chains without bridging assets. The Auth SDK addresses account abstraction. It allows users to onboard via social login, skipping wallet creation. Both improve user experience and onboarding. Arcana also offers a standalone CA wallet for spending unified balances on select Web3 apps.
# Chain Abstraction
# Unify Balance Across Chains
Let users spend [any](../web3-stack/ca_stack/#tokens) crypto asset on [any](../web3-stack/ca_stack/#chains) blockchain instantly - no chain switching, no bridging, no cross-chain swaps necessary.
No hassle. Seamless transaction experience.
Integrate Web3 app with the Arcana's [Chain Abstraction](../concepts/ca/chain-abstraction/) (CA) SDK. Enable app users to access [unified balance](../concepts/ca/unified-balance/) from all chains in one place.
**TL;DR** | [Install](../ca/ca-sdk-installation/) | [Quick Start](#quick-start) | [Examples](../ca/examples/) | [Usage](../ca/ca-usage-guide/)
## Quick Start
What kind of Web3 app do you have?
Select the appropriate app type and get started with integrating the Arcana CA SDK.
[Web Apps](../quick-start/ca-quick-start/) [Wagmi Apps](../quick-start/ca-wagmi-quick-start/)
Advanced Usage
You can let Web3 app users onboard via [social login](../concepts/social-login/) and spend [unified balance](../concepts/ca/unified-balance/) on any chain through [chain abstracted transactions](../concepts/ca/chain-abstraction/). For this, the app must be integrated with both the Arcana CA SDK as well as the Arcana Auth SDK. [Learn more...](../quick-start/auth-ca-wagmi-quick-start/)
## Demo
Would you like to experience chain abstraction and how unified balance works before integrating a Web3 app with the Arcana CA SDK? Try the SDK integration demo app.
[### SDK Integration Demo](https://sdk.arcana.network)
## CA Playground
Seamless UX with unified balance across assets and chains
[### Try Now](https://codesandbox.io/p/github/arcana-network/ca-wagmi-example/main)
## Spend on Any Chain
Chain abstracted transactions are a game changer for Web3 app adoption. Integrate with Arcana CA SDK to enable unified balance in Web3 apps.
- **Unified Balance**
______________________________________________________________________
Spend on any chain with unified balance of funds on the source chains and sign transactions on any destination chain with a third-party browser-based wallet.
[Learn More...](../concepts/ca/unified-balance/)
- **Track Status**
______________________________________________________________________
Use Arcana Intent Explorer to track status of chain abstracted transactions.
[Learn More...](../concepts/ca/intent-explorer/)
- **Integration Examples**
______________________________________________________________________
Get up and running quickly with integration examples:
[`ca-sdk`](https://github.com/arcana-network/ca-sdk-example)
[`ca-wagmi`](https://github.com/shaloo/sample-arcana-ca-wagmi-sdk)
- **Resources**
______________________________________________________________________
Release notes, FAQ, audit reports, whitepaper and more.
[Learn more...](https://docs.arcana.network/relnotes/latest-ca-release-note/)
[Learn more...](../ca/why-ca-sdk/)
## Need Help?
📨 [Email Arcana Support](mailto:support@arcana.network)
✅ Be a part of the [Arcana Community](../support/). Stay informed about the new upcoming SDK capabilities and usage examples.
# CA Demo
Here is our showcase demonstrating chain abstraction technology.
We use a two pronged approach for demo purposes:
1. Web3 Apps: Show CA in the context of popular Web3 apps by using a special CA enabled wallet.
1. SDK Demo: Show through a sample app integration how devs can enable chain abstracted transactions in any Web3 app by integrating the app with Arcana CA SDK.
## 1. Web3 Apps
In these videos, you'll see how unified balance and chain abstracted transactions elevate the user experience in some of these popular Web3 apps.
Note, these demo videos use the [Arcana CA Wallet](https://chromewebstore.google.com/detail/arcana-wallet/nieddmedbnibfkfokcionggafcmcgkpi) which is specially implemented to showcase the unified balance and chain abstracted transactions. It is not meant to be used as a full-fledged Web3 wallet, yet.
Click on the app specific tab to see chain abstracted transactions in action.
## 2. SDK Demo
Developers can integrate the Arcana CA SDK with any Web3 app to let users spend [unified balance](../../concepts/ca/unified-balance/) across chains via chain abstracted transactions.
[CA SDK Demo](https://sdk.arcana.network)
Have a Web3 app?
*Have you integrated your app with our SDK?*
**We would be delighted to add your app integration demo here and share it with the larger Arcana [community](../../support/#arcana-community)!**
**Submit** a YouTube link at hello@arcana.network
# Chain Abstraction SDKs
Enable [unified balance](../../concepts/ca/unified-balance/) and [chain abstracted](../../concepts/ca/chain-abstraction/) transactions for Web3 app users.
You may need to install one or more Arcana SDK packages according to the app type.
Arcana CA SDK Flavors
Install the appropriate CA SDK as per Web3 app type:
| SDK Name | Web3 Application Type | Package Name | Dependency | | --- | --- | --- | --- | | Arcana CA SDK | For enabling unified balance in web apps: Vanilla HTML/CSS/JS Apps, Vite, Vue Apps | [`ca-sdk`](https://www.npmjs.com/package/@arcana/ca-sdk) | None | | Arcana CA Wagmi SDK | Wagmi Apps | [`ca-wagmi`](https://www.npmjs.com/package/@arcana/ca-wagmi) | [`ca-sdk`](https://www.npmjs.com/package/@arcana/ca-sdk) |
## Install SDKs
### Web Apps
```
npm install --save @arcana/ca-sdk
```
### Wagmi Apps
```
npm install --save @arcana/ca-sdk @arcana/ca-wagmi
```
# API: `ca-sdk`
Integrate Web3 app with the Arcana CA SDK's to enable:
- Unified balance
- Chain abstracted transactions
[Arcana CA SDK Reference](https://ca-sdk-ref-guide.netlify.app/)
Chain Abstraction allows Web3 app users to spend assets on **any** chain through [unified balance](../../concepts/ca/unified-balance/).
Web3 app developers can enable unified balance for app users by integrating the appropriate **Arcana** CA SDK flavor.
## Integration Flow
```
flowchart LR
subgraph Integrate [Select SDK for App Type]
direction LR
A00(((Start))) --> F00[App Type]
F00 -- Web App --> G00[Arcana CA SDK]
F00 -- Wagmi App --> H00[Arcana CA Wagmi SDK]
G00 & H00 --> I00(Install & Integrate)
end
classDef an-pink stroke:#ff4e9f,stroke-width:0.25rem;
class E00 an-pink
```
```
flowchart LR
subgraph Integrate [Integrate SDK with App]
direction LR
A00(((Start))) --> F00[Install SDK]
F00 -- Integrate App --> G00[Initialize SDK]
G00 --> H00(Call SDK Functions)
end
classDef an-pink stroke:#ff4e9f,stroke-width:0.25rem;
class E00 an-pink
```
## See Also
- [Chain Abstraction](../../concepts/ca/chain-abstraction/)
- [CA SDK](../../concepts/ca/casdk/)
- [Download Arcana CA SDK](https://www.npmjs.com/package/@arcana/ca-sdk)
# CA Users
Spend crypto on any blockchain instantly - no chain switching, no bridges, no hassle.
To enjoy [unified balance](../../concepts/ca/unified-balance/) Web3 users have two options:
**Option 1:** Log in to an app integrated with Arcana's' Chain Abstraction SDK and connect any third-party browser-based wallet to view unified balance and sign transactions. For example, you can log into the [CA SDK demo app](https://sdk.arcana.network) to experience unified balance.
Arcana CA SDK Demo App: Unified Balance
**Option 2:** [Download](https://chromewebstore.google.com/detail/arcana-wallet/nieddmedbnibfkfokcionggafcmcgkpi) Arcana's' standalone CA Wallet browser extension to view unified balance across supported [chains](../../web3-stack/ca_stack/#chains) and [tokens](../../web3-stack/ca_stack/#tokens). This wallet showcases the [chain abstraction](../../concepts/ca/chain-abstraction/) solution and unified balance feature for a **select group of popular** [Web3 apps](../../web3-stack/ca_stack/#apps).
Arcana CA Wallet
See wallet [Help](https://arcananetwork.notion.site/Help-Content-127f11ed0804805fba4dc72ad3f8cdb2) and [FAQ](https://arcananetwork.notion.site/Frequently-Asked-Questions-128f11ed080480ed8679d90e4bb0b96d) resources for details.
# API: `ca-wagmi`
Integrate Web3 apps using Wagmi with the Arcana CA Wagmi SDK's to enable:
- Unified balance
- Chain abstracted transactions
[Arcana CA Wagmi SDK Reference](https://ca-wagmi-sdk-ref-guide.netlify.app/)
# Examples
This is a Vue+TypeScript+Vite template that has been enhanced with the Arcana CA SDK integration code.
[GitHub](https://github.com/arcana-network/ca-sdk-example/)
[Try Now!](https://codesandbox.io/p/github/arcana-network/ca-sdk-example/main)
This Wagmi example app demonstrates how to integrate the Arcana CA Wagmi SDK with a Wagmi app.
[GitHub](https://github.com/arcana-network/ca-wagmi-example/)
[Try Now!](https://codesandbox.io/p/github/arcana-network/ca-wagmi-example/main)
This Wagmi example app demonstrates how to onboard users via social login and enable chain abstraction by integrating the Arcana CA Wagmi SDK and the Arcana Auth SDK with a Wagmi app.
[GitHub](https://github.com/shaloo/sample-arcana-auth-ca-wagmi-sdks)
[Try Now!](https://codesandbox.io/p/github/shaloo/sample-arcana-auth-ca-wagmi-sdks/sample-auth-ca-wagmi-integration)
# Why CA SDK?
Arcana’s Chain Abstraction SDK can integrate with any Web3 app and enable unified balance for the app users. Unified balance allows users to spend the consolidated multi-chain balance of source chain [tokens](../../web3-stack/ca_stack/#tokens) within the app context on any destination [chain](../../web3-stack/ca_stack/#chains).
This allows Web3 apps to onboard users from any ecosystem effortlessly. Integration with the SDK requires minimal effort.
## Onboard Users on Any Chain
- **Unified Balance**
______________________________________________________________________
Display users' consolidated balance across chains. Use Arcana’s plug-and-play UI or design your own.
- **Flexible Gas Payments**
______________________________________________________________________
Users can pay gas fees in USDC or USDT if they do not have native gas tokens.
- **Larger Transactions**
______________________________________________________________________
Users can seamlessly access and spend their entire multi-chain balance on the desired chain, in a single click.
- **No Lock-In**
______________________________________________________________________
All assets are in user's custody, no compulsion to rely on Arcana for accessing funds. Users can freely spend their assets on any app.
## Quick Integration
- **Frontend Code Updates**
______________________________________________________________________
Requires **minimal** changes to the Web3 app's front-end code.
- **No Smart Contract Changes**
______________________________________________________________________
Requires **zero** migration or updates to Web3 app's smart contracts.
- **Bring Existing Wallets**
______________________________________________________________________
Users can bring their existing EOA wallets such as MetaMask, Rabby, Rainbow, etc.
- **Assets: Zero Lockups or Transfers**
______________________________________________________________________
Users do not need to transfer their funds to a new wallet address or lockup in a smart contract.
Arcana CA SDK Demo App: Unified Balance
## Why Chain Abstraction?
Chain abstraction addresses multiple blockchain usability issues. It eliminates liquidity fragmentation, enabling users to spend the available source chain unified balance on any destination chain. This offers a superior user experience by eliminating the need for users to navigate multiple blockchain hoops (bridges, token swaps, and determining the optimal route to consolidate funds acceptable on the destination chain). With unified balance, users can onboard a new chain with no assets or spend on a destination chain where the EOA has insufficient funds.
The table below illustrates how the user experience is superior with a single-click chain abstracted transaction.
| UX: Transact on New Chain | No CA: Complex, Multi-step UX | With CA: One-step UX | | --- | --- | --- | | Figure out which chain your app runs on | | | | Hunt for the best bridge to move assets | | | | Fund gas tokens on different chains | | | | Track and transfer balances across chains | | | | Issue a transaction on a new chain | | |
[Learn more...](https://blog.arcana.network/)
# Integrate Wagmi App
Integrate ['Wagmi'](https://wagmi.sh/) apps with the [Arcana CA Wagmi SDK](../../../concepts/ca/casdk/) to enable:
- [Unified balance](../../../concepts/ca/unified-balance/)
- [Chain abstracted](../../../concepts/ca/chain-abstraction/) transactions
App users can spend funds on any chain. They do not need to switch chains or bridge assets.
## Prerequisites
Download and install the SDKs:
```
npm install --save @arcana/ca-sdk @arcana/ca-wagmi
```
## `CAProvider`
Initialize the `CAProvider` component and specify the `CA` object as the `client` param.
```
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { WagmiProvider } from 'wagmi'
import { CA } from "@arcana/ca-sdk";
import { CAProvider } from '@arcana/ca-wagmi'
import App from "./App.tsx";
import { config } from "./utils/config";
const ca = new CA();
const queryClient = new QueryClient()
createRoot(document.getElementById("root")!).render(
);
```
For `CAProvider` methods, see [Arcana CA Wagmi SDK Reference](https://ca-wagmi-sdk-ref-guide.netlify.app//modules).
The `CAProvider` component offers hooks with the same name as the Wagmi library.
Replace the `useSendTransaction` and `useWriteContract` hooks from the Wagmi library. Instead, use the versions provided by the SDK. These support chain abstracted transactions.
## Wagmi Hooks
Replace the following hooks used in the app from the Wagmi library with those from the Arcana CA Wagmi SDK package:
```
import { useSendTransaction, useWriteContract } from "@arcana/ca-wagmi";
// Replace the `wagmi` APIs `useSendTransaction` and `useSendTransactionAsync`
const { sendTransaction, sendTransactionAsync } = useSendTransaction();
// Replace the wagmi APIs `useWriteContract` and `useWriteContractAsync`
const { writeContract, writeContractAsync } = useWriteContract();
```
## Arcana Hooks
The SDK also provides hooks for:
- Accessing [unified balance](../../../concepts/ca/unified-balance/)
- Issuing chain abstracted bridge and transfer functions
- Getting a list of user intents
- [`useBalance`](#usebalance) - to get the unified balance value across all supported chains for the specified token string
- [`useBalances`](#usebalances) - to get the unified balance values across all supported chains for all supported tokens associated with the EOA
- [`useBalanceModal`](#usebalancemodal) - to display or hide the unified balance popup widget
- [`useCAFn()`](#usecafn) - for chain abstracted bridging and token transfer functionality
- [`useGetMyIntents()`](#usegetmyintents) - get the list of intents created by the user
### useBalance
The [`useBalance`](https://ca-wagmi-sdk-ref-guide.netlify.app/#md:usebalance) hook fetches the unified balance for the specified token. This is the value across all the supported chains associated with the user's EOA.
`useBalance({ symbol: string })`
#### Params
`symbol`: Required parameter of type `string` with the value equal to one of the supported currency/token symbol.
```
import { useBalance } from "@arcana/ca-wagmi"
const balance = useBalance({ symbol: "eth" })
```
#### Response
| Parameter | Type | | --- | --- | | loading | `boolean` | | value | `{ symbol: string, decimals: number, formatted: string, value: bigint} \| null` | | error | `Error \| null` |
Sample `useBalance` Response
```
{
loading: false,
value: {
symbol: "ETH",
decimals: 18,
formatted: "0.000785657313049966",
value: 785657313049966n
},
error: null
}
```
### useBalances
The [`useBalances()`](https://ca-wagmi-sdk-ref-guide.netlify.app/#md:usebalances) hook returns the unified balance value across all the supported chains and all the supported tokens associated with the user's EOA.
```
import { useBalances } from "@arcana/ca-wagmi"
const balances = useBalances()
```
#### Response
returns response contains the following fields:
| Parameter | Type | | --- | --- | | loading | `boolean` | | value | `UseBalanceValue[] \| null` | | error | `Error \| null` |
Sample `useBalances` Response
```
{
loading: false,
value: [{
symbol: "ETH",
decimals: 18,
formatted: "0.000785657313049966"
value: 785657313049966n,
breakdown: [{
chain: {
id: 1,
name: "Ethereum",
logo: "..."
},
formatted: "0.000785657313049966",
address: "0x0000000000000000000000000000000000000000",
value: 785657313049966n
}]
}],
error: null
}
```
### useBalanceModal
The [`useBalanceModal()`](https://ca-wagmi-sdk-ref-guide.netlify.app/#md:usebalancemodal) hook can be used in the app to display or hide the unified balance modal. This modal displays the following information:
- **Overall unified balance:** Total available balance in the user's EOA across all supported chains and tokens
- **Per token unified balance:** Total available token balance across all the supported chains, breakup in a list of chains and per chain token balance.
```
import { useBalanceModal } from "@arcana/ca-wagmi"
const { showModal, hideModal } = useBalanceModal()
```
#### Response
| Field | Type | | --- | --- | | showModal | `() => void` | | hideModal | `() => void` |
Plug & Play Unified Balance Widget
### useCAFn
The `useCAFn()` hook allows chain abstracted `bridge` and `transfer` transactions.
```
import { useCAFn } from "@arcana/ca-wagmi"
const { bridge, transfer } = useCAFn()
await bridge({
token: "usdt",
amount: "1.5",
chain: 42161
})
const hash = await transfer({to: "0x80129F3d408545e51d051a6D3e194983EB7801e8",
token: "usdt",
amount: "1.5",
chain: 10
})
```
#### Response
| Parameter | Type | | --- | --- | | bridge | `({ token: string, amount: string, chain: number }) => Promise` | | transfer | `({ token: string, amount: string, chain: number, to: "0x${string}" }) => Promise` |
`useCAFn`: Chain Abstracted Bridge and Transfer
### useGetMyIntents
Used to get a list of intents created by the user.
`useGetMyIntents(page)`
#### Params
`page`: Page number; 1 returns latest, max 100 results per page
```
import { useGetMyIntents } from "@arcana/ca-wagmi";
const getMyIntentsResponse = useGetMyIntents(1);
```
#### Response
`UseQueryResult`
**Sample Response**
```
{
isLoading: false,
isFetching: false,
isSuccess: true,
isError: false,
data: [{
id: 107,
sources: [{
universe: "ETHEREUM",
tokenAddress: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
value: 18531n,
chainID: 10,
}],
destinations: [{
tokenAddress: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
value: 10000n,
}],
destinationUniverse: "ETHEREUM",
destinationChainID: 42161
fulfilled: true,
refunded: false,
expiry: 1750070223,
deposited: true
}],
error: null
}
```
**Finished.**
The 'Wagmi' app is all set to let users spend on any chain via unified balance and chain abstracted transactions.
## See Also
Arcana CA Wagmi SDK Quick Links
- [Arcana CA Wagmi SDK Reference](https://ca-wagmi-sdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-ca-release-note/)
- [Changelog](https://github.com/arcana-network/ca-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/ca-wagmi)
[Try CA Wagmi SDK CodeSandbox](https://codesandbox.io/p/github/shaloo/sample-arcana-auth-ca-wagmi-sdks/sample-auth-ca-wagmi-integration)
# Integrate Web App
Integrate 'Web3' apps with the [Arcana CA SDK](../../../concepts/ca/casdk/) to enable:
- [Unified balance](../../../concepts/ca/unified-balance/)
- [Chain abstracted](../../../concepts/ca/chain-abstraction/) transactions
App users can spend funds on any chain. They do not need to switch chains or bridge assets.
## Prerequisites
[Download](https://www.npmjs.com/package/@arcana/ca-sdk) and install the SDK.
```
npm install --save @arcana/ca-sdk
```
## Initialize
```
import { CA } from '@arcana/ca-sdk'
```
```
const provider = window.ethereum
const ca = new CA();
//Set the EVM provider
ca.setEVMProvider(provider);
```
```
try {
await ca.init()
} catch (e) {
// Handle exception case
}
```
`ca.init()`
Use `await` until the `init()` call is complete. Then call any other `CA` method listed in the [Arcana CA SDK Reference](https://ca-sdk-ref-guide.netlify.app/).
## Unified Balance
Get unified balance on the supported source chains:
- View the total EOA balance for all supported tokens and chains.
- View the total EOA balance for a specified token across all chains.
```
//total chain abstracted unified balance across all chains/tokens
const balances = await ca.getUnifiedBalances();
//total balance for a specific token across all chains
const usdtBalance = await ca.getUnifiedBalance("usdt");
```
## CA Transactions
Enable chain abstracted transactions through:
- `transfer`
- `request`
- `bridge`
### `transfer`
Use unified balance for chain abstracted transactions.
```
const handler = await ca.transfer({
to: "0x...",
amount: 5,
chainID: 10, //optional, defaults to current chain
token: "eth",
});
// Execute the transfer
const hash = await handler.exec();
// Simulate the transfer, returns intent data and token info
const response = await handler.simulate();
```
### `request`
Replace the standard EIP-1193 provider with a chain-abstracted one using `getEVMProviderWithCA`. Then use it to call `request` with `eth_sendTransaction` to use unified balance.
```
const providerWithCA = ca.getEVMProviderWithCA();
await providerWithCA.request({
method: "eth_sendTransaction",
params: [
{
to: "0xEa46Fb4b4Dc7755BA29D09Ef2a57C67bab383A2f",
from: "0x7f521A827Ce5e93f0C6D773525c0282a21466f8d",
value: "0x001",
},
],
});
```
### Bridge
Use the unified balance to deposit tokens on a different chain. Chain abstracted transactions handle the transfer.
```
const handler = await ca.bridge({
token: "usdt",
amount: 10,
chainID: 137,
});
// Execute the bridge
await handler.exec();
// Simulate the bridge, returns intent data and token info
const response = await handler.simulate();
```
## Allowance
Allowances are set to `unlimited` by default for all supported chains and tokens. Developers can update the allowance settings via `setOnAllowanceHook()`. App users can approve chain abstracted transactions. They cannot change the allowance set by the app developers.
### `setOnAllowanceHook`
Use `setOnAllowanceHook` to set up [allowances](../../../concepts/ca/allowances/) for chain abstracted transactions. The default value is set to `unlimited` for all chains.
```
ca.setOnAllowanceHook(async ({ allow, deny, sources }) => {
// This is a hook for the dev to show user the allowances that need to be setup for the current tx to happen
// sources: an array of objects with minAllowance, chainID, token symbol etc
// allow(allowances): allowances is an array with allowance for each source (len(sources) == len(allowances))
// deny(): stop the flow
})
```
### Get Allowance
Get allowance values configured for the chain abstracted transactions.
```
// Get USDC allowance for Polygon
await ca.allowance().tokens(["USDC"]).chain(137).get()
// Get USDC & USDT allowance for all supported chains
await ca.allowance().tokens(["USDC", "USDT"]).get()
// Get all supported token allowances for all supported chains
await ca.allowance().get()
```
## Intents
### `setOnIntentHook`
Use `setOnIntentHook` to show the intent details such as the source of funds, applicable fees.
```
ca.setOnIntentHook(({ intent, allow, deny, refresh }) => {
// This is a hook for the dev to show user the intent, the sources and associated fees
// intent: Intent data containing sources and fees for display purpose
// allow(): accept the current intent
// deny(): deny the intent and stop the flow
// refresh(): should be on a timer of 5s to refresh the intent (if not refreshed old intents might fail due to fee changes)
})
```
### Get Intents
Get the list of intents representing user's request for funds.
```
import type { RFF } from "@arcana/ca-sdk"
const page = 1
const intentList: RFF[] = await ca.getMyIntents(page);
```
## Events
Keep track of the user [intent](../../../concepts/ca/intent/) processing stages.
Set up a listener to monitor various [intent processing stages](../../../concepts/ca/intent/#stages) during a chain abstracted transaction.
### Add Listener
```
ca.addCAEventListener((data) => {
switch(data.type) {
case "EXPECTED_STEPS":{
// store data.data(an array of steps which will be followed)
state.value.steps = data.data.map(s => ({ ...s, done: false }))
state.value.inProgress = true
break;
}
case "STEP_DONE": {
const v = state.value.steps.find(s => {
return s.typeID === data.data.typeID
})
if (v) {
v.done = true
}
break;
}
}
});
```
### Remove Listener
```
ca.removeCAEventListener((data) => {...})
```
Check out the [integration example](https://codesandbox.io/p/github/arcana-network/ca-sdk-example/main) code.
**Finished.**
The 'Web3' app is all set to let users spend on any chain via unified balance and chain abstracted transactions.
## See Also
Arcana CA SDK Quick Links
- [Arcana CA SDK Reference](https://ca-sdk-ref-guide.netlify.app/)
- [CA FAQ](../../../faq/ca/faq/)
- [Release notes](../../../relnotes/latest-ca-release-note/)
- [Changelog](https://github.com/arcana-network/ca-sdk/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/ca-sdk)
[Try CA SDK Demo](https://sdk.arcana.network)
[Vite + CA SDK Integration](https://codesandbox.io/p/github/shaloo/sample-arcana-ca-sdk/main?import=true)
# Chain Abstraction Architecture
Before we get into the details of Arcana's Chain Abstraction (CA) architecture, let's first understand some key concepts.
## What is CA?
Managing multiple chains, tokens, and accounts fragments wallet liquidity for Web3 users. Even with enough assets overall, funds scattered across chains make transacting difficult and require complex, time-consuming conversions.
Chain abstraction lets users access a [unified balance](../../../concepts/ca/unified-balance/) across all wallet-linked chains, enabling transactions anywhere. Instead of converting funds first, users specify a [clear intent](../../../concepts/ca/intent/). The protocol collects funds from source chains, shows intent and fees for confirmation, then publishes the intent to solvers. Solvers compete to provide liquidity on the destination chain, and once available, users confirm the transaction. Settlement with solvers happens asynchronously using the collected funds.
As part of setup, devs configure [allowances](../../../concepts/ca/allowances/) per chain and token. Users approve or reject these allowances. For [supported tokens](../../../web3-stack/ca_stack/#tokens) on [source chains](../../../web3-stack/ca_stack/#chains), the protocol uses these allowances to deposit required funds for transactions on the destination chain.
Arcana's Chain Abstraction
## Why Chain Abstraction?
Chain abstraction enables unified balance to simplify and streamline Web3 transactions. It offers:
- **Faster Intent Processing:** Enables quick and seamless transaction execution across chains.
- **Unified Liquidity:** Provides a consolidated view of user assets across wallet-linked chains with no asset bridging.
- **Simplified UX:** Removes multi-step hurdles for a seamless experience, making transactions easy for all users.
- **Streamlined DX:** Developers can add unified balances to dApps with minimal changes and no smart contract updates for new chains.
## Arcana CA Offerings
Arcana has two CA offerings, one targeted at the Web3 Users and the other for Web3 builders and developers.
- Web Apps: Arcana CA SDK
- Wagmi Apps: Arcana CA Wagmi SDK
- Arcana Wallet (Standalone)
## Architecture
Arcana's [Chain Abstraction (CA)](../../../concepts/ca/chain-abstraction/) protocol manages balances across multiple chains and tokens in Web3 apps. It solves liquidity fragmentation by enabling a unified balance across supported chains. The Arcana Vault smart contracts on each supported chain and the solver ecosystem are two key parts of the Arcana CA protocol. There’s no auction; it’s a first-come, first-served system where the first solver to accept an intent gets to fulfill it.
The user's EOA state and intents are managed across multiple chains. Approved intents are published for 'solvers' to fulfill. Solvers compete to fulfill these intents and provide liquidity on the destination chain. The protocol handles state transitions and settles solver payments using transaction netting.
How Arcana CA Works
## CA Protocol
1. Developer sets up Arcana Chain Abstraction settings enabling cross chain transactions on selected chain types and required [allowances](../../../concepts/ca/allowances/).
1. App users are required to permit the allowance values or reconfigure them if the app allows. Allowances enable Arcana Vault to collect required funds from the EOA account on one or more source chains, as per the user's intent.
1. User submits an intent to spend `n` tokens on a destination chain Y and transact via a Web3 app.
1. Arcana verifies that user has sufficient funds across the source chains in the user's EOA account and adequate allowances are pre-configured to enable chain abstraction, pay gas fees.
1. Funds are moved to the Arcana Vault and user's intent is announced to all listening solvers.
1. The assumption is that one of the available solvers in the system will agree to service the user's intent. As of today, only Arcana solver is supported. We are working with partners to onboard trusted third-party solvers into the ecosystem.
1. Once the solver services the intent and provides the necessary liquidity on the desired destination chain into the user's EOA, the user can instantly spend it.
1. Arcana takes care of managing the settlement at the agreed upon periodicity with the successful solvers. The settlement does not happen after every user transaction but after netting and verification process.
1. In case a transaction fails, or times out waiting for a solver, user's funds deposited from the source chain are refunded within a stipulated time period after verification.
Arcana's Chain Abstraction is designed for onboarding users across a wide range of applications, but it is particularly impactful for DeFi applications that depend on deposits in stablecoins like USDC or USDT, as well as native tokens like ETH.
Benefits
- Remove friction of bridging with a unified multi-chain balance
- Larger transaction values
- Launch apps on emerging chains while onboarding users from established ecosystems
## Swaps
Allow users to execute token swaps on a single chain DEX while using funds held in multiple assets across several chains as a unified balance. For example, a user holding ETH on Optimism and USDC on Arbitrum can seamlessly swap tokens to be able to spend USDT on Polygon without needing to bridge or consolidate assets manually. This removes friction for users, ensuring smoother transactions and higher conversion rates for swap protocols.
## Bridges
Bridges enable users to move funds from Chain A to Chain B, but when users hold disparate assets across multiple chains, they face the challenge of tracking and transferring funds chain by chain. With Arcana’s Chain Abstraction, users can bridge their entire multi-chain balance to the desired chain in one step.
Example
User holds USDC on Arbitrum, USDT on Polygon, some ETH on Optimism and wants to consolidate their funds on Arbitrum.
With chain abstraction, instead of manually bridging disparate tokens held across different chains, one at a time, users can issue a single intent to bridge their asset balance from source chains to a desired supported token on Arbitrum in a single step.
## Decentralized Exchanges (DEXes)
For liquidity providers and traders, fragmented funds across chains often hinder participation in DEXes. With Arcana, users can trade or provide liquidity on a single-chain DEX (for example, Optimism) using their unified balance from multiple chains, such as Ethereum, Polygon, and Arbitrum. This enables more efficient capital utilization, increases trading volumes, and expands access to liquidity for DEX platforms.
## Perpetuals Trading
For protocols that need users to deposit stable coins to a particular address on a specific chain (for example, Hyperliquid on Arbitrum) Arcana’s Chain Abstraction allows users to trade on a perpetual protocol on one chain, like Base, using a unified balance of funds held on Ethereum, Polygon, or other chains. This removes the need for manual bridging and ensures traders can respond quickly to market changes without delays in fund transfers.
## Prediction Markets
Prediction markets often have strong user bases tied to specific chains. Arcana’s Chain Abstraction allows users to stake or wager assets on a prediction market hosted on a single chain (for example, Polymarket on Polygon) using funds held across multiple chains. For instance, a user can use their combined stablecoin holdings from Ethereum and Polygon to place a bet on Polygon, ensuring greater cross-chain participation and deeper liquidity for these markets.
## Lending
Borrowers and lenders often face challenges when their assets are distributed across chains and they want to access new yield products on specific chains. With Arcana, a user can supply liquidity to a lending protocol on one chain, such as Ethereum, using their unified balance aggregated from other chains like Optimism and Base.
This leads to larger deposit and borrow transactions with the access to a larger pool of capital.
## Staking/Restaking
Restaking requires users to bring assets or derivatives to specific chains. Arcana enables users to stake or restake assets on a protocol running on a single chain (for example, Polygon) by leveraging their unified balance across multiple chains. For instance, a user with ETH on Ethereum and Arbitrum can stake and restake seamlessly on another chain without manual transfers.
This allows users from multiple EVM ecosystems to participate in the protocol.
*Stay tuned, Arcana is actively working on supporting additional use cases with the Arcana CA SDK.*
How do I fix the polyfilling issues right after import statement when integrating React and Vite app with the Arcana CA SDK?
To fix polyfilling issues, make sure `vite.config.ts` has the polyfilling options configured.
```
import { defineConfig, Plugin } from "vite";
import react from "@vitejs/plugin-react";
import { nodePolyfills, PolyfillOptions } from "vite-plugin-node-polyfills";
import tailwindcss from "@tailwindcss/vite";
const nodePolyfillsFix = (options?: PolyfillOptions | undefined): Plugin => {
return {
...nodePolyfills(options),
resolveId(source: string) {
const m =
/^vite-plugin-node-polyfills\/shims\/(buffer|global|process)$/.exec(
source
);
if (m) {
return `node_modules/vite-plugin-node-polyfills/shims/${m[1]}/dist/index.cjs`;
}
},
};
};
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
nodePolyfillsFix({
include: ["buffer"],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
],
define: {
"process.env": {},
},
});
```
Is there a refund if a chain abstracted transaction fails after funds have been pulled out of the source chains in the user's EOA?
For chain abstracted transaction safety, follow these guidelines:
1. **Failed transactions?** *Don't panic* - you'll get your tokens back automatically in the next settlement cycle (usually within 15 minutes but it may take an hour in some cases).
1. **Before transacting:** Always check the transaction details including the gas fee requirements, before issuing a transaction.
1. **During transacting:** The status of the chain abstracted transaction is displayed in the app's context. Click on 'View Intent' details link and **save** the unique intent identifier associated with the transaction. You'll need the **intent identifier** if something goes wrong.
1. **Track your transaction:** Use the [Arcana Intent Explorer](https://explorer.arcana.network/) with your intent ID to monitor status. **Critical:** Keep your app/wallet open and logged in if you encounter a failed transaction—refunds require an active session and typically complete within 15 minutes.
1. **No refund after 1 hour:** The protocol auto-retries, but you must stay logged in. If you closed the app/wallet, reopen and log back in to enable refund processing. Did not get a refund? Contact Arcana team via the [support](../../../support/) channels and make sure you mention the **intent identifier** that failed to refund or your wallet address with date / time of the transaction.
**Bottom line:** Your funds are protected - failed transactions always get refunded, either automatically or with the team's assistance.
Viewing Refund
To view the refund, the user must open or log into the app and access the wallet that was used to sign the intent and confirm the chain abstracted transaction.
Why is liquidity fragmentation an issue and how does chain abstraction solve it?
Liquidity fragmentation is an issue because it makes it difficult for users to spend their assets on any chain.
Let us take a simple case of a user's wallet that contains 3 USDC on Arbitrum and 2 USDC on Optimism. If the user intends to send 4 USDC on Base, it is not possible to do so through a traditional wallet because there is liquidity fragmentation for USDC in the wallet across Arbitrum and Optimism. To be able to send USDC on Base, there are multiple complex steps for the user.
First, there is no USDC on Base to be sent. The user cannot directly spend USDC on Base even though there are enough USDC tokens when put together on the other two chains in the same wallet account. To spend on Base, the user has to bridge tokens from one or more source chains. That is a complex, multi-step, multi-click, time-consuming process. It also needs non-trivial knowhow about secure bridging and getting the best token exchange deals. Next, the user is required to switch the network to Base and then send the tokens.
[Chain Abstraction (CA)](../../../concepts/ca/chain-abstraction/) enables unified balance across source chains that can help the user spend 4 USDC on Base with a single click. The user is not required to manually convert the tokens on Optimism or Arbitrum to make this transaction on Base. With a unified balance, onboarding a new chain does not necessarily require the user to procure tokens on the new chain. The user can pledge or sign an intent to send tokens from any of the source chains to the destination chain.
I'm a Web3 dApp developer. how can I enable unified balance for dApp users?
Download and [install the appropriate CA SDK flavor](../../../ca/ca-sdk-installation/) as per the app type.
- **Web3 apps**: Install the [Arcana CA SDK](https://www.npmjs.com/package/@arcana/ca-sdk). Check out the integration example in [codesandbox](https://codesandbox.io/p/github/arcana-network/ca-sdk-example/main)
- Web3 apps using the **Wagmi library**: Install the [Arcana CA Wagmi SDK](https://www.npmjs.com/package/@arcana/ca-wagmi). Try the [codesandbox](https://codesandbox.io/p/github/arcana-network/ca-wagmi-example/main) integration example.
Refer to the respective SDK quick start guide for integration details.
I'm a Web3 wallet user, how can I enjoy unified balance with chain abstraction?
Web3 wallet users can unify assets across chains and spend on any chain. To do this, they must log into a Web3 app that is integrated with the Arcana CA SDK and supports any third-party browser-based wallet.
Alternatively, wallet users can [download](https://chromewebstore.google.com/detail/arcana-wallet/nieddmedbnibfkfokcionggafcmcgkpi) and install the Arcana Standalone CA wallet browser extension to try [unified balance](../../../concepts/ca/unified-balance/) in the context of some of the popular [Web3 apps](../../../web3-stack/ca_stack/#apps).
Why do users need to pay gas fees to set up CA with Layer 1 chains?
When setting up Arcana chain abstraction to include Layer 1 chains, users need ETH to pay gas fees for signing the token allowance transaction with the Arcana vault smart contract. The Arcana standalone CA wallet doesn't cover these Layer 1 chain gas fees. As a result, users who choose to include Layer 1 chains in their CA scope must pay these gas fees themselves to set up the CA allowance.
What is a CA allowance and why are allowances needed?
Allowance or 'Permit' in the blockchain context allows a third party, such as a smart contract, to perform transactions from a user's EOA for a specified amount — without accessing the user's private key.
In Arcana chain abstraction, [allowances](../../../concepts/ca/allowances/) enable unified balance. This lets users spend on any destination chain when they have enough funds and gas fees on their source chains.
Which ERC20 tokens does the unified balance feature support?
Refer to the latest [supported token list](../../../web3-stack/ca_stack/#tokens).
Which chains does the unified balance feature support?
Arcana's chain abstraction and unified balance works for some select [chains](../../../web3-stack/ca_stack/#chains) and [tokens](../../../web3-stack/ca_stack/#tokens). We are working on adding support for more chains in the future.
Does dApp integration with the Arcana CA SDK enable an in-app wallet like the Auth SDK?
No there is no built-in in-app wallet offered by the Arcana SDKs. Web3 apps integrating with the Arcana CA SDK must use a third-party wallet for blockchain transactions.
How does a dApp access unified balance for a user account?
The dApp must download and integrate with the CA-SDK and use the EIP-1193 provider to access the unified balance in the context of an authenticated user. See [Arcana CA SDK Reference](https://ca-sdk-ref-guide.netlify.app/) and [the usage guide](../../../ca/ca-usage-guide/) for details.
Does the Arcana CA SDK enable unified balance and chain abstracted transactions in a Web3 app built using Wagmi?
For Web3 app built using Wagmi, integrate with the Arcana CA Wagmi SDK.
How do I enable unified balance and chain abstracted `sendTransaction`, `bridge` and `transfer` functions in a Web3 app that uses the Wagmi library?
To enable unified balance and chain abstraction in a Web3 app that uses the Wagmi library, integrate the app with the Arcana CA Wagmi SDK. This SDK replaces the Wagmi hooks: `useSendTransaction` and `useWriteContract`. Additionally, it provides hooks such as `useBalance`, `useBalanceModal` and `useCAFn` to enable unified balance plug-and-play popup modal and chain abstracted `bridge` and `transfer` functions. For details see [Arcana CA Wagmi SDK Quick Start Guide](../../../quick-start/ca-wagmi-quick-start/) and the [Arcana CA Wagmi SDK Reference](https://ca-wagmi-sdk-ref-guide.netlify.app/).
Who is the target audience for the Arcana CA SDKs?
Arcana CA SDKs help Web3 dApp developers handle fragmented blockchain assets, letting users spend on any chain. These SDKs can integrates with dApps to offer unified balances across chains and chain abstracted transactions.
For a complete list of real life applications of unified balance, see [use cases](../../../ca/introduction/use-cases/) section.
Who is the target audience for the standalone Arcana standalone CA wallet?
The standalone Arcana standalone CA wallet is meant for wallet users that want to try unified balance in the context of some of the popular [Web3 apps](../../../web3-stack/ca_stack/#apps).
It enables unified balance and solves liquidity fragmentation when using any of the supported [chains](../../../web3-stack/ca_stack/#chains) and [tokens](../../../web3-stack/ca_stack/#tokens) in the context of these supported [Web3 apps](../../../web3-stack/ca_stack/#apps). We will be adding support for newer Web3 apps soon.
$100 limit
The standalone Arcana standalone CA wallet has a $100 limit for transactions needing chain abstraction. Transfers on the same chain have no limit.
Can you give me an example of liquidity fragmentation and how the CA SDK solves it?
**Liquidity Fragmentation**
Imagine a user with assets spread across chains:
Arbitrum: 3 USDC Optimism: 4 USDC Base: 0 USDC Ethereum: 0.001 ETH
If the user wants to send 5 USDC to Base, they can't because no single chain has enough funds. Liquidity fragmentation forces the user to make multiple transactions, complicating the process.
**How unified balance through chain abstraction solves this?**
With chain abstraction, users first set up allowances before issuing a multi-chain transaction intent.
In this case, the user signs an intent to send 5 USDC to Base by pledging 3 USDC from Arbitrum and 2.2 USDC from Optimism (including gas and service fees). The intent specifies the amount to be deposited on source chains and the agreed amount received on the destination chain.
Arcana's Chain Abstraction protocol collects the pledged tokens and gas fees based on the user's allowances. Once the intent is signed, Arcana processes the 5 USDC transaction on Base and deducts the gas fee from the pledged USDC.
Can I request gas tokens using ERC20 through Arcana Chain Abstraction??
Yes, you can request gas tokens using ERC20 via Chain Abstraction.
For example, if you have 13 USDC and 0 ETH on Optimism but need to make a 15 USDC transaction requiring 0.0000001 ETH for gas, you'll need an extra 2 USDC plus the gas fee.
You can pledge or sign an intent to pay the additional USDC and gas fees using funds from other supported chains like Arbitrum or Base, assuming you have enough USDC to cover the deficit and fees.
Once you sign the intent, Arcana CA SDK supplies the needed USDC and gas in a single transaction. Charges include the deficit amount, CA Gas Fees, protocol fees, and Solver fees.
*Note: Fees are deducted from the main token requested, such as USDC. Arcana CA SDK supports ETH, USDC, and USDT.*
Can a user review intent details before issuing a transaction that requires chain abstraction with two or more source chain tokens?
Yes, user's can review the intent details before issuing a CA transaction via the Arcana CA Wallet. Before submitting a transaction, click 'View Intent' to see the intent details. Once the transaction is successful, there are options to view the intent details as well as the transaction details.
To view the intent details at a later point in time, you need to save the intent identifier displayed in the details during the transaction, before closing the wallet screen.
Use the Arcana Intent Explorer accessible at: and enter the intent ID to view details at a later time.
View Intent Details
Can I use `transfer` function to deposit chain abstracted unified balance funds to a smart contract and update the blockchain state?
No. `transfer` does not support `data`. Use [`request` with `sendTransaction`](https://ca-sdk-ref-guide.netlify.app/#quick-start) to deposit funds to a smart contract and update the blockchain state.
Sending 0.1 USDC from 0.3 USDC balance uses funds from other chains. Why isn't this a normal transaction since sufficient balance exists locally?
The transaction uses chain abstraction because you need both sufficient tokens AND gas fees for a normal transaction.
Even though 0.1 USDC < 0.3 USDC balance, the remaining 0.2 USDC may not cover the gas fees.
When local funds can't cover transaction amount + gas fees, the system pulls from other chains' allowances to make up the difference, making it a chain-abstracted transaction instead of normal.
# Auth
# Web3 Made Effortless
Seamlessly onboard Web3 app users without friction. Web3 app usage should not necessitate setting up and connecting a Web3 wallet for login and authentication.
Onboard Web3 app users via familiar Web2 login providers. Enable authenticated users to immediately access the in-app, non-custodial Arcana wallet for signing blockchain transactions.
Integrate Web3 apps with the Arcana Auth SDK to enable [social login](../concepts/social-login/).
**TL;DR** | [Setup](../setup/config-auth/register-app/) | [Install](../auth/sdk-installation/) | [Quick Start](#quick-start) | [Examples](https://github.com/arcana-network/auth-examples) | [Usage](../introduction/)
## Quick Start
What kind of Web3 app do you have?
Select the appropriate app type and get started with integrating the Arcana Auth SDK.
[Wagmi](../quick-start/wagmi-quick-start/) [RainbowKit](../quick-start/rainbowkit-quick-start/) [Web3-React](../quick-start/web3-react-quick-start/) [WalletConnect](../quick-start/walletconnect-quick-start/) [HTML/CSS/JS](../quick-start/vanilla-web-apps-quick-start/) [React/NextJS](../quick-start/react-nextjs-quick-start/) [Vue](../quick-start/vue-quick-start/)
[Solana](../quick-start/solana-quick-start/) [MultiversX](../quick-start/mvx-quick-start/) [Near](../quick-start/near-quick-start/)
[React-Native](../quick-start/react-native-quick-start/) [Flutter](../quick-start/flutter-quick-start/)
[Unity](../quick-start/unity-quick-start/)
Advanced Usage
You can let Web3 app users onboard via [social login](../concepts/social-login/) and spend [unified balance](../concepts/ca/unified-balance/) on any chain through [chain abstracted transactions](../concepts/ca/chain-abstraction/). For this, the app must be integrated with both the Arcana CA SDK as well as the Arcana Auth SDK. [Learn more...](../quick-start/auth-ca-wagmi-quick-start/)
## Demo
Would you like to experience how social login works without actually integrating your Web3 app with the Arcana Auth SDK? Try the SDK integration demo app.
[### SDK Integration Demo](https://demo.arcana.network)
## Auth Playground
[### Try Now](https://codesandbox.io/p/github/shaloo/auth-sdk-example-vite-vue/main?import=true)
## Onboard with Zero Friction
Let users log into your Web3 app securely without having to deal with Web3 specific complexities. Integrate with Arcana Auth SDK to enable social login.
- **Social Login**
______________________________________________________________________
Enable Web2-like login in Web3 apps with Arcana Auth SDK and enable in-app Arcana wallet.
[Learn More...](../concepts/social-login/)
- **Set up in 2m**
______________________________________________________________________
Use Arcana Developer Dashboard to register app, configure settings and manage user experience.
[Configure](../setup/config-dApp-with-db/)
- **Integration Examples**
______________________________________________________________________
Get up and running quickly with these integration examples for various supported Web3 apps.
[Integration Examples](https://github.com/arcana-network/auth-examples)
- **Resources**
______________________________________________________________________
Release notes, migration guides, Dashboard Settings Guide, FAQ, integration checklists and more.
[Resources](https://docs.arcana.network/relnotes/latest-auth-release-note/)
## Need Help?
📨 [Email Arcana Support](mailto:support@arcana.network)
✅ Be a part of the [Arcana Community](../support/). Stay informed about the new upcoming SDK capabilities and usage examples.
[Integration Checklist](../checklists/)
# Auth-Core SDK
The Arcana Auth-Core SDK is a client-side tool for developers to assign Web3 keys to authenticated users for signing blockchain transactions. Use this SDK instead of the Arcana Auth SDK for key assignment or when building a completely whitelisted solution.
When initializing Arcana Auth-Core SDK, the developer sets the redirect URL. The SDK performs OAuth2 login with the chosen provider and returns the login token from the provider. At the specified redirect URL, the developer uses this token to fetch the user's private key.
Limited Feature SDK
The Arcana Auth-Core SDK has limited capabilities as compared to the Arcana Auth-Core SDK:
- No built-in plug-and-play login UI feature
- No built-in Arcana wallet UI
- No support for Global keys, only app-specific keys (default) are allowed.
- No support for enhanced wallet security via MFA.
Contact [support](mailto:support@arcana.network) to access the latest release.
[SDK Reference](https://auth-core-sdk-ref-guide.netlify.app/)
## Installation
### npm
```
npm install --save @arcana/auth-core
```
### yarn
```
yarn add @arcana/auth-core
```
### CDN
```
```
```
```
## Usage
### Import
```
const { AuthProvider, SocialLoginType, CURVE } = window.arcana.auth_core;
// or
import { AuthProvider, CURVE } from '@arcana/auth-core';
```
### Initialize `AuthProvider`
```
const auth = new AuthProvider({
curve: CURVE.ED25519, // defaults to CURVE.SECP256K1
appId: `${appId}`,
redirectUri: ''
});
```
### Initiate Social Login
```
await auth.loginWithSocial(SocialLoginType.google);
```
### Initiate Passwordless Login
```
const result = await auth.loginWithPasswordlessStart(`${emailAddress}`, PasswordlessOptions);
```
### Get Login Status
```
const loggedIn = auth.isLoggedIn(); /* boolean response */
```
### Get User Info
After successful login, the user information is saved in memory. Before the page `unload` event, the user information gets stored in `session-storage`. After a successful page reload, it is fetched again to memory and removed from the `session-storage`.
```
const userInfo = auth.getUserInfo();
/*
UserInfo: {
loginType: 'google',
userInfo: {
id: 'abc@example.com',
name: 'ABC DEF',
email: '',
picture: ''
},
privateKey: ''
}
*/
```
For userInfo type details, see [Exported Types](#exported-types).
### Get Public Key
```
const publicKey = await auth.getPublicKey({
verifier: SocialLoginType.google,
id: `abc@example.com`,
});
```
For details regarding `SocialLoginType`, see [Exported Enums](#exported-enums).
### Clear Login Session
```
await auth.logout();
```
## TypeScript Usage
### Exported Enums
```
enum SocialLoginType {
apple = 'apple',
google = 'google',
discord = 'discord',
twitch = 'twitch',
github = 'github',
twitter = 'twitter',
telegram = 'telegram',
passwordless = 'passwordless',
}
```
### Exported Types
```
interface KeystoreInput {
id: string;
verifier: LoginType;
}
interface InitParams {
// arcana app id with network hint, ex xar_dev_xyz - xyz is the appId
appId: string;
network?: 'dev' | 'testnet'| 'mainnet'; /* defaults to testnet */
/**
* autoRedirect: is redirected via SDK, instead of `loginWithSocial`
* output being `{ url }`
*/
autoRedirect: boolean /* defaults to true */
/**
* shouldVerifyState: state is compared internally, the state is stored
* to local storage on login init
*/
shouldVerifyState: boolean /* defaults to true */
/**
* revokeTokenPostLogin: Some tokens need to be revoked to get new tokens
* on subsequent login or to prevent misuse, SDK does this internally. If
* set to `false` there is a cleanup function that is output of the func
* `auth.handleRedirectMode()` which should be called after token is used
* for secondary purpose
*/
revokeTokenPostLogin: boolean /* defaults to true */
debug?: boolean; /* defaults to false */
}
interface GetInfoOutput {
loginType: SocialLoginType;
userInfo: UserInfo {
id: string;
email?: string;
name?: string;
picture?: string;
};
privateKey: string;
}
```
## Flow Modes
### Redirect
`login.js`
```
window.onload = async () => {
const auth = new AuthProvider({
appId: `${appId}`,
redirectUri:'path/to/redirect'
});
googleLoginBtn.addEventListener('click', async () => {
await auth.loginWithSocial(SocialLoginType.google);
});
}
```
`redirect.js`
```
window.onload = async () => {
const auth = new AuthProvider({
appId: `${appId}`,
redirectUri:'path/to/redirect'
});
await auth.handleRedirect();
if(auth.isLoggedIn()) {
const info = auth.getUserInfo();
}
}
```
### Variables
- `origin` - Base URL of the app.
# Auth Demo
Do you wish to experience how social login can remove the friction of onboarding users to any Web3 app before you try to enable that in your Web3 app?
Experience the power of social login for onboarding Web3 apps in a frictionless manner. Click to log into the Arcana Auth SDK demo app.
[### SDK Integration Demo](https://demo.arcana.network)
This sample app integrated with the Arcana Auth SDK, demonstrates the following features:
- Any user, even those who do not yet have their own keys or a wallet to connect to the app, can onboard Web3 app integrated with the Arcana Auth SDK.
- Use of familiar Web2 authentication mechanisms (for example, Google, passwordless login, etc.) to onboard Web3 app
- Automatic access to a secure, self-custodial, in-app, embedded, built-in Arcana wallet right after user authenticates.
- No need to download or set up a Web3 wallet - own your in-app wallet and its assets.
- Upon subsequent log ins, access the same wallet.
- In-app wallet allows users to import keys if they wish to use EOA accounts associated with any third-party browser-based wallets.
# Auth Errors
If you integrate a Web3 app with the Arcana Auth SDK, you might encounter some of the following errors depending on user actions, app logic, and the sequence of Arcana Auth SDK function calls.
For more insights, refer to the [Arcana Auth SDK troubleshooting guide](../../troubleshooting/).
## Error Messages
| Error | Description | | --- | --- | | wallet_not_initialized | Wallet is not initialized. Please run `await wallet.init()` before calling any other wallet functions. | | user_not_logged_in | User is not logged in. First, trigger user login and after successful authentication, you can use wallet functions. |
## Passwordless Authentication Errors
| Error | Description | | --- | --- | | authorize_params_missing | Missing one or more required params. | | login_token_already_used | Login token is invalid or has already been used. | | login_token_not_found | Login token not found in query params. | | login_token_invalid | Login token is invalid. | | user_token_not_found | User token not found in header or query. | | user_token_invalid | User token is invalid. |
# Arcana Auth SDK Usage
Use the Arcana Auth SDK to onboard users via social login, allow users to access the in-app Arcana wallet and sign blockchain transactions.
\[[Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)\](https://authsdk-ref-guide.netlify.app/)
## Installation
### NPM/Yarn Install
```
npm install --save @arcana/auth
yarn add @arcana/auth
```
### CDN Install
```
```
```
```
______________________________________________________________________
## Quick Start with `ethers.js`
```
import { AuthProvider } from '@arcana/auth'
import { ethers } from 'ethers'
// clientId: Arcana Unique App Identifier via Dashboard
const auth = new AuthProvider(`${clientId}`)
window.onload = async () => {
try {
await auth.init()
const arcanaProvider = await auth.connect()
const provider = new ethers.providers.Web3Provider(arcanaProvider)
await provider.getBlockNumber()
// 14983200
} catch (e) {
// log error
}
}
```
______________________________________________________________________
## Quick Start with `web3.js`
```
import { AuthProvider } from '@arcana/auth'
import Web3 from 'web3'
// clientId: Arcana Unique App Identifier via Dashboard
const auth = new AuthProvider(`${clientId}`)
window.onload = async () => {
try {
await auth.init()
const arcanaProvider = await auth.connect()
const provider = new Web3(arcanaProvider)
await provider.getBlockNumber()
} catch (e) {
// log error
}
}
```
______________________________________________________________________
## Usage
### AuthProvider
#### Import AuthProvider
```
const { AuthProvider } = window.arcana.auth // From CDN
// or
import { AuthProvider } from '@arcana/auth' // From npm
```
#### Initialize AuthProvider
```
import { AuthProvider } from '@arcana/auth'
const auth = new AuthProvider(`${clientId}`, {
position: 'left', // default - right
theme: 'light', // default - dark
alwaysVisible: false, // default - true
setWindowProvider: true, // default - false
connectOptions: {
compact: true, // default - false
},
})
await auth.init()
```
See [Get Started with Auth SDK](https://docs.arcana.network/quick-start/wagmi-quick-start/) for more Auth SDK usage insights.
### Auth API
#### Plug and Play Authentication
```
const provider = await auth.connect()
```
#### Custom Login
Social login
```
// loginType - Apple, Cognito, Discord, GitHub, Google, Steam, Twitch, Twitter
const provider = await auth.loginWithSocial(`${loginType}`)
// Note: Use loginWithBearer method for Telegram, Firebase
```
Passwordless login via an email verification OTP
```
await auth.loginWithLink(`${email}`)
```
Deprecated
`loginWithLink` is deprecated.
Use `loginWithOTPStart`, `loginWithOTPComplete` for passwordless login with OTP. The OTP will be received via email supplied in `loginWithOTPStart` call.
Passwordless login via OTP
```
try {
const loginState = await auth.loginWithOTPStart("john.doe@somemail.com");
await loginState.begin()
if(loginState.isCompleteRequired) {
// App is using default app-specific keys
// App must ask the user to input a 6-digit code received in mail
var userInput = prompt("Please enter a 6-digit code:", "111111");
// Validate if the input is a 6-digit code
if (userInput !== null &&
userInput.length === 6 &&
!isNaN(userInput)) {
const complete = await auth.loginWithOTPComplete(
userInput,
onMFARequired() => {
//Hide overlay, if used in the app
});
console.log("complete:",complete);
} else {
console.log("Invalid input. Please enter a valid 6-digit code.");
}
} else {
// App is using global keys, built-in OTP input UI is displayed by the SDK
// App is not required to add code for OTP input
}
} catch (e) {
console.log(e);
}
```
Check if a user is logged in
```
const isloggedIn = await auth.isLoggedIn() // boolean
```
Check and reconnect, if required, within a 30-minute window after logout.
```
const canReconnect = await auth.canReconnect()
// auth.reconnect() should be on a click event since it opens a new tab
await auth.reconnect()
```
Get user information. The loginToken is a JWT Token that can be verified by using the public JWT Key. In the future this will be deprecated. Refer to userDIDToken. It is base64 encoded data
`base64(JSON.stringify([sig, claims]))`
```
const info = await auth.getUser()
/*
interface UserInfo {
address: string;
email?: string;
id: string;
userDIDToken: string;
loginToken: string;
loginType: Logins | "passwordless";
name?: string;
picture?: string;
publicKey: string;
}
*/
```
Show wallet UI
```
auth.showWallet()
```
#### Logout
```
await auth.logout()
```
### Get Public Key
Get the public key associated with an email.
```
await auth.getPublicKey(`${email}`)
```
### Encryption
#### ECIES Encryption
The wallet uses ECIES to decrypt cipher text, so a complementary encryption method has to be used from package `eth-crypto`.
```
import EthCrypto from 'eth-crypto'
const encrypted = await EthCrypto.encryptWithPublicKey(
'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...', // publicKey
'foobar' // message
)
```
______________________________________________________________________
## Arcana Wallet Operations
Arcana wallet is an embedded Web3 wallet offered via the Auth SDK. It uses [Ethereum JSON-RPC](https://ethereum.github.io/execution-apis/api-documentation/) to interact with the blockchains.
### JSON RPC Support
Arcana wallet implements the following common interfaces exposed by all Ethereum clients:
- [eth_accounts](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_accounts)
- [eth_getBalance](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance)
- [eth_sendTransaction](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
- [eth_sign](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign)
- [eth_call](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call)
### Switching Chains
#### `wallet_addEthereumChain`
This method is specified by [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085).
```
try {
await provider.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0xABCDEF',
chainName: 'My Custom Chain',
rpcUrls: ['...']
}]
})
} catch(error) {
...
}
interface AddEthereumChainParameter {
chainId: string; // A 0x-prefixed hexadecimal string
chainName: string;
nativeCurrency: {
name: string;
symbol: string; // 2-6 characters long
decimals: 18;
};
rpcUrls: string[];
blockExplorerUrls?: string[];
}
```
#### `wallet_switchEthereumChain`
This method is specified by [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326).
```
try {
await provider.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xf00' }],
});
} catch(error) {
...
}
interface SwitchEthereumChainParameter {
chainId: string; // A 0x-prefixed hexadecimal string
}
```
If the error code (error.code) is 4902, then the requested chain has not been added, and you have to request to add it via `wallet_addEthereumChain`.
#### `wallet_watchAsset`
This method is specified by [EIP-747](https://eips.ethereum.org/EIPS/eip-747)
```
await provider.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: '0xB983E01458529665007fF7E0CDdeCDB74B967Eb6',
symbol: 'FOO',
decimals: 18,
image: 'https://foo.io/token-image.svg',
},
},
})
```
Check out [Auth SDK Reference Guide](https://authsdk-ref-guide.netlify.app/) for details.
# Integrate Custom Auth App
Integrate ['Custom-Auth'](../../concepts/authtype/custom-auth/) apps with [Arcana Auth SDK](../../concepts/authsdk/) and allow authenticated users to sign blockchain transactions with the in-app [Arcana wallet](../../concepts/anwallet/).
## Prerequisites
- The app should be [registered and configured for using custom Auth](../../setup/config-custom-auth/) using the Arcana Developer Dashboard.
- You will require the following to integrate the app with the SDK:
- Unique *Client ID* assigned to the app after registration.
- *Provider identifier* value displayed in the registered app settings in the dashboard **after configuring and saving** the custom Auth settings.
## 1. Install
Depending upon the [app type](../../web3-stack/apps/), you may need to [install one or more SDKs](../sdk-installation/) and the integration code may vary from one app type to another.
## 2. Integrate App
Select the app type and follow the instructions to integrate the app with the SDK.
[HTML/CSS/JS App](../integrate/vanilla-html-css-js/) [React/Next.js App](../integrate/react-nextjs/) [Wagmi App](../integrate/wagmi/) [WalletConnect App](../integrate/walletconnect/) [RainbowKit App](../integrate/rainbow/) [Web3-React App](../integrate/web3-react/) [Unity App](../integrate/unity/)
[Flutter Apps](../mobile/flutter-get-started/) [React-Native Apps](../mobile/react-native-get-started/)
[Custom Auth](./)
No user onboarding
When using custom authentication, apps **do not onboard users** via the social login feature of the Arcana Auth SDK. Simply integrate with the SDK, access `AuthProvider` and call `loginWithCustomProvider` to provision the user's keys for signing blockchain transactions.
## 3. Call `loginWithCustomProvider`
After the user logs in successfully via custom authentication solutions, get the JWT and provide it as input to the Arcana Auth SDK method below:
```
await auth.loginWithCustomProvider({
token: params.token, //JWT Token
userID: params.userID, // Email or ID as configured in the Dashboard settings
provider: "provider-id-name", //Custom Auth Provider identifier displayed in the Dashboard
});
```
Upon success, `loginWithCustomProvider` will ensure that the authenticated user's key shares are fetched locally and the user key is generated within the app/user context securely, with full privacy.
Sample Code
Refer to [Custom Auth Frontend](https://github.com/arcana-network/custom-provider-fe-example) and [Custom Auth Server](https://github.com/arcana-network/custom-provider-server-example) for details. These are examples of a custom authentication server and a frontend that uses the `loginWithCustomProvider` method for fetching authenticated user's keys to perform blockchain transactions.
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../web3-ops/evm/) in the authenticated user's context.
## See also
**'Custom-Auth'** integration example: See `sample-auth-custom-oauth` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../faq/faq-gen/)
- [Troubleshooting Guide](../../troubleshooting/)
- [Arcana Auth SDK Errors](../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Custom Wallet UI
Learn how a Web3 app can use a custom wallet UI instead of the default, built-in, [Arcana wallet](../../concepts/anwallet/) UI and integrate with the [Arcana wallet](../../concepts/authsdk/) to enable [social login](../../concepts/social-login/) and allow users to sign blockchain transactions.
## Prerequisites
To log into the Arcana Developer Dashboard, you’ll need an account with a supported social login or use email for passwordless access.
- Google
- GitHub
- Twitch
- Discord
## 1. Dashboard Login
Use to log in with one of the available options.
Developer Dashboard Login Page
Aggregate Login
The [aggregate login](../../concepts/aggregatelogin/) feature in the Arcana Auth SDK merges login identities from social providers into one Arcana account if the email ID is the same across these providers. Developers can log into the Arcana Developer Dashboard using any supported provider and still access the same Arcana account and app settings.
## 2. Register App
Use the dashboard to create a new app entry and [register the app](../../setup/config-auth/register-app/). While specifying the new app name and other details, specify the **Wallet UI Mode** setting as 'Custom UI'. By default, it is set to use the built-in, Arcana wallet UI. Then click the 'Create' button to confirm app registration. Once registered, you cannot change the **Wallet UI Mode** setting.
Choose Custom Wallet UI
## 3. Configure Social Login
Follow the instructions to [configure social login](../../setup/) and [custom IAM providers](../../setup/config-idm/) if required, before integrating the app with the Arcana Auth SDK.
## 4. Integrate App
Select the app type and follow the instructions to integrate the app with the SDK.
[HTML/CSS/JS App](../integrate/vanilla-html-css-js/) [React/Next.js App](../integrate/react-nextjs/) [Wagmi App](../integrate/wagmi/) [WalletConnect App](../integrate/walletconnect/) [RainbowKit App](../integrate/rainbow/) [Web3-React App](../integrate/web3-react/) [Unity App](../integrate/unity/)
[Flutter Apps](../mobile/flutter-get-started/) [React-Native Apps](../mobile/react-native-get-started/)
[Custom Auth](../custom-auth/)
## 5. Onboard Users
Apps that are integrated with the Arcana Auth SDK can choose the built-in [plug-and-play login UI](../../concepts/plug-and-play-auth/) or use custom login ui to onboard users.
User Onboarding Considerations
1. **Log in Options:** What options are offered by the app to the onboard users via social login? *Configure the required [social login providers](../../setup/config-auth/) via the dashboard.*
1. **Built-in or Custom Login UI:** Does the Web3 app have a custom login UI or do they need to use the built-in, [plug-and-play login UI](../../concepts/plug-and-play-auth/) modal offered by the Arcana Auth SDK? *Choose the appropriate onboarding functions of the `AuthProvider`.*
1. **Session Management:** Does the authenticated user stay logged in if they accidentally close the browser tab? If yes, what is the acceptable Web3 app security window for the session? After how long should the session expire and a user re-login is necessitated for security? *Configure the [session management settings](../../setup/config-dApp-with-db/#login-session-management) via the dashboard.*
1. **Reconnect:** Does the Web3 app allow users to stay connected or require re-authentication after a certain time has elapsed? *Use `isConnected`, `canReconnect` and `reconnect` functions of the `AuthProvider`.*
[Wagmi Apps](../onboard/wagmi/wagmi-pnp-ui/) [RainbowKit Apps](../onboard/rainbow/rainbow-pnp-ui/) [WalletConnect Apps](../onboard/walletconnect/walletconnect-pnp-ui/) [Web3-React Apps](../onboard/web3-react/web3-react-pnp-ui/) [React/Next.js Apps](../onboard/react-nextjs/use-plug-play-auth/) [Vanilla HTML/CSS/JS App](../onboard/vanilla/use-plug-play-auth/) [Vue App](../onboard/vue/use-plug-play-auth/) [Flutter Apps](../mobile/flutter-get-started/) [React-Native Apps](../mobile/react-native-get-started/)
[Wagmi Apps](../onboard/wagmi/wagmi-custom-ui/) [RainbowKit Apps](../onboard/rainbow/rainbow-custom-ui/) [WalletConnect Apps](../onboard/walletconnect/walletconnect-custom-ui/) [Web3-React Apps](../onboard/web3-react/web3-react-custom-ui/) [React/Next.js Apps](../onboard/react-nextjs/custom-ui/) [Vanilla HTML/CSS/JS App](../onboard/vanilla/custom-ui/) [Vue App](../onboard/vue/custom-ui/) [Flutter Apps](../mobile/flutter-get-started/) [React-Native Apps](../mobile/react-native-get-started/)
## Advanced
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Reconnect Users
Use `canReconnect` and `reconnect` methods of `AuthProvider` within a 30-min window of the user-logout action. Allow users to automatically reconnect to the app without re-authentication.
See [`canReconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#canReconnect) and [`reconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#reconnect) for details.
Apps Using Custom Auth
Web3 apps that use custom user authentication solutions and require authenticated users to sign blockchain transactions can also integrate with the Arcana Auth SDK. These apps can skip the social onboarding feature and use `loginWithCustomProvider` function of the `AuthProvider` to assign keys securely. [Learn more...](../custom-auth/)
## 6. Plug in Custom Wallet UI
Once user onboarding logic is in place, add code to wire your custom wallet UI to enable wallet operations.
- Issue Wallet Ops
- Manage User Control
- Export Private Key
### Issue Wallet Ops
During app integration with Arcana Auth SDK, an `AuthProvider` is created. This provider is a standard Ethereum EIP-1193 provider. It facilitates wallet interactions with the blockchain. Use `AuthProvider` to call the [JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) and handle [Web3 wallet operations for the selected chains](../web3-ops/evm/). Add code to trigger wallet actions like sending transactions, signing messages, and executing contract calls.
Sample Code
The following code snippet shows how an HTML/CSS/JS app can integrate with the Arcana Auth SDK, onboard users via plug-and-play login UI and use the standard EIP-1193 Ethereum provider for issuing blockchain transactions through a custom wallet UI.
```
import { AuthProvider } from "@arcana/auth";
import { ethers } from 'ethers';
let provider;
const auth = new AuthProvider('xar_live_nnnnnnnnnnnnnnncdddddddd') //Use registered app client Id
// initialize the Arcana AuthProvider before calling any AuthProvider functions
...
await auth.init()
...
// onboard users - for e.g. using plug-and-play ui
const arcanaProvider = await auth.connect()
// alternatively, onboard users by calling loginWithLink(deprecated), `loginWithOTPStart`, `loginWithOTPComplete`, loginWithSocial, loginWithBearer for passwordless, social or IAM providers.
...
const provider = new ethers.providers.Web3Provider(arcanaProvider)
// Call ethers provider APIs see https://docs.ethers.org/v5/api/providers/provider/ for details
await provider.getBlockNumber()
// Use the Arcana provider to sign a message using JSON RPC calls
async function signMessage() {
// Display a notification in custom wallet UI showing the message details and seeking user's approval
...
// Once user approves, issue the request via the Arcana Auth SDK to sign transaction
const { sig } = await arcanaProvider.request({
method: 'eth_sign',
params: [
{
from, // sender account address
data: 'Some message data',
},
],
})
console.log({ sig })
}
...
// You can send tokens or use eth_sendtransaction functionality in custom wallet UI
// Show a UI notification displaying the transaction details and ask for user's approval
...
// Use the Arcana provider to issue the send transaction
async function sendTransaction() {
const hash = await arcanaProvider.request({
method: 'eth_sendTransaction',
params: [{
from,
gasPrice: 0,
to: '0xE28F01Cf69f27Ee17e552bFDFB7ff301ca07e780', // receiver account address
value: '0x0de0b6b3a7640000',
},],
})
console.log({ hash })
}
...
```
### Manage User Control
For a smooth user experience, ensure your custom UI displays clear approval/rejection prompts when blockchain requests are made. Users must be able to view the details and accept or reject these actions.
### Export Key Option
When using the default Arcana wallet UI, authenticated users can access and copy their private key from the profile tab. For custom wallet UI, developers should include secure options for users to export their private key. Use the `AuthProvider` to access the private key and make a JSON/RPC `request` call with the `_arcana_getPrivateKey` method to retrieve the key securely in the user's context.
Sample Code
```
// Only valid when custom wallet UI is selected in the dashboard
// during app registration
async function onClickGetUserPrivateKey() {
const authProvider = window.ethereum //assuming setWindowProvider is set when AuthProvider was instantiated
try {
const userPkey = await authProvider.request({
method: '_arcana_getPrivateKey',
params: []
});
// Do something with the key in custom wallet UI
// For e.g., display it in the app context, allow user to copy it
} catch(error) {
console.log(error);
};
}
```
Access Limitation
If the app is configured through the Arcana Developer Dashboard for using the default [app specific keys option](../../concepts/keyspace-types/), then `_arcana_getPrivateKey` can be used. Not available for the Global Keys [Keyspace configuration setting](../../concepts/keyspace-types/) for security reason.
## What's Next?
Add code to use the `AuthProvider` and issue blockchain transactions in the context of the authenticated user and seek the user's approval, if required. The JSON/RPC functions and Web3 wallet operations supported by the Arcana Auth SDK for [EVM chains](../web3-ops/evm/) may differ from those supported for the non-EVM chains. [Learn more...](../../concepts/non-evm-chains/)
## See also
- [FAQ](../../faq/faq-gen/)
- [Troubleshooting Guide](../../troubleshooting/)
- [Arcana Auth SDK Errors](../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
# Handle Provider Events
This guide lists the standard EIP-1193 events raised by the `AuthProvider` in the Arcana Auth SDK and how app developers can handle those events in the app.
## Prerequisites
- To receive and handle the `AuthProvider` events, register the app, configure social login and wallet settings and integrate the app with the SDK.
## Events
`AuthProvider` emits the following standard [EIP-1193 events](https://eips.ethereum.org/EIPS/eip-1193#events):
- **connect**: the provider is ready to submit the blockchain requests to the chain on behalf of the user (*Use `provider.isConnected()` to check if the `AuthProvider` is connected.*)
- **disconnect**: the `AuthProvider` is unable to submit RPC requests to a chain
- **chainChanged**: the chain associated with the Provider has changed
- **accountsChanged**: the `AuthProvider` emits this event when the return value of the `eth_accounts` RPC method changes
After initialization, when the provider is ready to submit the blockchain requests to the chain on behalf of the user, the **connect** event is generated. Use `provider.isConnected()` to check if the `AuthProvider` is connected. The **disconnect** event occurs when there is any connectivity issue with the blockchain network. If the chain is switched programmatically via the app and approved by the user or if it is changed via the Arcana wallet UI by the user, the **chainChanged** event occurs. Similarly, when the account associated with the `AuthProvider` changes, the **accountsChanged** event is emitted.
## Examples
### Connect Event
```
interface ConnectEventInfo {
chainId: string;
}
const auth = new AuthProvider("...")
await auth.init()
...
auth.provider.on('connect', handler: (data: ConnectEventInfo) => void);
```
### Disconnect Event
When the `AuthProvider` becomes disconnected from the chains it emits the event `disconnect` with the error [ProviderRpcError](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors).
```
interface ProviderRpcError extends Error {
code: number;
data?: unknown;
}
const auth = new AuthProvider("...")
await auth.init()
...
auth.provider.on('disconnect', handler: (error: ProviderRpcError) => void);
```
### Chain Changed Event
```
const auth = new AuthProvider("...")
await auth.init()
...
auth.provider.on('chainChanged', (chainId: string) => {
console.log(chainId);
// Use chainId
});
```
### Accounts Changed Event
If the accounts available to the `AuthProvider` change, it emits the event **accountsChanged** with value **accounts: string[]**, containing the account addresses.
```
const auth = new AuthProvider("...")
await auth.init()
...
auth.provider.on('accountsChanged', handler: (accounts: Array) => void);
```
Remove Listener
Make sure that you remove event listeners once you're done listening to an event in the app. For example:
```
const auth = new AuthProvider("...")
await auth.init()
...
function handleSomeEvent(accounts) {
// Handle the event
}
auth.provider.on('someEvent', handleSomeEvent);
// Later, when the component is unloaded or you are done watching the event
auth.provider.removeListener('someEvent', handleSomeEvent);
```
**That is all.**
*You are all set to handle the events emitted by the `AuthProvider`.*
## What's Next?
Authenticated users can use the Arcana wallet to sign blockchain transactions, send and receive native, ERC20, or custom tokens, and [more](../../user-guides/wallet-ui/).
## See also
- [Arcana wallet capabilities](../../concepts/anwallet/)
- [Using Web3 wallet operations](../../user-guides/wallet-ui/)
Apps using Arcana Auth SDK can enable passkey login in two ways:
- Allow new users to sign up with passkeys, making it the only login option.
- Let existing users set up passkeys as an alternative login method, alongside other social login options.
## Passkey Sign-up
To sign up with passkeys, use `registerWithPasskey()`, followed by `loginWithPasskey()`. This will allow users to sign up and log in one step. Users must provide a unique identifier for passkey registration such as a name, email, device ID, biometrics data, PIN, or pattern. This sign-up flow is ideal for apps that only allow passkey onboarding. [See details...](../onboard/passkey-auth/passkey-signup/)
## Passkey Login
To use passkeys as an alternative login, users first need to onboard through another method, like social login. Once logged in, they can set up a passkey for future logins. Use `linkPasskey()` to create and associate passkey with the app or website. Next time, when user chooses passkey option to log in, the app can call `loginWithPasskey()`, triggering the device or browser to display a UI where the user can choose the previously set passkey. This flow works best for apps that support multiple onboarding methods. [See details...](../onboard/passkey-auth/passkey-login/)
# Install Arcana Auth SDK
Arcana Auth SDK supports various [app types](../../web3-stack/apps/). You may be required to install one or more Arcana Auth SDK packages depending upon the app type.
For example, Vue apps, HTML/CSS/JS apps only require installation of the `auth` package. For other app types, you may need to install app-type-specific packages along with the companion `auth` package. See table for more details:
Arcana Auth SDK Flavors
In some cases, you need to install and integrate the app with the `auth` package in addition to the app-specific package listed below.
| SDK Name | Web3 Application Type | Package Name | Requires companion SDK | | --- | --- | --- | --- | | Arcana Auth SDK | For enabling user onboarding in web apps: Vanilla HTML/CSS/JS Apps, Vue Apps | [`auth`](https://www.npmjs.com/package/@arcana/auth) | None | | Arcana Auth React SDK | React Apps | [`auth-react`](https://www.npmjs.com/package/@arcana/auth-react) | [`auth`](https://www.npmjs.com/package/@arcana/auth) | | Arcana Auth Wagmi SDK | Apps using wallet connectors such as Wagmi, RainbowKit, WalletConnect | [`auth-wagmi`](https://www.npmjs.com/package/@arcana/auth-wagmi) | [`auth`](https://www.npmjs.com/package/@arcana/auth) | | Arcana Auth Web3 React SDK | Apps using Web3-React wallet connector | [`auth-web3-react`](https://www.npmjs.com/package/@arcana/auth-web3-react) | [`auth`](https://www.npmjs.com/package/@arcana/auth) | | Arcana Auth Flutter SDK | Mobile apps built using Flutter | `arcana_auth_flutter` | None | | Arcana Auth React-Native SDK | Mobile apps built using React Native | `auth-react-native` | None | | Arcana Auth-Core SDK | Auth SDK for user onboarding features usage only and ability to assign keys to authenticated users, with no embedded wallet feature | `auth-core` | None | | Arcana Auth Unity SDK | Gaming apps built using Unity | `arcana-auth-sdk` | None |
## Arcana Auth SDK
### HTML/CSS/JS, Vue Apps
```
npm install --save @arcana/auth
```
```
yarn add @arcana/auth
```
### React/Next.js Apps
```
npm install --save @arcana/auth @arcana/auth-react
```
```
yarn add @arcana/auth @arcana/auth-react
```
### Wagmi/RainbowKit/WalletConnect Apps
**Wagmi 2.0**
```
npm install --save @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
npm install --save @arcana/auth-wagmi@2.0.0 @arcana/auth
```
**Wagmi 2.0**
```
yarn add @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
yarn add @arcana/auth-wagmi@2.0.0 @arcana/auth
```
### Web3-React Apps
```
npm install --save @arcana/auth-web3-react @arcana/auth
```
```
yarn add @arcana/auth-web3-react @arcana/auth
```
### Unity Framework
Download the Arcana Auth Unity SDK package: [https://npm-registry.arcana.network/](https://npm-registry.arcana.network/-/web/detail/arcana-auth-sdk). Unzip the contents and copy them to the **Assets** folder of the Unity Project.
Unity Settings
Developers must update the Unity Project settings in addition to installing the Arcana Auth Unity SDK. This is required to enable SDK usage in Unity Apps. See [Unity Setup](../../quick-start/unity-quick-start/#1-unity-setup-auth-install).
## Mobile SDKs
### Flutter Apps
pubspec.yaml
```
dependencies:
flutter: # Required for every Flutter project
sdk: flutter # Required for every Flutter project
flutter_localizations: # Required to enable localization
sdk: flutter # Required to enable localization
arcana_auth_flutter: ^0.0.6
```
### React-Native Apps
```
npm i @arcana/auth-react-native
(cd ios && pod install)
```
# Wallet UI Errors
The Arcana wallet users may encounter the following run-time errors when using the wallet to sign blockchain transactions or while using other wallet UI features such as adding or switching networks, setting up enhanced security via [MFA](../../concepts/mfa/), etc.
## Error Messages
| Error | Description | | --- | --- | | W-101: RPC URL is already specified in profile. | Cannot add this RPC URL more than once. | | W-102: Chain Id already exists in profile. | Cannot add same chain ID more than once. | | W-103: This network is currently active. Select a different to make it active. | You may be trying to switch to a network which is already selected as the active network. Try again. | | W-104: Enter the pin to continue. | For enhanced security via MFA, you need to enter the pin to authorize access. | | Wallet address copied. | The wallet address is copied successfully to the clipboard. | | W-105: Please enter a valid wallet address. | Check the specified wallet address for the blockchain transaction. | | Answer all the questions to recover the key. | You must answer at least 3 security questions correctly in order to authorize access. | | Each questions must be unique! | You cannot specify the same security question more than once during MFA setup or recovery. | | W-106: Please provide the gas fee. | You have not specified the required gas fees for this transaction. | | W-107: Insufficient balance to pay for the gas fee. | Top up your account to pay for the gas fee, otherwise the transaction will fail due to insufficient balance. | | W-108: Cannot estimate gas fee. Please try again later. | For some unknown reason, we are not able to estimate the gas fees for this transaction. The network may not be responding or loaded so try again after some time. | | W-109: Gas limit cannot be set to a value less than the required gas fee for this transaction. | You have set up a gas limit which is insufficient to cover the gas fees for this transaction, change the gas limit. | | W-110: Enter all the details to continue. | You need to provide all the required details before this transaction can occur. | | Token Added successfully. | - | | Token already added. | This token is already available in the wallet, you cannot add it more than once. | | Token belongs to Ethereum Mainnet. | This token is not available on the current selected network but on the Mainnet, try switching network. | | Token sent successfully. | - | | W-111: Insufficient balance for specified transfer amount. | The account balance is insufficient for this transaction. Try topping up the balance before performing this transaction. | | W-112: Amount cannot be greater than the maximum available balance. | The amount of tokens specified should be less than or equal to the balance available in the current account. | | NFT Added. | - | | NFT already added. | This NFT is already added to the wallet, cannot add an NFT more than once. | | W-112: Unsupported NFT. | The wallet supports only these NFT types: ERC-721, ERC-1155. | | W-113: You don't have ownership for this NFT. | Cannot add NFT to the current wallet as this wallet address does not own the specified NFT. | | NFT Deleted. | - | | W-114: Insufficient NFTs. At most, you can send NFTs. | The quantity of NFTs specified in the transaction is more than available NFTs, fix and resubmit the transaction. | | W-116: Error creating NFT. Please try again. | - | | W-115: Invalid contract address. | - | | MFA setup completed. | - | | W-116: Incorrect answers. | MFA recovery answers are not correct, recovery failed. | | W-117: Incorrect pin. | MFA recovery failed due to incorrect pin. | | W-118: Please fill in all the questionnaires. | - | | W-119: Questions cannot be repeated. | - | | W-120: Questions cannot be empty. | - | | W-121: User cancelled the setup. | MFA setup was cancelled by the user, no enhanced security is set up for this account. | | W-122: Incorrect combination of chain Id and RPC URL. | Check RPC URL does not match with the specified chain Id. | | W-123: Invalid RPC URL! | Check the RPC URL and provide the correct one for the blockchain. | | W-124: Failed to copy. | Could not copy the selected item in the wallet UI. | | W-125: Failed to copy wallet address. | The wallet address could not be copied to the local clipboard. | | W-126: Failed to get balance. | Could not retrieve the balance for the current wallet address. It could be an intermittent error due to network issues. | | W-148: No valid wallet is associated for the given address. | The specified address does not belong to a valid wallet. | | W-127: Invalid token Id. | Check the token Id specified while manually adding a token asset through the wallet UI. | | W-128: Error occurred while setting up MFA. Please try again! | Retry MFA Setup. | | W-129: Please enter a valid quantity. | Check the number of tokens specified in the transaction. It should be less than or equal to the balance available. | | W-130: Please make the request again. | For some unknown reason the request failed, try again. | | W-131: Something went wrong, please try again. | Unknown error, try again. | | W-132: Please fill all values! | All input values must be specified, they are not optional in this case. | | W-133: Failed to initialize one or more on-ramps. | Transak encountered an error while initializing the on-ramp provider, try again. | | W-134: Could not get token. | Login failure as the token is not available. | | W-136: Failed to add to activities list. | Due to some unknown reason, the activity tab was not updated for this current transaction. | | W-137: Could not verify credentials. | Passwordless login failed as the OTP/email link credentials could not be verified successfully. | | W-138: Could not contact parent page causing login failure. Retry login. | Redirect to the specified URL failed causing a failed login. Check auth settings. | | W-139: Could not log in, an unexpected error occurred. | Login failed unexpectedly, try again and report error if it persists. | | W-140: Local or session storage doesn't work, falling back to in-memory storage. | There is some unknown issue in the local or session storage of the browser, falling back to in-memory storage. Your changes may not be saved across browser sessions. | | W-141: Required params missing. | Token validation error, expected input parameters are missing. | | W-142: Token already added. | The token already exists in the wallet, cannot be added more than once. | | W-143: Token belongs to Ethereum Mainnet. | You can use the Mainnet Token only when using the Mainnet App Client ID. Check the integration code. | | W-144: Invalid contract address. | The specified contract address for the transaction is invalid, check again. | | W-145: You do not own this token. | Token can be added to the wallet or transacted only if it is owned by the wallet address. | | W-146: Invalid token. | Invalid JWT Token specified for accessing keys. | | W-147: Failed to fetch details. | Token validation failed as details could not be fetched and verified. |
# Integrate MultiversX App
Integrate 'MultiversX' apps with [Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-mvx/) the 'MultiversX' app and configure the Arcana Auth SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
MultiversX Shard Selection
MultiversX uses [adaptive state sharding](https://docs.multiversx.com/technology/adaptive-state-sharding/) for horizontal scaling. Shards allow it to process far more transactions through parallelization, improving transaction throughput and efficiency.
Choose your shard once when registering a MultiversX app on the Arcana Developer Dashboard. It cannot be changed later.
By default, Arcana uses 'Shard 0' to deploy all app contracts and allocate wallet addresses for users. The benefit is that when addresses from the same shard interact with contracts on the same shard, latencies are much lower than in cross-shard interactions.
## 1. Install
Depending upon the [app type](../../../web3-stack/apps/), you may need to [install one or more Arcana Auth SDK flavors](../../sdk-installation/) and the integration steps may vary.
## 2. Integrate App
Select your 'MultiversX' app type and follow the integration instructions.
[HTML/CSS/JS App](../vanilla-html-css-js/) [React/Next.js App](../react-nextjs/) [Wagmi App](../wagmi/) [WalletConnect App](../walletconnect/) [RainbowKit App](../rainbow/) [Web3-React App](../web3-react/) [Unity App](../unity/)
[Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Custom Auth](../../custom-auth/)
## What's Next?
Add code to [onboard users](../../onboard/mvx/). Use `AuthProvider`, the standard EIP-1193 Web3 provider to call support JSON/RPC functions and Web3 wallet operations. [Learn more...](../../web3-ops/mvx/)
## See also
**'MultiversX'** integration example: See `sample-auth-multiversx` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [MultiversX FAQ](../../../faq/faq-mvx/)
[Try Demo App](https://demo.arcana.network)
# Integrate Near App
Integrate 'Near' apps with [Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-near/) the 'Near' app and configure Arcana Auth SDK SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## 1. Install
Depending upon the [app type](../../../web3-stack/apps/), you may need to [install one or more Arcana Auth SDK SDK flavors](../../sdk-installation/) and the integration steps may vary.
## 2. Integrate App
Select your 'Near' app type and follow the integration instructions.
[HTML/CSS/JS App](../vanilla-html-css-js/) [React/Next.js App](../react-nextjs/) [Wagmi App](../wagmi/) [WalletConnect App](../walletconnect/) [RainbowKit App](../rainbow/) [Web3-React App](../web3-react/) [Unity App](../unity/)
[Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Custom Auth](../../custom-auth/)
## What's Next?
Add code to [onboard users](../../onboard/near/). Use `AuthProvider`, the standard EIP-1193 Web3 provider to call support JSON/RPC functions and Web3 wallet operations. [Learn more...](../../web3-ops/near/)
## See also
**'Near'** integration example: See `sample-auth-near` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [Near FAQ](../../../faq/faq-near/)
[Try Demo App](https://demo.arcana.network)
# Integrate Rainbow App
[RainbowKit](https://www.rainbowkit.com/) allows Web3 apps to connect to multiple Web3 wallets. It relies on [Wagmi](https://wagmi.sh/) and [Viem](https://viem.sh/).
Integrate 'RainbowKit' apps with Arcana Auth SDK and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'RainbowKit' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
**Wagmi 2.0**
```
npm install --save @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
npm install --save @arcana/auth-wagmi@2.0.0 @arcana/auth
```
**Wagmi 2.0**
```
yarn add @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
yarn add @arcana/auth-wagmi@2.0.0 @arcana/auth
```
### 2. Create `AuthProvider` & `ArcanaConnector`
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi"
const auth = new AuthProvider('your-client-id');
const connector = new ArcanaConnector({ auth });
```
`AuthProvider` Optional Parameters
Besides Client ID input parameter, you can optionally customize these settings in the `AuthProvider` constructor:
______________________________________________________________________
**`position`:** wallet position within the app context - `left`|`right`
**`theme`:** wallet theme - `light`|`dark`
**`connectOptions`:** [compact mode](../../../concepts/plug-and-play-auth/#compact-modal) for the built-in plug-and-play login UI - `true`|`false`
```
connectOptions: {
compact: true // default - false
},
```
______________________________________________________________________
See [`AuthProvider` constructor parameters](https://authsdk-ref-guide.netlify.app/interfaces/constructorparams) for details.
Compact Mode
While creating the `AuthProvider`, you can choose the [compact mode (optional)](../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
### 3. Create `ArcanaRainbowConnector`
Initialize the `connectorsForWallets` in the RainbowKit with the `ArcanaRainbowConnector`.
```
//This example uses Arcana Rainbow connector and MetaMask
import { connectorsForWallets } from "@rainbow-me/rainbowkit";
import { metaMaskWallet } from "@rainbow-me/rainbowkit/wallets";
import { getAuthProvider } from "./getArcanaAuth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { sequenceLogo } from "./logo";
export const ArcanaRainbowConnector = ({ chains }) => {
return {
id: "arcana-auth",
name: "Login with Email/Social",
iconUrl: sequenceLogo,
iconBackground: "#101010",
createConnector: () => {
const connector = new ArcanaConnector({
chains,
options: {
auth: getAuthProvider()
}
});
return {
connector
};
}
};
};
const connectors = (chains) =>
connectorsForWallets([
{
groupName: "Recommended",
wallets: [ArcanaRainbowConnector({ chains }), metaMaskWallet({ chains })]
}
]);
export { connectors };
```
Use the `ArcanaRainbowConnector` and set up `WagmiConfig`.
```
// Note:
// This sample code is for
// wagmi versions 1.x.x and auth-wagmi 2.0.0
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { polygon, mainnet, optimism, arbitrum } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { connectors } from "./wallet";
import { useAccount, useConnect } from 'wagmi'
import { Connect } from "./Connect";
const { chains, publicClient } = configureChains(
[mainnet, polygon, optimism, arbitrum],
[publicProvider()]
);
const wagmiEntity = createConfig({
connectors: connectors(chains),
autoConnect: true,
publicClient,
});
...
```
```
// Note:
// This sample code is for
// wagmi versions <1.x.x and auth-wagmi <2.0.0
import "../styles/globals.css";
import "@rainbow-me/rainbowkit/styles.css";
import { configureChains, createClient, WagmiConfig } from "wagmi";
import { polygon, mainnet } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { connectors } from "../utils/wallet";
const { chains, provider } = configureChains(
[mainnet, polygon],
[publicProvider()]
);
const wagmiEntity = createClient({
connectors: connectors(chains),
autoConnect: true,
provider,
});
...
```
Use the `WagmiConfig` to initialize the `RainbowKitProvider` components in the app.
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
The 'RainbowKit' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/rainbow/rainbow-pnp-ui/) or a [custom login UI](../../onboard/rainbow/rainbow-custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'RainbowKit'** integration example: See \`\`sample-auth-rainbowkit-viem`, `sample-auth-rainbowkit\` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Integrate React/Next.js App
Integrate 'React/NextJS' apps with[Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'React/NextJS' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
```
npm install --save @arcana/auth
```
```
yarn add @arcana/auth
```
```
npm install --save @arcana/auth @arcana/auth-react
```
```
yarn add @arcana/auth @arcana/auth-react
```
### 2. Initialize `AuthProvider`, `ProviderAuth`
```
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { AuthProvider } from "@arcana/auth";
import { ProvideAuth } from "@arcana/auth-react";
import App from "./App";
const rootElement = document.getElementById("root");
const root = createRoot(rootElement);
const provider = new AuthProvider(
"xar_live_d7c88d9b033d100e4200d21a5c4897b896e60063"
);
root.render(
);
```
```
import React from "react";
import { Auth } from "@arcana/auth-react";
export default function App() {
return (
;
}
if (!isLoggedIn) {
return (
);
}
}
export default App
```
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/react-nextjs/use-plug-play-auth/) or a [custom login UI](../../onboard/react-nextjs/custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'React/NextJS'** integration example: See `sample-auth-react` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Integrate Solana App
Integrate 'Solana' apps with [Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-Solana/) the 'Solana' app and configure Arcana Auth SDK SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
Select your 'Solana' app type and follow the integration instructions. Solana apps will require to initialize and use **Solana Provider** in addition to the `AuthProvider`.
## 1. Install
Depending upon the [app type](../../../web3-stack/apps/), you may need to [install one or more Arcana Auth SDK SDK flavors](../../sdk-installation/) and the integration steps may vary.
### 2. Integrate App
Select your 'Solana' app type and follow the integration instructions.
[HTML/CSS/JS App](../vanilla-html-css-js/) [React/Next.js App](../react-nextjs/) [Wagmi App](../wagmi/) [WalletConnect App](../walletconnect/) [RainbowKit App](../rainbow/) [Web3-React App](../web3-react/) [Unity App](../unity/)
[Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Custom Auth](../../custom-auth/)
## 3. Initialize Solana Provider
Solana apps can use the `auth.provider` to make standard JSON RPC calls in the context of an authenticated user.
```
const provider = auth.provider;
```
Use the Solana provider for issuing Solana Web3 wallet operations in the context of an authenticated user.
```
const solanaP = auth.solana;
```
## What's Next?
Add code to [onboard users](../../onboard/solana/). Use `AuthProvider`, the standard EIP-1193 Web3 provider to call support JSON/RPC functions and Web3 wallet operations. [Learn more...](../../web3-ops/solana/)
## See also
**'Solana'** integration example: See `sample-auth-solana` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [Solana FAQ](../../../faq/faq-solana/)
[Try Demo App](https://demo.arcana.network)
# Integrate Unity App
Integrate 'Unity' apps with [Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-Unity/) the 'Unity' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Setup
#### Setup Unity
- Install [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity).
- In the NuGet Toolbar at the top, click **NuGet > Manage NuGet packages**.
Manage NuGet Packages
- Install the following packages by STA: `Nethereum.Web3`, `WebsocketSharp.Core`
- Use the Unity Editor Project Settings window to edit package settings for your project. Click **Edit > Project Settings > Package Manager**.
- [Edit Project Settings](https://docs.unity3d.com/Manual/class-PackageManager.html) with URL **https://npm-registry.arcana.network/** and set the scope to `com.cysharp.unitask, dev.voltstro`
Edit Project Settings
- Add another new scoped registry with URL **https://unitynuget-registry.azurewebsites.net** and set the scope to `org.nuget`.
Add Scoped Registry
- In the NuGet window, use the NuGet Toolbar at the top, and click **Window > Package Manager > Add Package by Name**.
Add Package by Name
- Add the following packages: `com.cysharp.unitask`, \`\`dev.voltstro.unitywebbrowser.engine.cef\`
- **Windows**: `dev.voltstro.unitywebbrowser.engine.cef.win.x64`
- **Linux**: `dev.voltstro.unitywebbrowser.engine.cef.linux.x64`
- **MacOS**: `dev.voltstro.unitywebbrowser.engine.cef.macos.x64`
See [Unity Web Browser package list](https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/packages/#package-list) for details.
- Download the Arcana Auth Unity SDK package: [https://npm-registry.arcana.network/](https://npm-registry.arcana.network/-/web/detail/arcana-auth-sdk). Unzip the contents and copy them to the **Assets** folder of the Unity Project.
- Search for **ArcanaSDK** prefab in the 'Project Window' of the Unity Editor. Click **Assets > ArcanaSDK > Prefabs > ArcanaSDK**. Drag this prefab into the project 'Hierarchy' and configure the prefab as shown here:
Configure Arcana Prefab
#### Install Auth SDK
```
npm install --save @arcana/auth
```
```
yarn add @arcana/auth
```
### 2. Initialize Auth SDK
```
using ArcanaSDK;
await arcanaSDK.InitializeSDK(env, "unique_clientID_for_registed_app");
```
## What's Next?
After integrating an app with the Arcana Auth Unity SDK, developers can add code to [onboard users](../../onboard/unity/) and [enable Web3 wallet operations](../../web3-ops/unity-wallet-ops/) for authenticated users to sign transactions.
## See also
**'Unity'** integration example: See `sample-auth-unity` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
[Try Demo App](https://demo.arcana.network)
# Integrate HTML/CSS/JS App
Integrate 'HTML/CSS/JS' apps with[Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'HTML/CSS/JS' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
```
npm install --save @arcana/auth
```
```
yarn add @arcana/auth
```
### 2. Initialize `AuthProvider`
```
import { AuthProvider } from '@arcana/auth'
```
```
const auth = new AuthProvider(
"xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
{
alwaysVisible: false, // default: true, wallet always visible
connectOptions: {
compact: true // default: false, regular plug-and-play login UI
},
position: 'left', // default: right
setWindowProvider: true, // default: false, window.ethereum not set
theme: 'light', // default: dark
})
```
Initialize First!
After creating the `AuthProvider`, wait until the `init` call is complete before invoking any of the other SDK functions.
```
try {
await auth.init()
} catch (e) {
// Handle exception case
}
```
`AuthProvider` Optional Parameters
Besides Client ID input parameter, you can optionally customize these settings in the `AuthProvider` constructor:
______________________________________________________________________
**`position`:** wallet position within the app context - `left`|`right`
**`theme`:** wallet theme - `light`|`dark`
**`connectOptions`:** [compact mode](../../../concepts/plug-and-play-auth/#compact-modal) for the built-in plug-and-play login UI - `true`|`false`
```
connectOptions: {
compact: true // default - false
},
```
______________________________________________________________________
See [`AuthProvider` constructor parameters](https://authsdk-ref-guide.netlify.app/interfaces/constructorparams) for details.
The 'HTML/CSS/JS' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/vanilla/use-plug-play-auth/) or a [custom login UI](../../onboard/vanilla/custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'HTML/CSS/JS'** integration example: See `sample-auth-html-css-js` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Integrate Vue App
Integrate 'Vue' apps with[Arcana Auth SDK](../../../concepts/authsdk/) and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'Vue' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
```
npm install --save @arcana/auth
```
```
yarn add @arcana/auth
```
### 2. Initialize `AuthProvider`
```
import { AuthProvider } from "@arcana/auth";
let authInstance;
//Mainnet ClientId
const clientId = "xar_live_d7c88d9b033d100e4200d21a5c4897b896e60063";
if (authInstance == null) {
authInstance = new AuthProvider(clientId);
await authInstance.init();
}
// Use authInstance for user onboarding, JSON/RPC and wallet ops
```
`AuthProvider` Optional Parameters
Besides Client ID input parameter, you can optionally customize these settings in the `AuthProvider` constructor:
______________________________________________________________________
**`position`:** wallet position within the app context - `left`|`right`
**`theme`:** wallet theme - `light`|`dark`
**`connectOptions`:** [compact mode](../../../concepts/plug-and-play-auth/#compact-modal) for the built-in plug-and-play login UI - `true`|`false`
```
connectOptions: {
compact: true // default - false
},
```
______________________________________________________________________
See [`AuthProvider` constructor parameters](https://authsdk-ref-guide.netlify.app/interfaces/constructorparams) for details.
The 'Vue' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/vue/use-plug-play-auth/) or a [custom login UI](../../onboard/vanilla/custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Vue'** integration example: See `sample-auth-vue` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Integrate Wagmi App
[Wagmi](https://wagmi.sh/) is a React Hooks library for Ethereum that simplifies connecting Web3 apps to multiple wallets and chains.
Integrate 'Wagmi' apps with Arcana Auth SDK and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'Wagmi' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
**Wagmi 2.0**
```
npm install --save @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
npm install --save @arcana/auth-wagmi@2.0.0 @arcana/auth
```
**Wagmi 2.0**
```
yarn add @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
yarn add @arcana/auth-wagmi@2.0.0 @arcana/auth
```
### 2. Create `AuthProvider` & `ArcanaConnector`
Specify the **Client ID** assigned to the registered app to create the `AuthProvider`. Then use the `AuthProvider` to create `ArcanaConnector`.
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi"
const auth = new AuthProvider('your-client-id');
const connector = new ArcanaConnector({ auth });
```
`AuthProvider` Optional Parameters
Besides Client ID input parameter, you can optionally customize these settings in the `AuthProvider` constructor:
______________________________________________________________________
**`position`:** wallet position within the app context - `left`|`right`
**`theme`:** wallet theme - `light`|`dark`
**`connectOptions`:** [compact mode](../../../concepts/plug-and-play-auth/#compact-modal) for the built-in plug-and-play login UI - `true`|`false`
```
connectOptions: {
compact: true // default - false
},
```
______________________________________________________________________
See [`AuthProvider` constructor parameters](https://authsdk-ref-guide.netlify.app/interfaces/constructorparams) for details.
Compact Mode
While creating the `AuthProvider`, you can choose the [compact mode (optional)](../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
### 3. Setup `WagmiConfig`
Create Wagmi config and specify the `ArcanaConnector`.
```
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { AuthProvider } from '@arcana/auth';
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"xar_dev_c2fb7be163754e57d384e24257ea2c8d2a5dd31a"
);
}
export const connector = () => {
return new ArcanaConnector({auth,})
};
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }),
connector(),
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
```
```
// Note:
// This sample code is for
// wagmi versions 1.x.y and auth-wagmi 2.a.b
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { newAuthProvider } from "./utils/newArcanaAuth";
import { useAccount, useConnect, useDisconnect, useBalance } from 'wagmi'
import "../styles/globals.css";
const { chains, provider, webSocketProvider } = configureChains(
[mainnet, polygon, polygonAmoy],
[publicProvider()],
{ targetQuorum: 1 }
);
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: newAuthProvider(),
login: {
provider: "google",
},
},
});
};
const { chains, publicClient } = configureChains(
[polygon, polygonAmoy],
[publicProvider()]
);
export const wagmiEntity = createConfig({
autoConnect: true,
connectors: [connector(chains)],
publicClient,
});
...
```
The 'Wagmi' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/wagmi/wagmi-pnp-ui/) or a [custom login UI](../../onboard/wagmi/wagmi-custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Wagmi'** integration example: See `sample-auth-wagmi-2`, `sample-auth-wagmi-viem`, `sample-auth-wagmi` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Integrate WalletConnect App
[WalletConnect](https://walletconnect.com/) allows Web3 app users to seamlessly switch between multiple connected wallets within a dApp.
Integrate 'WalletConnect' apps with Arcana Auth SDK and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the 'WalletConnect' app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
**Wagmi 2.0**
```
npm install --save @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
npm install --save @arcana/auth-wagmi@2.0.0 @arcana/auth
```
**Wagmi 2.0**
```
yarn add @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
yarn add @arcana/auth-wagmi@2.0.0 @arcana/auth
```
### 2. Create `AuthProvider` & `ArcanaConnector`
```
// Set up Arcana Auth
import { AuthProvider } from "@arcana/auth";
let auth: AuthProvider | null;
const getAuthProvider = () => {
if (!auth) {
auth = new AuthProvider(
"xar_test_b2dde12aad64eb35d72b2c80926338e178b1fa3f"
);
}
return auth;
};
export { getAuthProvider };
```
Initialize First!
After creating the `AuthProvider`, wait until the `init` call is complete before invoking any of the other SDK functions.
```
try {
await auth.init()
} catch (e) {
// Handle exception case
}
```
```
//This example uses Arcana Wallet connector and Coinbase Wallet
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { getAuthProvider } from './arcanaConnector';
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({
projectId: '3fcc6bba6f1de962d911bb5b5c3dba68', //WalletConnect ProjectID
}),
ArcanaConnector(
{
auth: getAuthProvider(),
}
)
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
```
`AuthProvider` Optional Parameters
Besides Client ID input parameter, you can optionally customize these settings in the `AuthProvider` constructor:
______________________________________________________________________
**`position`:** wallet position within the app context - `left`|`right`
**`theme`:** wallet theme - `light`|`dark`
**`connectOptions`:** [compact mode](../../../concepts/plug-and-play-auth/#compact-modal) for the built-in plug-and-play login UI - `true`|`false`
```
connectOptions: {
compact: true // default - false
},
```
______________________________________________________________________
See [`AuthProvider` constructor parameters](https://authsdk-ref-guide.netlify.app/interfaces/constructorparams) for details.
### 3. Set up `WagmiProvider`
Create Wagmi config and specify the `ArcanaConnector`.
```
//Use "`auth-wagmi` version > v2.0.0"
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
The 'WalletConnect' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/walletconnect/walletconnect-pnp-ui/) or a [custom login UI](../../onboard/walletconnect/walletconnect-custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'WalletConnect'** integration example: See `sample-auth-walletconnect` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Integrate Web3-React App
[Web3-React](https://www.npmjs.com/package/web3-react) framework allows Connectors for various Web3 wallets.
Integrate 'Web3-React' apps with Arcana Auth SDK and onboard users via [social login](../../../concepts/social-login/). Enable users to sign blockchain transactions with the in-app [Arcana wallet](../../../concepts/anwallet/).
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the Wa'Web3-React'gmi app and configure SDK usage [settings for social login](../../../setup/) providers, manage app [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Steps
### 1. Install
**Wagmi 2.0**
```
npm install --save @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
npm install --save @arcana/auth-wagmi@2.0.0 @arcana/auth
```
**Wagmi 2.0**
```
yarn add @arcana/auth-wagmi@3.0.0 @arcana/auth@1.0.12
```
**Wagmi 1.0**
```
yarn add @arcana/auth-wagmi@2.0.0 @arcana/auth
```
### 2. Create `AuthProvider` and `ArcanaConnector`
```
import { initializeConnector } from "@web3-react/core";
import { ArcanaConnector } from "@arcana/auth-web3-react";
import { AuthProvider } from "@arcana/auth";
import { URLS } from "../chains";
const auth = new AuthProvider(
"xar_test_b2ddexxxxxxxxxxxxxxxxxxxx8b1fa3f" //App client ID via Dashboard
);
export const [arcanaConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
})
);
...
```
### 3. `ArcanaConnectCard` Component
In the Web3-React app, use the `ArcanaConnector` and React hooks to connect `ArcanaConnector` with the Web3-React ecosystem via `ArcanaConnectCard`.
```
import { useEffect, useState } from "react";
import { MAINNET_CHAINS } from "../../chains";
import { hooks, arcanaConnect } from "../../connectors/arcanaWallet";
import { Card } from "../Card";
const CHAIN_IDS = Object.keys(MAINNET_CHAINS).map(Number);
const {
useChainId,
useAccounts,
useIsActivating,
useIsActive,
useProvider,
useENSNames,
} = hooks;
export default function ArcanaConnectCard() {
const chainId = useChainId();
const accounts = useAccounts();
const isActivating = useIsActivating();
const isActive = useIsActive();
const provider = useProvider();
const ENSNames = useENSNames(provider);
const [error, setError] = useState(undefined);
// attempt to connect eagerly on mount
useEffect(() => {
arcanaConnect.connectEagerly().catch((error) => {
console.debug("Failed to connect eagerly to arcanaConnect", error);
});
}, []);
return (
);
}
```
Now, you are all set to onboard users in the Web3-React app using the plug-and-play login UI and enable Arcana wallet for the authenticated users.
pages/index.tsx
```
import ArcanaConnectCard from "../components/connectorCards/ArcanaConnectCard";
import CoinbaseWalletCard from "../components/connectorCards/CoinbaseWalletCard";
import GnosisSafeCard from "../components/connectorCards/GnosisSafeCard";
import MetaMaskCard from "../components/connectorCards/MetaMaskCard";
import NetworkCard from "../components/connectorCards/NetworkCard";
import WalletConnectCard from "../components/connectorCards/WalletConnectCard";
import WalletConnectV2Card from "../components/connectorCards/WalletConnectV2Card";
import ProviderExample from "../components/ProviderExample";
export default function Home() {
return (
<>
);
>
}
```
The 'Web3-React' Web3 app is now **integrated** with the Arcana Auth SDK.
## What's Next?
Onboard users via the [built-in plug-and-play login UI](../../onboard/web3-react/web3-react-pnp-ui/) or a [custom login UI](../../onboard/web3-react/web3-react-custom-ui/).
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Web3-React'** integration example: See `sample-auth-web3-react` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Architecture: Auth
Arcana Auth SDK allows Web3 app developers to onboard app users at scale using social and passwordless login. Authenticated users can instantly access the embedded, non-custodial Arcana wallet from within the app's context. Developers can whitelist app operations and enable gasless transactions through the Arcana wallet or third-party wallets.
Here is a high-level overview of the technical architecture and components that power the Arcana Auth SDK.
## Auth Components
- [Arcana Developer Dashboard](../../../concepts/dashboard/)
- [Arcana Gateway](../../../concepts/gateway-node/)
- [Arcana Auth SDK](../../../concepts/authsdk/)
- [Asynchronous Distributed Key Generation (ADKG)](../../../concepts/adkg/)
- Arcana Auth protocol (Back-end Subsystem)
Auth Components
### Arcana Developer Dashboard
Arcana Developer Dashboard is the user interface offered to Web3 app developers for registering an app and configuring the authentication providers and gasless transaction usage settings as per the app requirements.
### Arcana Gateway
The Gateway is one of the key back-end components that works with the Arcana Developer Dashboard as well as the SDK integrated with the app. It is responsible for storing and managing SDK usage configuration details for various apps and manages developer accounts, app usage and billing, etc.
All transactions initiated by the Arcana wallet are processed via the Gateway. It also handles gasless transactions for the Arcana wallet.
### Arcana Auth SDK
The Arcana Auth SDK integrates with the app and enables user onboarding through social login providers, IAM providers, and passwordless login. It also enables Web3 operations through the embedded Arcana wallet.
### Asynchronous Distributed Key Generation (ADKG)
A core back-end component that generates and manages key shares securely. It works with the SDK integrated with the app to securely dispense key shares. Some of the nodes running ADKG logic are owned by trusted third-party validators. In the future, we plan to make this component fully decentralized.
### Arcana Auth protocol (Back-end Subsystem)
This refers to a bunch of entities in the back-end that implement the core system logic and algorithms on blockchain using [Arcana smart contracts](../../../concepts/ansmartc/an-smart-contracts/).
See [Arcana Technical White paper](https://www.notion.so/Arcana-Technical-Docs-a1d7fd0d2970452586c693e4fee14d08) for details.
# Arcana Auth Use Cases
The Arcana Auth SDK allows developers to supercharge their Web3 apps with plug-and-play user authentication. Also, authenticated app users can instantly access the in-app, self-custodial Arcana wallet to securely sign blockchain transactions without having to install any browser extension or manage keys.
Web3 developers can integrate apps with the Arcana Auth SDK to:
- Authenticate and onboard users with social login
- Automatically enable in-app wallet for authenticated users to sign blockchain transactions
- Monitor app usage
## User Authentication
- **Plug-and-Play Auth**: Onboard users with a single line of code. Call `connect` method to bring up plug-and-play login UI that displays the configured Web2 social login providers, IAM providers and passwordless login options.
- **Build-your-own-Auth-UI**: Create your own login UX and call `loginWithSocial` method to enable authentication via popular Web2 social login providers, `loginWithBearer` for IAM providers. Use `loginWithLink` (deprecated), `loginWithOTPStart`, and `loginWithOTPComplete` methods for onboarding users via the passwordless option.
- **Customize Onboarding**: Choose which providers/login options are visible to the user at the time of logging into the Web3 application.
## Sign Blockchain Transactions
- **Accessible & Secure Wallet**: Enable *authenticated app users* to sign blockchain transactions without having to learn the Web3 nuances or expose them to tedious key management hoops. At the same time, provide a secure wallet that works only in the context of an app for an authenticated user.
- **Customize Wallet Usage Experience**: Control the Arcana wallet visibility by choosing whether it should be always visible in the context of a Web3 application or whether it shows up only when a blockchain transaction is triggered.
- **Wallet Branding**: Allows Web3 application developers to customize the Arcana wallet theme.
- **No Browser Extension Deployment**: Arcana Auth SDK allows quick wallet onboarding for users without any prior need to generate Web3 keys or install any wallet or browser extension to onboard Web3 apps.
- **Web3 Wallet Operations**: Enable typical wallet functions in the application for authenticated users:
- Sign blockchain transactions
- Send Transaction
- Send/Receive native, custom tokens
- Send/Receive NFTs
- Browse NFTs, view NFT details
- Add [supported networks](../../../web3-stack/chains/)
- Switch networks
- Monitor transaction activity
- JSON-RPC method support
- Buy crypto via fiat/on-ramp providers
## Monitor App Usage
- **Register Apps**: Developers can register and configure the Arcana Auth SDK usage and wallet user experience by using the Arcana Developer Dashboard as per their app requirements.
- **Monitor App Usage**: Developers can manage and monitor application usage in terms of **Monthly Active Users (MAU)**. They can also configure how apps are deployed on the Arcana Testnet and Mainnet. Billing is done only for Arcana Mainnet usage. Usage across all apps deployed on Mainnet can be tracked by the developers.
## Secure with MFA
Gaming, DeFi and other Web3 apps that deal with user's crypto assets, NFTs can further secure user data by utilizing the [MFA feature](../../../concepts/mfa/). A user can set up various recovery methods for their wallet to enhance security. Whenever they try to log in from a new device they will have to provide one of the two in order to login. The Arcana Auth SDK works across devices and browsers.
# Why Auth SDK?
At Arcana, our mission is to build an ecosystem of components that enables developers to build Web3 applications quickly, securely, and with complete data privacy and ownership for application users.
This is totally unlike Web2, where user data is owned by the applications and corporations. Web2 users have no control over who sees or accesses their data.
## Privacy-Preserving Applications
If you are building Web3 apps that require complete data privacy, and security, the Arcana SDKs does the heavy lifting for you to onboard users using popular authentication providers and passwordless options. It allows authenticated users to sign blockchain transactions, manage tokens, and more without having to bother about the Web3 secret and key management complexities.
At Arcana, we take security, privacy, and ownership seriously. We are actively working towards tracking and plugging in any vulnerabilities in our solution.
Take a quick look at the overview of the [architecture and key components](../auth-architecture/) of the {{ no such element: dict object['product_name'] }} and see [Arcana Network Technical White Paper v1.0](https://www.notion.so/arcananetwork/Arcana-Technical-Docs-a1d7fd0d2970452586c693e4fee14d08) for implementation details.
## Build Web3 Apps Faster
As a Web3 app developer, you can focus on core application logic while delegating essential tasks related to end-user onboarding, signing blockchain transactions, and managing the security and privacy of user access to the {{ no such element: dict object['product_name'] }} product.
### 1. Onboard App Users Effortlessly
Developers can plug in the popular Web2 sign-up/login mechanisms in the Web3 apps and lower the barrier to entry for Web3 users.
To onboard users in a Web3 app, the Arcana Auth SDK allows developers to select and configure user authentication providers for the app. Developers can choose the default, built-in plug-and-play user authentication UI via `connect` function of the Arcana Auth SDK. Or, they can customize and build a custom user authentication UI, add a few lines of code to call `loginWithSocial`, `loginWithLink`(deprecated), `loginWithOTPStart` and `loginWithOTPComplete` functions to onboard users.
Read more about the [plug-and-play feature](../../../concepts/plug-and-play-auth/), and [how to onboard users](../../onboard/vanilla/use-plug-play-auth/) via the built-in, plug-and-play login UI or [custom login UI](../../onboard/vanilla/custom-ui/build-pwdless-auth/).
Before you can integrate an app with the Arcana Auth SDK, developers must use the Arcana Developer Dashboard and configure onboarding options and user experience for signing blockchain transactions. Learn about [authentication providers](../../../concepts/authtype/), and [how to configure authentication providers](../../../setup/config-auth/) using the Arcana Developer Dashboard.
### 2. Sign blockchain transactions securely
Allow authenticated Web3 application users to securely sign blockchain operations without bothering about managing secrets and keys. No centralized authority manages user keys in the {{ no such element: dict object['product_name'] }} DKG subsystem. Use the embedded, non-custodial Arcana wallet provided by the Arcana Auth SDK to let the authenticated users review and sign blockchain transactions.
Read more about the [Arcana wallet features](../../../concepts/anwallet/) and [how to transact using the Arcana wallet](../../web3-ops/evm/). Check out the [Arcana wallet User Guide](../../../user-guides/wallet-ui/) to learn more about various Web3 wallet operations that can be accessed by the application users.
## Flexibility & Choice
Tailor the user experience for your Web3 applications as per your use case and target audience. Learn more about the \[\[use-cases|{{ no such element: dict object['product_name'] }} Use Cases\]\].
## See Also
- [Social Login Demo App](https://demo.arcana.network)
- [Arcana Auth SDK Usage Guide](../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
# Get Started: Flutter Apps
'Flutter' Web3 apps can onboard users via social login by integrating with the Arcana Auth Flutter SDK!
## Prerequisites
- Flutter [v3.15.0](https://flutter-ko.dev/development/tools/sdk/releases) or higher
## 1. Register & Configure
- App must be [registered](../../../setup/config-auth/register-app/) via the Arcana Developer Dashboard:
- Optionally [configure auth settings](../../../setup/config-auth/) such as [social login](../../../concepts/social-login/), [wallet user experience](../../../concepts/anwallet/), etc.
## 2. Install SDK
The Arcana Auth Flutter SDK is available at 'Pub.dev' as a [Flutter plugin](https://docs.flutter.dev/packages-and-plugins/developing-packages) package called [`arcana_auth_flutter`](https://pub.dev/packages/arcana_auth_flutter).
Add the following line to the dependencies section in your app's `pubspec.yaml` file:
pubspec.yaml
```
dependencies:
flutter: # Required for every Flutter project
sdk: flutter # Required for every Flutter project
flutter_localizations: # Required to enable localization
sdk: flutter # Required to enable localization
arcana_auth_flutter: ^0.0.6
```
Use latest Arcana Auth Flutter SDK
Use latest Arcana Auth Flutter SDK release **v0.0.6** available at [pub.dev](https://pub.dev/packages/arcana_auth_flutter).
## 3. Integrate
Once installed, integrate the app with the Arcana Auth Flutter SDK. Create an `AuthProvider` instance and specify the unique **client ID** assigned to the registered app.
```
import 'package:arcana_sdk/arcana_sdk.dart';
final auth = AuthProvider(clientId:"xar_xxxx_...");
auth.init(context: context);
```
Next, add code to onboard users and allow authenticated users to sign blockchain transactions using Arcana wallet.
### Onboard Users
Add code to onboard users through one of the configured social login providers or via OTP login option.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
**Social Login**
```
auth.loginWithSocial("google").then((_) => {
// On login Success
}).catchError(...);
```
**OTP Login**
```
auth.loginWithOTP("${email_id}").then((_) => {
// On login Success
}).catchError(...);
```
**Logout**
Call the logout method in response to a user's choice to log out. The built-in Arcana wallet UI has a **Logout** option in the user profile tab.
```
auth.logout().then((_) => {
// On logout
});
```
**Get User Address**
```
auth.getAccount().then((account) => ...);
```
**Get User Details**
```
auth.getUserInfo().then((UserInfo info) => ...);
```
**Show/Hide Wallet UI**
Developers can choose to show or hide the wallet as per the app requirements.
```
auth.showWallet();
```
```
auth.hideWallet();
```
**Check Wallet Visibility**
To determine in the Flutter app if the Arcana wallet is visible in the app's context, get the visibility status:
```
var isVisible = auth.isVisible();
```
**Clear Cache**
Flutter apps can use `clearCache` to clear the Webview cache:
```
auth.clearCache();
```
### Sign Transactions
The `AuthProvider` supports the JSON-RPC requests for the following Web3 operations:
```
auth.request(method: "...", params: [...]).then(() => ...);
```
```
auth.sendTransaction({ to: "", value: "" }).then((hash) => ...);
```
## 4. Deploy
**That's all!**
The 'Flutter' app is ready to onboard users and allow them to sign blockchain transactions.
## See also
- **'Flutter'** integration example: See `sample-auth-flutter` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
Arcana Auth Flutter SDK Quick Links
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-flutter/releases)
- [Download SDK](https://pub.dev/packages/arcana_auth_flutter)
# Get Started: React-Native Apps
'React-Native' Web3 apps can onboard users via social login by integrating with the Arcana Auth React-Native SDK!
## Prerequisites
- React-Native [v0.71.8](https://reactnative.dev/versions) or higher
## 1. Register & Configure
- App must be [registered](../../../setup/config-auth/register-app/) via the Arcana Developer Dashboard:
- Optionally [configure auth settings](../../../setup/config-auth/) such as [social login](../../../concepts/social-login/), [wallet user experience](../../../concepts/anwallet/), etc.
## 2. Install SDK
For 'React-Native' Web3 apps, install the [`auth-react-native`](https://www.npmjs.com/package/@arcana/auth-react-native) package.
```
npm i @arcana/auth-react-native
(cd ios && pod install)
```
**Note:** You are **not required** to manually link this module, as it supports React Native auto-linking.
Use latest SDKs
Use the latest Arcana Auth React-Native SDK release **v0.0.4** available at [npm](https://www.npmjs.com/package/@arcana/auth-react-native).
## 3. Integrate
Use the unique client ID assigned to the app during registration to integrate with the SDK.
```
import React, { useState } from "react";
import { Button, View } from "react-native";
import Auth from "@arcana/auth-react-native";
export default function App() {
const authRef = React.useRef(null);
return (
);
}
```
```
```
### Onboard Users
Call `Auth` functions and onboard users through the configured authentication providers.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
**Google Login**\*
```
// For logging in
const loginWithGoogle = () => {
if(authRef !== null){
authRef.current.loginWithSocial('google').then(() => {
// logged in
}).catch(err => {
// already logged in
// or error during login
})
}
}
```
**Logout**
Add code to provide user log out option via the `logout` method or let authenticated users log out using the wallet UI logout option in the 'User Profile' tab.
```
// Logout User from session
const logout = () => {
if(authRef !== null){
authRef.current.logout().then(() => {
// on logout
});
}
};
```
**Show/Hide Wallet**
Once the user logs into the app, they can instantly access the Arcana wallet. Developers can choose to show and hide the wallet as required by the app.
```
// For showing wallet
const showWallet = () => {
if(authRef !== null){
authRef.current.showWallet();
}
}
// For hiding wallet
const hideWallet = () => {
if(authRef !== null){
authRef.current.hideWallet();
}
}
```
```
// For getting logged in user info
const getUserInfo = async () => {
if(authRef !== null){
return authRef.current.getUserInfo();
}
};
```
```
// For getting current account
const getAccount = async () => {
if(authRef !== null){
return await authRef.current.getAccount();
}
};
```
```
return (
);
```
### Sign Transactions
Use `authRef` EIP-1193 provider to call JSON-RPC functions and Web3 wallet operations.
```
// For sending transaction
const sendTransaction = async data => {
if(authRef !== null){
return await authRef.current.sendTransaction(data);
}
};
// For getting current account balance
const getBalance = async () => {
if(authRef !== null){
return await authRef.current.getBalance();
}
};
// EIP 1193 request method
const request = async (method, params) => {
if(authRef !== null){
return await authRef.current.request({ method, params });
}
};
```
## 4. Deploy
**That's all!**
The 'React-Native' app is ready to onboard users and allow them to sign blockchain transactions.
## See also
- **'React-Native'** integration example: See `sample-auth-react-native` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
Arcana Auth React-Native SDK Quick Links
- [Release notes](../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-react-native/releases)
- [Download auth-react-native](https://www.npmjs.com/package/@arcana/auth-react-native)
# MultiversX App: Onboard Users
Learn how to onboard users through the configured [social login](../../../concepts/social-login/) providers in a 'MultiversX' app.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-mvx/) the 'MultiversX' app and configure SDK usage [settings for social login](../../../setup/) providers, [manage MultiversX chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) for 'MultiversX'.
- [Integrate](../../integrate/mvx/) 'MultiversX' app and obtain an `AuthProvider` for blockchain transactions.
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
MultiversX Shard Selection
MultiversX uses [adaptive state sharding](https://docs.multiversx.com/technology/adaptive-state-sharding/) for horizontal scaling. Shards allow it to process far more transactions through parallelization, improving transaction throughput and efficiency.
Choose your shard once when registering a MultiversX app on the Arcana Developer Dashboard. It cannot be changed later.
By default, Arcana uses 'Shard 0' to deploy all app contracts and allocate wallet addresses for users. The benefit is that when addresses from the same shard interact with contracts on the same shard, latencies are much lower than in cross-shard interactions.
## Onboard Users
User Onboarding Considerations
1. **Log in Options:** What options are offered by the app to the onboard users via social login? *Configure the required [social login providers](../../../setup/config-auth/) via the dashboard.*
1. **Built-in or Custom Login UI:** Does the Web3 app have a custom login UI or do they need to use the built-in, [plug-and-play login UI](../../../concepts/plug-and-play-auth/) modal offered by the Arcana Auth SDK? *Choose the appropriate onboarding functions of the `AuthProvider`.*
1. **Session Management:** Does the authenticated user stay logged in if they accidentally close the browser tab? If yes, what is the acceptable Web3 app security window for the session? After how long should the session expire and a user re-login is necessitated for security? *Configure the [session management settings](../../../setup/config-dApp-with-db/#login-session-management) via the dashboard.*
1. **Reconnect:** Does the Web3 app allow users to stay connected or require re-authentication after a certain time has elapsed? *Use `isConnected`, `canReconnect` and `reconnect` functions of the `AuthProvider`.*
[Wagmi Apps](../wagmi/wagmi-pnp-ui/) [RainbowKit Apps](../rainbow/rainbow-pnp-ui/) [WalletConnect Apps](../walletconnect/walletconnect-pnp-ui/) [Web3-React Apps](../web3-react/web3-react-pnp-ui/) [React/Next.js Apps](../react-nextjs/use-plug-play-auth/) [Vanilla HTML/CSS/JS App](../vanilla/use-plug-play-auth/) [Vue App](../vue/use-plug-play-auth/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Wagmi Apps](../wagmi/wagmi-custom-ui/) [RainbowKit Apps](../rainbow/rainbow-custom-ui/) [WalletConnect Apps](../walletconnect/walletconnect-custom-ui/) [Web3-React Apps](../web3-react/web3-react-custom-ui/) [React/Next.js Apps](../react-nextjs/custom-ui/) [Vanilla HTML/CSS/JS App](../vanilla/custom-ui/) [Vue App](../vue/custom-ui/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
## Advanced
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Reconnect Users
Use `canReconnect` and `reconnect` methods of `AuthProvider` within a 30-min window of the user-logout action. Allow users to automatically reconnect to the app without re-authentication.
See [`canReconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#canReconnect) and [`reconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#reconnect) for details.
Apps Using Custom Auth
Web3 apps that use custom user authentication solutions and require authenticated users to sign blockchain transactions can also integrate with the Arcana Auth SDK. These apps can skip the social onboarding feature and use `loginWithCustomProvider` function of the `AuthProvider` to assign keys securely. [Learn more...](../../custom-auth/)
## What's Next?
Use the EIP-1193 provider offered by the SDK to call JSON/RPC functions and other [supported Web3 wallet operations on MultiversX](../../web3-ops/mvx/) in the authenticated user's context.
## See Also
**'MultiversX'** integration example: See `sample-auth-mvx` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [MultiversX FAQ](../../../faq/faq-mvx/)
[Try Demo App](https://demo.arcana.network)
# Near App: Onboard Users
Learn how to onboard users through the configured [social login](../../../concepts/social-login/) providers in a 'Near' app.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-near/) the 'Near' app and configure SDK usage [settings for social login](../../../setup/) providers, [manage Near chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) for 'Near'.
- [Integrate](../../integrate/near/) 'Near' app and create `AuthProvider`, `ArcanaConnector` as per the app type.
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Onboard Users
User Onboarding Considerations
1. **Log in Options:** What options are offered by the app to the onboard users via social login? *Configure the required [social login providers](../../../setup/config-auth/) via the dashboard.*
1. **Built-in or Custom Login UI:** Does the Web3 app have a custom login UI or do they need to use the built-in, [plug-and-play login UI](../../../concepts/plug-and-play-auth/) modal offered by the Arcana Auth SDK? *Choose the appropriate onboarding functions of the `AuthProvider`.*
1. **Session Management:** Does the authenticated user stay logged in if they accidentally close the browser tab? If yes, what is the acceptable Web3 app security window for the session? After how long should the session expire and a user re-login is necessitated for security? *Configure the [session management settings](../../../setup/config-dApp-with-db/#login-session-management) via the dashboard.*
1. **Reconnect:** Does the Web3 app allow users to stay connected or require re-authentication after a certain time has elapsed? *Use `isConnected`, `canReconnect` and `reconnect` functions of the `AuthProvider`.*
[Wagmi Apps](../wagmi/wagmi-pnp-ui/) [RainbowKit Apps](../rainbow/rainbow-pnp-ui/) [WalletConnect Apps](../walletconnect/walletconnect-pnp-ui/) [Web3-React Apps](../web3-react/web3-react-pnp-ui/) [React/Next.js Apps](../react-nextjs/use-plug-play-auth/) [Vanilla HTML/CSS/JS App](../vanilla/use-plug-play-auth/) [Vue App](../vue/use-plug-play-auth/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Wagmi Apps](../wagmi/wagmi-custom-ui/) [RainbowKit Apps](../rainbow/rainbow-custom-ui/) [WalletConnect Apps](../walletconnect/walletconnect-custom-ui/) [Web3-React Apps](../web3-react/web3-react-custom-ui/) [React/Next.js Apps](../react-nextjs/custom-ui/) [Vanilla HTML/CSS/JS App](../vanilla/custom-ui/) [Vue App](../vue/custom-ui/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
## Advanced
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Reconnect Users
Use `canReconnect` and `reconnect` methods of `AuthProvider` within a 30-min window of the user-logout action. Allow users to automatically reconnect to the app without re-authentication.
See [`canReconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#canReconnect) and [`reconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#reconnect) for details.
Apps Using Custom Auth
Web3 apps that use custom user authentication solutions and require authenticated users to sign blockchain transactions can also integrate with the Arcana Auth SDK. These apps can skip the social onboarding feature and use `loginWithCustomProvider` function of the `AuthProvider` to assign keys securely. [Learn more...](../../custom-auth/)
## What's Next?
Use the EIP-1193 provider offered by the SDK to call JSON/RPC functions and other [supported Web3 wallet operations on Near](../../web3-ops/near/) in the authenticated user's context.
## See also
**'Near'** integration example: See `sample-auth-near` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [Near FAQ](../../../faq/faq-near/)
[Try Demo App](https://demo.arcana.network)
# Solana App: Onboard Users
Learn how to onboard users through the configured [social login](../../../concepts/social-login/) providers in a 'Solana' app.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-Solana/) the 'Solana' app and configure SDK usage [settings for social login](../../../setup/) providers, [manage Solana chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) for 'Solana'.
- [Integrate](../../integrate/solana/) 'Solana' app and create `AuthProvider`, `ArcanaConnector` as per the app type.
Non-EVM Chains
When registering an app through Arcana Developer Dashboard, the choice of chain type (EVM, Solana, MultiversX, Near) is final. App developers can't change it later. They can switch the default chain within the same type. For example, a Solana app on Testnet can switch to Solana Mainnet or Solana Dev but not to MultiversX or an EVM chain.
## Onboard Users
User Onboarding Considerations
1. **Log in Options:** What options are offered by the app to the onboard users via social login? *Configure the required [social login providers](../../../setup/config-auth/) via the dashboard.*
1. **Built-in or Custom Login UI:** Does the Web3 app have a custom login UI or do they need to use the built-in, [plug-and-play login UI](../../../concepts/plug-and-play-auth/) modal offered by the Arcana Auth SDK? *Choose the appropriate onboarding functions of the `AuthProvider`.*
1. **Session Management:** Does the authenticated user stay logged in if they accidentally close the browser tab? If yes, what is the acceptable Web3 app security window for the session? After how long should the session expire and a user re-login is necessitated for security? *Configure the [session management settings](../../../setup/config-dApp-with-db/#login-session-management) via the dashboard.*
1. **Reconnect:** Does the Web3 app allow users to stay connected or require re-authentication after a certain time has elapsed? *Use `isConnected`, `canReconnect` and `reconnect` functions of the `AuthProvider`.*
[Wagmi Apps](../wagmi/wagmi-pnp-ui/) [RainbowKit Apps](../rainbow/rainbow-pnp-ui/) [WalletConnect Apps](../walletconnect/walletconnect-pnp-ui/) [Web3-React Apps](../web3-react/web3-react-pnp-ui/) [React/Next.js Apps](../react-nextjs/use-plug-play-auth/) [Vanilla HTML/CSS/JS App](../vanilla/use-plug-play-auth/) [Vue App](../vue/use-plug-play-auth/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
[Wagmi Apps](../wagmi/wagmi-custom-ui/) [RainbowKit Apps](../rainbow/rainbow-custom-ui/) [WalletConnect Apps](../walletconnect/walletconnect-custom-ui/) [Web3-React Apps](../web3-react/web3-react-custom-ui/) [React/Next.js Apps](../react-nextjs/custom-ui/) [Vanilla HTML/CSS/JS App](../vanilla/custom-ui/) [Vue App](../vue/custom-ui/) [Flutter Apps](../../mobile/flutter-get-started/) [React-Native Apps](../../mobile/react-native-get-started/)
## Advanced
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Reconnect Users
Use `canReconnect` and `reconnect` methods of `AuthProvider` within a 30-min window of the user-logout action. Allow users to automatically reconnect to the app without re-authentication.
See [`canReconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#canReconnect) and [`reconnect`](https://authsdk-ref-guide.netlify.app/classes/authprovider#reconnect) for details.
Apps Using Custom Auth
Web3 apps that use custom user authentication solutions and require authenticated users to sign blockchain transactions can also integrate with the Arcana Auth SDK. These apps can skip the social onboarding feature and use `loginWithCustomProvider` function of the `AuthProvider` to assign keys securely. [Learn more...](../../custom-auth/)
## What's Next?
Use the EIP-1193 provider offered by the SDK to call JSON/RPC functions and other [supported Web3 wallet operations for Solana](../../web3-ops/solana/) in the authenticated user's context.
## See also
**'Solana'** integration example: See `sample-auth-solana` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [Solana FAQ](../../../faq/faq-solana/)
[Try Demo App](https://demo.arcana.network)
# Unity App: Onboard Users
Learn how to onboard users via [social login](../../../concepts/social-login/) in a Web3 Unity gaming app integrated with the [Arcana Auth Unity SDK](../../../concepts/authsdk/) and allow authenticated users to access the Arcana wallet within the app context.
## Prerequisites
- The Unity Web3 gaming App must be [integrated with the Arcana Auth Unity SDK](../../integrate/unity/).
## Onboarding Users
*Follow these steps to onboard users in a Unity Web3 gaming app with the Arcana Auth Unity SDK and allow authenticated users to access the Arcana wallet.*
Call `LoginWithSocial` or `LoginWithOTP` to onboard the user. Choose one of the [supported user onboarding options](../../../web3-stack/auth/) such as Google, Steam, etc.
```
// After initializing the SDK
if (loginMethod == LoginMethod.Passwordless)
arcanaSDK.LoginWithOTP(email);
else
arcanaSDK.LoginWithSocial(loginMethod);
```
That is all.
The Unity Web3 gaming app can now onboard users via the configured social login providers.
## What's Next?
After adding code to onboard users in a Unity Web3 gaming app, developers can add code to [enable Web3 wallet operations](../../web3-ops/unity-wallet-ops/) for authenticated users to sign transactions.
## See also
- [Authentication Types](../../../concepts/authtype/)
- [Unity Quick Start Guide](../../../quick-start/unity-quick-start/)
# Login Users via Passkeys
In this guide, you will learn how a Web3 app integrated with the Arcana Auth SDK can let users set up [passkeys](../../../../concepts/authtype/auth-passkeys/) as an [alternative login](../../../../concepts/authtype/auth-passkeys/#alternate-login) option.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- The app must be [registered using the Arcana Developer Dashboard](../../../../setup/config-auth/register-app/). A unique Client ID is assigned after app registration. It is required for integrating the app with the Arcana Auth SDK.
- [Configure passkeys settings](../../../../setup/config-auth-passkeys/) in the Arcana Developer Dashboard.
- Follow the instructions as per the app type and [integrate the app](../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK.
## Steps
*Follow these steps to enable passkeys as an alternative login for users in a Web3 app integrated with the Arcana Auth SDK.*
### 1. Authenticate User
Add code to onboard users via [social login](../../vanilla/custom-ui/build-social/) or [passwordless](../../vanilla/custom-ui/build-pwdless-auth/) options. Use `loginWithSocial` or `loginWithOTP` to onboard users for their first login without passkeys.
### 2. Link Passkeys
In the authenticated user's context, check if the browser supports logging in via passkey through the `IsPasskeyLoginSupported` function. If the app browser supports passkeys, call `linkPasskey` function in the authenticated user's context to bind the passkey with the app.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
if auth.isPasskeyLoginSupported(){
console.log("Passkey login is supported by the device/browser.")
// The device or browser running the app supports Passkey Login.
// Add code to allow non-passkey authenticated user to set up passkey
...
}
```
The `linkPasskey` function invokes the device/browser specific passkey functionality. User will be prompted to create a passkey if none exist on the device. Or a list of available passkeys will be displayed for the user to choose from. Then the selected passkey can be linked or bound to the app for future login attempts.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
// First login / signup
// Display custom login UI with non-passkey login options
...
// Allow user to click log in via one of the options
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }})
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
}
}
```
After passkeys are set for the app, the `getMyPasskeys` can be called in the authenticated user's context to list all the user passkeys linked with the app on the device/browser.
```
import { AuthProvider } from "@arcana/auth";
const auth = new AuthProvider("...");
window.onload = () => {
await auth.init();
}
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
...
}
```
### Enable Passkey Login
Once passkeys are set up by the user, enable a 'login with passkey' option in the custom login UI of the app. When a user chooses this option to log in, call `loginWithPasskey`. This will bring up the device specific UI to display a list of passkeys and let the user select one to onboard the app.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
...
// Display custom login UI with non-passkey login options
...
// Allow user to click log in via one of the options
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
}
// Allow user to choose and log out after passkey linking is done
// Display custom login UI with all onboarding options including passkeys
// User clicks 'login with passkey' option in the UI
if !auth.isLoggedIn(){
// Pre login function
await auth.loginWithPasskey();
...
}
...
```
Developers can also let user view the passkeys linked with the app or website and unlink them, if required.
### List Passkeys
In the authenticated user's context, call `getMyPasskeys` to list all the user passkeys associated with the app.
```
import { AuthProvider } from "@arcana/auth";
const auth = new AuthProvider("...");
window.onload = () => {
await auth.init();
}
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
...
}
```
### Unlink Passkeys
Apps can allow users to unlink the passkeys associated with an app.
To do this, call `getMyPasskeys`in the authenticated user's context. This will list all the passkeys associated with the app. Let the user select a passkey. Specify the id of the selected passkey and call `unlinkPasskey(id)`. This will ensure that on subsequent login attempts, user cannot onboard the app with the unlinked passkey.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
...
// First login / signup
// Display custom login UI with non-passkey login options
...
// Allow user to click log in via one of the options
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
}
// Allow user to choose and log out after passkey linking is done
// Display custom login UI with all onboarding options including passkeys
// User clicks 'login with passkey' option in the UI
// Pre login function
await auth.loginWithPasskey();
...
if !auth.isLoggedIn(){
// Allow user to select passkey and unlink
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
// User selects passkey n via device/browser passkey UI
if (passkeys[n]){
// Post login function
await auth.unlinkPasskey(passkey[n]);
}
}
```
**That is all.**
Your dApp is all set for onboarding users via the passkeys option.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../concepts/authtype/)
- [Configure Social Providers](../../../../setup/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
# Login Users via Passkeys
In this guide, you will learn how a Web3 app integrated with the Arcana Auth SDK let users [sign-up and login](../../../../concepts/authtype/auth-passkeys/#sign-up-login) into the app via [passkeys](../../../../concepts/authtype/auth-passkeys/) as the only app onboarding.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- The app must be [registered using the Arcana Developer Dashboard](../../../../setup/config-auth/register-app/). A unique Client ID is assigned after app registration. It is required for integrating the app with the Arcana Auth SDK.
- [Configure passkeys settings](../../../../setup/config-auth-passkeys/) in the Arcana Developer Dashboard.
- Follow the instructions as per the app type and [integrate the app](../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK.
## Steps
*Follow these steps to enable sign-up & login via passkeys in a Web3 app that is integrated with the Arcana Auth SDK.*
### 1. Register Passkey
Add code to sign-up and create new user account via `registerWithPasskey()`. This will let the user create a new passkey and link it with the app in one shot. The newly created user will be assigned a blockchain wallet address as well. Once user has created the passkeys, enable the `Login with Passkey` option in the app UI.
### 2. Enable Passkey Login
Once passkeys are set up by the user, enable a 'login with passkey' option in the custom login UI of the app. When a user chooses this option to log in, call `loginWithPasskey`. This will bring up the device specific UI to display a list of passkeys linked with the app and let the user select one to onboard the app.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
...
// Display custom login UI with non-passkey login options
...
// Allow user to click log in via one of the options
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
}
// Allow user to choose and log out after passkey linking is done
// Display custom login UI with all onboarding options including passkeys
// User clicks 'login with passkey' option in the UI
if !auth.isLoggedIn(){
// Pre login function
await auth.loginWithPasskey();
...
}
...
```
Developers can also let user view the passkeys linked with the app or website and unlink them, if required.
### List Passkeys
In the authenticated user's context, call `getMyPasskeys` to list all the user passkeys associated with the app.
```
import { AuthProvider } from "@arcana/auth";
const auth = new AuthProvider("...");
window.onload = () => {
await auth.init();
}
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
...
}
```
### Unlink Passkeys
Apps can allow users to unlink the passkeys associated with an app.
To do this, call `getMyPasskeys`in the authenticated user's context. This will list all the passkeys associated with the app. Let the user select a passkey. Specify the id of the selected passkey and call `unlinkPasskey(id)`. This will ensure that on subsequent login attempts, user cannot onboard the app with the unlinked passkey.
```
import { AuthProvider } from "@arcana/auth"
const auth = new AuthProvider("...")
window.onload = () => {
await auth.init()
}
...
// First login / signup
// Display custom login UI with non-passkey login options
...
// Allow user to click log in via one of the options
if !auth.isLoggedIn(){
// Onboard user via non-passkey option
await auth.loginWithSocial({{ no such element: dict object['social_provider'] }});
const userInfo = auth.getUser();
console.log("userInfo.name", userInfo.name);
// Check if the device/browser support passkey login
if auth.isPasskeyLoginSupported(){
// Enable authenticated user to link a passkey with the app
// Post login function
await auth.linkPasskey();
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
}
}
// Allow user to choose and log out after passkey linking is done
// Display custom login UI with all onboarding options including passkeys
// User clicks 'login with passkey' option in the UI
// Pre login function
await auth.loginWithPasskey();
...
if !auth.isLoggedIn(){
// Allow user to select passkey and unlink
// Post login function
const passkeys = await auth.getMyPasskeys();
console.log({ passkeys });
// User selects passkey n via device/browser passkey UI
if (passkeys[n]){
// Post login function
await auth.unlinkPasskey(passkey[n]);
}
}
```
**That is all.**
Your dApp is all set for letting users sign-in and login via passkeys.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../concepts/authtype/)
- [Configure Social Providers](../../../../setup/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
# Custom Login UI
Onboard users in a 'RainbowKit' app integrated with the Arcana Auth SDK through a custom login UI.
Plug-and-Play Login UI
You can onboard users in a 'RainbowKit' app faster through the built-in, [plug-and-play login UI](../../../../concepts/plug-and-play-auth/) instead of choosing to build a custom login UI. [Learn more...](../rainbow-pnp-ui/)
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'RainbowKit'.
- [Integrate](../../../integrate/wagmi/) 'RainbowKit' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Configure `ArcanaConnector`
`ArcanaConnector` is created earlier as part of SDK integration. When using a custom login UI to onboard users, configure `ArcanaConnector` differently.
Add code in the custom UI for onboarding via social login and passwordless options by using the `setLogin` function.
*Enable Authentication Provider*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for user login via Google */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'google', //See 'Custom Login UI' section in the documentation for other supported providers.
} // Optional, specify here during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'google'
})
*/
...
```
*Enable Passwordless Login*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for Passwordless user login */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'passwordless',
email: 'abc@example.com' //optional
} // Optional, specify login details here or during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'passwordless',
email: 'abc@example.com' //optional
})
*/
...
```
Single Provider Optimization
When using a single social login provider, specify it when creating ArcanaConnector to optimize onboarding. There's no need to use setLogin later in the custom login UI code.
For multiple social login providers, create ArcanaConnector without specifying a provider. Use the setLogin function later based on the user's choice.
### 2. Set up `WagmiConfig`
Use the `ArcanaConnector` and set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
// Note:
// This sample code is for
// wagmi versions 1.x.x and auth-wagmi 2.0.0
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { polygon, mainnet, optimism, arbitrum } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { connectors } from "./wallet";
import { useAccount, useConnect } from 'wagmi'
import { Connect } from "./Connect";
const { chains, publicClient } = configureChains(
[mainnet, polygon, optimism, arbitrum],
[publicProvider()]
);
const wagmiEntity = createConfig({
connectors: connectors(chains),
autoConnect: true,
publicClient,
});
...
```
```
// Note:
// This sample code is for
// wagmi versions <1.x.x and auth-wagmi <2.0.0
import "../styles/globals.css";
import "@rainbow-me/rainbowkit/styles.css";
import { configureChains, createClient, WagmiConfig } from "wagmi";
import { polygon, mainnet } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { connectors } from "../utils/wallet";
const { chains, provider } = configureChains(
[mainnet, polygon],
[publicProvider()]
);
const wagmiEntity = createClient({
connectors: connectors(chains),
autoConnect: true,
provider,
});
...
```
### 3. Initialize RainbowKit App Components
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'RainbowKit' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../rainbow-custom-ui/) and onboard users in a 'RainbowKit' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'RainbowKit'.
- [Integrate](../../../integrate/wagmi/) 'RainbowKit' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Setup `WagmiConfig`
Use the `ArcanaConnector` created during app integration to set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
//
// For apps using Wagmi versions v2.a.b and auth-wagmi v3.x.y
//
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { AuthProvider } from '@arcana/auth'
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"Your-app-Client-ID"
);
}
const connector = new ArcanaConnector({ auth });
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }),
connector(),
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
...
```
```
//
// For apps using Wagmi versions v1.x.y and auth-wagmi v2.a.b
//
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import { polygon, polygonAmoy } from "wagmi/chains";
import { useAccount, useConnect, useDisconnect, useBalance } from 'wagmi'
import "../styles/globals.css";
import { AuthProvider } from '@arcana/auth'
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"Your-app-Client-ID"
);
}
const { chains, provider, webSocketProvider } = configureChains(
[mainnet, polygon, polygonAmoy],
[publicProvider()],
{ targetQuorum: 1 }
);
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
},
});
};
const { chains, publicClient } = configureChains(
[polygon, polygonAmoy],
[publicProvider()]
);
export const wagmiEntity = createConfig({
autoConnect: true,
connectors: [connector(chains)],
publicClient,
});
...
```
### 2. Initialize `RainbowKitProvider`
Specify Wagmi config to initialize `WagmiConfig` component in the app before using the `RainbowKitProvider` component.
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
```
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
);
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'RainbowKit'** integration example: See \`\`sample-auth-rainbowkit-viem`, `sample-auth-rainbowkit\` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'React/Next.js' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../custom-ui/) and onboard users in a 'React/Next.js' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'React/Next.js'.
- [Integrate](../../../integrate/react-nextjs/) 'React/Next.js' app, create and initialize the `AuthProvider`.
## Steps
```
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { AuthProvider } from "@arcana/auth";
import { ProvideAuth } from "@arcana/auth-react";
import App from "./App";
const rootElement = document.getElementById("root");
const root = createRoot(rootElement);
const provider = new AuthProvider(
"xar_live_d7c88d9b033d100e4200d21a5c4897b896e60063",
{
network: "mainnet",
theme: "light",
connectOptions: {
compact: true,
},
chainConfig: {
chainId: "80001"
}
}
); //See SDK Reference Guide for optional parameters
root.render(
);
```
```
import { Auth } from "@arcana/auth-react";
// Use to use the built-in, plug & play login UI
function App() {
const [theme, setTheme] = React.useState("light");
return (
;
}
if (!isLoggedIn) {
return (
Login UI (Built-in)
);
}
}
export default App
```
The figure below shows the built-in login UI plug-and-play pop-up authentication screen for a test app.
Plug-and-play Login UI
Compact Mode
While creating the `AuthProvider`, use `connectoOptions` to optionally choose the [compact mode](../../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
```
connectOptions: {
compact: true // default - false
},
```
Login UI Options
No plug-and-play support for Firebase authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Firebase. Developers must build a custom login UI and add code to onboard users. For details, see [onboarding users via Firebase and custom login UI](../custom-ui/build-idm/firebase-login/)
No plug-and-play support for Telegram authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Telegram. Developers must build a custom login UI and add code to onboard users. For details, see \[\[{{ no such element: dict object['telegram_custom_ui_tag'] }}|onboarding users via Telegram and custom login UI\]\].
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'React/Next.js'** integration example: See `sample-auth-react`,`sample-auth-nextjs` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Custom Login UI
[Enable Passwordless Auth](build-pwdless-auth/)
[Social Login Providers](build-social/)
[IAM Providers](build-idm/)
# Build Passwordless Auth
Learn how React/Next.js app can use custom login UI and allow users to onboard via passwordless login option.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- The app must be [registered using the Arcana Developer Dashboard](../../../../../setup/config-auth/register-app/) and a unique Client ID must be already assigned to it. This Client ID is essential for integrating the app with the Arcana Auth SDK
- Follow the instructions to [integrate the React app](../../../../integrate/react-nextjs/) with the Arcana Auth SDK and initialize the `AuthProvider` instance.
No Setup Required for Passwordless
Passwordless login does **not** require any configuration setup through the Arcana Developer Dashboard. When prompted, app users must supply an email ID to receive the OTP for logging into the app. On receiving the OTP in email, user must provide the same in the app to authenticate and access the in-app Arcana wallet to sign transactions.
## Steps
`useAuth() hook`
Use `loginWithLink` (deprecated) `loginWithOTPStart` and `loginWithOTPComplete` through the `useAuth` hook offered by the Arcana Auth React SDK and trigger passwordless login to onboard the users.
### Login with link
```
await auth.loginWithLink(`${email}`)
```
Deprecated
`loginWithLink` is deprecated.
Use `loginWithOTPStart`, `loginWithOTPComplete` for passwordless login with OTP. The OTP will be received via email supplied in `loginWithOTPStart` call.
### Login with OTP
```
try {
const loginState = await auth.loginWithOTPStart("john.doe@somemail.com");
await loginState.begin()
if(loginState.isCompleteRequired) {
// App is using default app-specific keys
// App must ask the user to input a 6-digit code received in mail
var userInput = prompt("Please enter a 6-digit code:", "111111");
// Validate if the input is a 6-digit code
if (userInput !== null &&
userInput.length === 6 &&
!isNaN(userInput)) {
const complete = await auth.loginWithOTPComplete(
userInput,
onMFARequired() => {
//Hide overlay, if used in the app
});
console.log("complete:",complete);
} else {
console.log("Invalid input. Please enter a valid 6-digit code.");
}
} else {
// App is using global keys, built-in OTP input UI is displayed by the SDK
// App is not required to add code for OTP input
}
} catch (e) {
console.log(e);
}
```
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
## What's Next?
Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../web3-ops/evm/)
## See also
**React/Next.js** integration example: See `sample-auth-react`,`sample-auth-nextjs` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../../auth-usage-guide/)
- [Arcana Auth React SDK Reference](https://auth-react-sdk-ref-guide.netlify.app/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth React SDK Quick Links
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Arcana Auth SDK Release notes](../../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-react/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-react)
[Try Demo App](https://demo.arcana.network)
# IAM Provider: Custom Login UI
Developers can choose to **not** use the plug-and-play login UI and instead build a custom login UI to onboard users.
In this case, developers must build custom login UI themselves after configuring the IAM Providers in the Arcana Developer Dashboard. This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for every configured IAM provider.
[Cognito](cognito-oauth/)
[Firebase](firebase-login/)
# User Login with Cognito
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Cognito authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Cognito](../../../../../../setup/config-idm/cognito-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Cognito to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('aws');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Cognito
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Cognito.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Firebase
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Firebase SDK can onboard users via custom login UI and Firebase as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Firebase](../../../../../../setup/config-idm/firebase-auth/) as the authentication provider.
- Install the Firebase SDK and integrate the app as explained in the Firebase documentation for [iOS apps](https://firebase.google.com/docs/ios/setup), [Android apps](https://firebase.google.com/docs/android/setup) and [web apps](https://firebase.google.com/docs/web/setup). Use [Firebase authentication](https://firebase.google.com/docs/auth) as per the Web3 app type, mobile or web app. Once a user is authenticated by Firebase, the developer must obtain the token and user identifier and provide it as input to the `loginWithBearer` function of the Arcana Auth SDK for onboarding users to Web3.
- Install the Arcana Auth SDK and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK by using the appropriate integration method as per the app type. After that follow the steps listed below and add code to onboard users to Web3 and enable them to sign blockchain transactions.
## Steps
*Using Firebase to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
### Call `loginWithBearer` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with both the Firebase SDK as well as the Arcana Auth SDK, before adding code to onboard users via Firebase.
App.vue
```
import { initializeApp } from 'firebase/app'
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from 'firebase/auth'
import { AuthProvider, BearerAuthentication } from '@arcana/auth'
const config = {
apiKey: "AIzaSyBddysLWM9CcpNEVLbUz52YwyQL_uytQX0", // Obtain this after registering app at Firebase console
authDomain: "arc4n4-docx.firebaseapp.com", // Project ID Domain setting in the Firebase console
projectId: "some-projectid-example-arc4n4-docx",
storageBucket: "some-storage-arc4n4-docx.appspot.com",
messagingSenderId: "2xxxx318486297382",
appId: "4:3184ddddddd7382:web:8b639axxxxxxxx39f85fe7",
measurementId: "G-EGccccccLDR"
};
const firebaseApp = initializeApp(config)
const firebaseAuth = getAuth(firebaseApp)
//Create Arcana Auth Provider
// Get client ID 'xar_live_xxxxxx' from Arcana Developer Dashboard
const auth = new AuthProvider("xar_live_123940ytyoxxxxxxx343o404",{
network: "mainnet", //change it to testnet or mainnet
})
export default {
name: 'App',
data: () => ({
email: '',
password: ''
}),
mounted () {
AP.init().then((k) => console.log(k)).catch(e => console.error(e)) //Initialize the Auth Provider
},
methods: {
async ultimate (upm) {
if (await AP.isLoggedIn()) {
window.alert('Already logged in')
return
}
await auth.loginWithBearer(BearerAuthentication.firebase, {
uid: upm.user.uid,
token: upm.user.accessToken
})
},
async login () { //Sign in existing Firebase users
const data = await signInWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
},
async register () { //Sign up new users with Firebase Auth
const data = await createUserWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
}
}
}
...
```
Refer to the [Sample Firebase Vue app integration example](https://github.com/arcana-network/auth-examples) to see how the `loginWithBearer` function is used.
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
**That is all.**
Your app is all set for authenticating users via Firebase. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
No Aggregate Login with Firebase
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for third-party IAM providers such as Firebase.
If a user has the same email ID registered with say a social login provider and with Firebase, logging into an app using Firebase will create a new unique user account even if the user uses the same email as the one used with a social login provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Firebase is used to log in and subsequently a social login provider or passwordless login is used by the same user having the same email ID.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Get Firebase User token](https://firebase.google.com/docs/reference/js/auth.user.md#usergetidtoken)
- [Using Firebase Auth](https://firebase.google.com/docs/auth)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Social Login Providers: Custom Login UI
Developers can choose to **not** use the plug-and-play login UI and instead build a custom login UI to onboard users.
In this case, developers must build custom login UI themselves after configuring the social login providers in the Arcana Developer Dashboard. This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for configured social login providers.
[Apple](apple-oauth/)
[Discord](discord-oauth/)
[GitHub](github-oauth/)
[Google](google-oauth/)
[Steam](steam-oauth/)
[Telegram](telegram-oauth/)
[Twitch](twitch-oauth/)
[Twitter](twitter-oauth/)
# User Login with Apple
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Apple authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Apple](../../../../../../setup/config-social/apple-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Apple to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('apple');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Apple
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Apple.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Discord
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Discord authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Discord](../../../../../../setup/config-social/discord-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Discord to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('discord');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Discord
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Discord.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with GitHub
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through GitHub authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure GitHub](../../../../../../setup/config-social/github-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using GitHub to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('github');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with GitHub
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via GitHub.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Google
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Google authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Google](../../../../../../setup/config-social/google-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Google to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('google');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Google
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Google.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Steam
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Steam authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Steam](../../../../../../setup/config-social/steam-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Steam to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('steam');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Steam
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Steam.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Telegram
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Telegram authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Telegram](../../../../../../setup/config-social/telegram-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Telegram to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('telegram');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Telegram
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Telegram.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitch
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Twitch authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitch](../../../../../../setup/config-social/twitch-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Twitch to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('twitch');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Twitch
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Twitch.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitter
In this guide, you will learn how a React/Next.js app integrated with the Arcana Auth SDK and Arcana Auth React SDK can onboard users with a custom login UI through Twitter authentication.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitter](../../../../../../setup/config-social/twitter-oauth/) as the authentication provider.
- Use the instructions and [integrate the React app](../../../../../integrate/react-nextjs/) with the Arcana Auth SDK and the Arcana Auth React SDK before adding code to onboard users.
## Steps
*Using Twitter to onboard users in a React/Next.js app requires a single line of code.*
## Step 1: Use `loginWithSocial`
App.js
```
import { useAuth } from "@arcana/auth-react";
function App() {
const { loading, isLoggedIn, loginWithSocial } = useAuth()
// custom login UI
const onConnectClick = async () => {
try {
await loginWithSocial('twitter');
} catch (err) {
console.log({ err });
// Handle error
}
};
if (loading) {
return
Loading...
;
}
if (!isLoggedIn) {
return (
Connect with Twitter
);
}
}
export default App
```
**That is all.**
The React/Next.js app is all set for onboarding users via Twitter.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/).
- [Arcana Auth React SDK Reference Guide](https://auth-react-sdk-ref-guide.netlify.app/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../custom-ui/) and onboard users in a 'Vanilla HTML/CSS/JS' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the app that uses `wagmi` and configure the SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Vanilla HTML/CSS/JS'.
- [Integrate](../../../integrate/wagmi/) 'Vanilla HTML/CSS/JS' app, create and initialize the `AuthProvider`.
## Steps
### 1. `connect`
Use the `connect()` function to bring up the plug-and-play pop-up modal in the app context and display the available options for user onboarding. Only those options are displayed that were earlier configured by the developer using the Arcana Developer Dashboard. The passwordless login option is enabled by default.
```
await auth.connect();
```
Plug-and-Play Login UI
Compact Mode
While creating the `AuthProvider`, use `connectoOptions` to optionally choose the [compact mode](../../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
```
connectOptions: {
compact: true // default - false
},
```
Login UI Options
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use..
No plug-and-play support for Firebase authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Firebase. Developers must build a custom login UI and add code to onboard users. For details, see [onboarding users via Firebase and custom login UI](../custom-ui/build-idm/firebase-login/)
No plug-and-play support for Telegram authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Telegram. Developers must build a custom login UI and add code to onboard users. For details, see \[\[{{ no such element: dict object['telegram_custom_ui_tag'] }}|onboarding users via Telegram and custom login UI\]\].
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Vanilla HTML/CSS/JS'** integration example: See `sample-auth-html-css-js` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Custom Login UI
[Passwordless Auth](build-pwdless-auth/)
[Social Providers](build-social/)
[IAM Providers](build-idm/)
Refer to the [Auth Examples](https://github.com/arcana-network/auth-examples) for sample applications that use custom login UI to onboard users.
# Build Custom Passwordless Auth
In this guide, you will learn how to integrate 'Vanilla HTML/CSS/JS' app with the Arcana Auth SDK and then onboard users through custom login UI and passwordless login option.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- The app must be [registered using the Arcana Developer Dashboard](../../../../../setup/config-auth/register-app/). A unique Client ID is assigned after app registration. It is required for integrating the app with the Arcana Auth SDK
- Follow the instructions as per the app type and [integrate the app](../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK.
Configuring App
Unlike other user onboarding options that require enabling authentication providers, passwordless login can be enabled without any configuration setup using the Arcana Developer Dashboard.
Developers can optionally choose to modify the default settings for branding and the Arcana wallet settings in the Arcana Developer Dashboard.
## Steps
*Follow these steps for enabling passwordless login in a Web3 app that is integrated with the Arcana Auth SDK.*
After integrating the app, add the code to onboard users in a passwordless manner using the SDK method listed below.
App users must supply an email ID to receive the OTP for logging into the app. An OTP is sent to the specified email ID. When the user provides the same OTP in the app context, authentication is complete and a wallet address is assigned to the user.
### Login with link
```
await auth.loginWithLink(`${email}`)
```
Deprecated
`loginWithLink` is deprecated.
Use `loginWithOTPStart`, `loginWithOTPComplete` for passwordless login with OTP. The OTP will be received via email supplied in `loginWithOTPStart` call.
### Login with OTP
```
try {
const loginState = await auth.loginWithOTPStart("john.doe@somemail.com");
await loginState.begin()
if(loginState.isCompleteRequired) {
// App is using default app-specific keys
// App must ask the user to input a 6-digit code received in mail
var userInput = prompt("Please enter a 6-digit code:", "111111");
// Validate if the input is a 6-digit code
if (userInput !== null &&
userInput.length === 6 &&
!isNaN(userInput)) {
const complete = await auth.loginWithOTPComplete(
userInput,
onMFARequired() => {
//Hide overlay, if used in the app
});
console.log("complete:",complete);
} else {
console.log("Invalid input. Please enter a valid 6-digit code.");
}
} else {
// App is using global keys, built-in OTP input UI is displayed by the SDK
// App is not required to add code for OTP input
}
} catch (e) {
console.log(e);
}
```
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Check if the user has logged in successfully:
```
const connected = await auth.isLoggedIn()
```
Log out the dApp user when requested:
```
await auth.logout()
```
**That is all.**
Your dApp is all set for onboarding users via the passwordless login option.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../concepts/authtype/)
- [Configure Social Providers](../../../../../setup/)
- [Arcana Auth SDK Errors](../../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
# IAM Providers: Custom Login UI
Developers can choose to **not** use Arcana's plug-and-play login UI for third-party IAM providers and instead build a custom login UI to onboard users.
In this case, developers must build the custom login UI themselves after configuring the IAM providers in the Arcana Developer Dashboard . This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for the third-party IAM providers.
[Cognito](cognito-oauth/)
[Firebase](firebase-login/)
# User Login with AWS Cognito
In this guide, you will learn how a Vanilla HTML/CSS/JS app integrated with the Arcana Auth SDK can onboard users via custom login UI and AWS Cognito as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure AWS Cognito](../../../../../../setup/config-idm/cognito-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using AWS Cognito to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
### Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via AWS Cognito.
```
await auth.loginWithSocial('aws')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
Your app is all set for authenticating users via AWS Cognito. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
Apps using IAM Providers
Apps usually use Arcana Auth SDK for user onboarding and blockchain transaction signing. Authentication providers must be set up in the Arcana Developer Dashboard before integrating with the SDK.
Some apps might use third-party IAM providers like AWS Cognito for authentication but still use Arcana Auth SDK to access Arcana wallet. The setup is different since third-party IAM providers support authentication verifiers like Google directly.
Developers only need to set up the IAM provider in the Arcana Developer Dashboard. They don't need to configure authentication verifiers that work directly with the IAM providers. Use the IAM provider's console, like Cognito Developer Console, to set up authentication verifiers like Google, not the Arcana Developer Dashboard.
No Aggregate Login with Cognito
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the third-party IAM providers such as Cognito.
If a user has the same email ID registered with say a social login provider and with Cognito, logging into an app using Cognito will create a new unique user account even if the user uses the same email as the one used with a social login provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Cognito is used to log in and subsequently a social login provider or passwordless login is used by the same user having the same email ID.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Firebase
In this guide, you will learn how a Vanilla HTML/CSS/JS app integrated with the Arcana Auth SDK and Firebase SDK can onboard users via custom login UI and Firebase as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Firebase](../../../../../../setup/config-idm/firebase-auth/) as the authentication provider.
- Install the Firebase SDK and integrate the app as explained in the Firebase documentation for [iOS apps](https://firebase.google.com/docs/ios/setup), [Android apps](https://firebase.google.com/docs/android/setup) and [web apps](https://firebase.google.com/docs/web/setup). Use [Firebase authentication](https://firebase.google.com/docs/auth) as per the Web3 app type, mobile or web app. Once a user is authenticated by Firebase, the developer must obtain the token and user identifier and provide it as input to the `loginWithBearer` function of the Arcana Auth SDK for onboarding users to Web3.
- Install the Arcana Auth SDK and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK by using the appropriate integration method as per the app type. After that follow the steps listed below and add code to onboard users to Web3 and enable them to sign blockchain transactions.
## Steps
*Using Firebase to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
### Call `loginWithBearer` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with both the Firebase SDK as well as the Arcana Auth SDK, before adding code to onboard users via Firebase.
App.vue
```
import { initializeApp } from 'firebase/app'
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from 'firebase/auth'
import { AuthProvider, BearerAuthentication } from '@arcana/auth'
const config = {
apiKey: "AIzaSyBddysLWM9CcpNEVLbUz52YwyQL_uytQX0", // Obtain this after registering app at Firebase console
authDomain: "arc4n4-docx.firebaseapp.com", // Project ID Domain setting in the Firebase console
projectId: "some-projectid-example-arc4n4-docx",
storageBucket: "some-storage-arc4n4-docx.appspot.com",
messagingSenderId: "2xxxx318486297382",
appId: "4:3184ddddddd7382:web:8b639axxxxxxxx39f85fe7",
measurementId: "G-EGccccccLDR"
};
const firebaseApp = initializeApp(config)
const firebaseAuth = getAuth(firebaseApp)
//Create Arcana Auth Provider
// Get client ID 'xar_live_xxxxxx' from Arcana Developer Dashboard
const auth = new AuthProvider("xar_live_123940ytyoxxxxxxx343o404",{
network: "mainnet", //change it to testnet or mainnet
})
export default {
name: 'App',
data: () => ({
email: '',
password: ''
}),
mounted () {
AP.init().then((k) => console.log(k)).catch(e => console.error(e)) //Initialize the Auth Provider
},
methods: {
async ultimate (upm) {
if (await AP.isLoggedIn()) {
window.alert('Already logged in')
return
}
await auth.loginWithBearer(BearerAuthentication.firebase, {
uid: upm.user.uid,
token: upm.user.accessToken
})
},
async login () { //Sign in existing Firebase users
const data = await signInWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
},
async register () { //Sign up new users with Firebase Auth
const data = await createUserWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
}
}
}
...
```
Refer to the [Sample Firebase Vue app integration example](https://github.com/arcana-network/auth-examples) to see how the `loginWithBearer` function is used.
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
**That is all.**
Your app is all set for authenticating users via Firebase. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
No Aggregate Login with Firebase
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for third-party IAM providers such as Firebase.
If a user has the same email ID registered with say a social login provider and with Firebase, logging into an app using Firebase will create a new unique user account even if the user uses the same email as the one used with a social login provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Firebase is used to log in and subsequently a social login provider or passwordless login is used by the same user having the same email ID.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Get Firebase User token](https://firebase.google.com/docs/reference/js/auth.user.md#usergetidtoken)
- [Using Firebase Auth](https://firebase.google.com/docs/auth)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Social Login Providers: Custom Login UI
Developers can choose to **not** use the plug-and-play login UI and instead build a custom login UI to onboard users.
In this case, developers must build custom login UI themselves after configuring the social login providers in the Arcana Developer Dashboard. This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for every configured social login provider.
[Apple](apple-oauth/)
[Discord](discord-oauth/)
[GitHub](github-oauth/)
[Google](google-oauth/)
[Steam](steam-oauth/)
[Telegram](telegram-oauth/)
[Twitch](twitch-oauth/)
[Twitter](twitter-oauth/)
# User Login with Apple
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Apple as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- [Follow the instructions to configure Apple](../../../../../../setup/config-social/apple-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Apple to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Apple.
```
await auth.loginWithSocial('apple')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all**
The Web3 app is all set for onboarding users via Apple.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Discord
In this guide, you will learn how a Vanilla HTML/CSS/JS app integrated with the Arcana Auth SDK can onboard users via custom login UI and Discord as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Discord](../../../../../../setup/config-social/discord-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Discord to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Discord.
```
await auth.loginWithSocial('discord')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Discord.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with GitHub
In this guide, you will learn how a Vanilla HTML/CSS/JS app integrated with the Arcana Auth SDK can onboard users via custom login UI and GitHub as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure GitHub](../../../../../../setup/config-social/github-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using GitHub to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via GitHub.
```
await auth.loginWithSocial('github')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via GitHub.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Google
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Google as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Google](../../../../../../setup/config-social/google-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Google to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Google.
```
await auth.loginWithSocial('google')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Google.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Steam OAuth
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Steam as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to obtain Steam API key and set it up in the dashboard](../../../../../../setup/config-social/steam-oauth/) for user authentication.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Steam to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Steam OAuth.
```
await auth.loginWithSocial('steam')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
Your app is all set for authenticating users via Steam OAuth. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
No Aggregate Login with Steam OAuth
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the Steam OAuth login mechanism.
When a user has the same email registered with a social login provider and Steam OAuth, logging in with Steam makes a new unique account. Even if the user later logs in with the same email through a social login provider or passwordless, it creates a different wallet address for the same user.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Telegram
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Telegram as the social authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- [Follow the instructions to configure Telegram](../../../../../../setup/config-social/telegram-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Telegram to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithBearer` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Telegram.
```
window.onload = () => {
const btn = document.getElementById("telegram-login");
btn.onclick = () => {
const url = new URL("/auth", "https://oauth.telegram.org");
url.searchParams.append("bot_id", "7097916610");
url.searchParams.append("scope", "profile");
url.searchParams.append("origin", "https://zcnk5z-5000.csb.app");
url.searchParams.append("return_to", "https://zcnk5z-5000.csb.app/redirect");
setTimeout(() => (window.location.href = url.toString()), 50);
};
};
```
```
const { AuthProvider } = window.arcana.auth;
window.onload = async () => {
const auth = new AuthProvider( //Use ClientID to create AuthProvider
"xar_dev_92ecc87db08e4c13b1fcd9b37ca9bf54fa874355"
);
await auth.init(); //Initialize the Auth Provider
const u = new URL(window.location.href);
if (u.hash) {
const p = new URLSearchParams(u.hash.substring(1));
const t = p.get("tgAuthResult");
if (t) {
cleanURL();
//Initiate social login, must set app domain in Telegram bot for successful login
await auth.loginWithBearer("telegram", { token: t });
}
}
};
function cleanURL() {
const cleanUrl = window.location.origin + window.location.pathname;
window.history.replaceState(null, "", cleanUrl);
}
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Telegram.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitch
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Twitch as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitch](../../../../../../setup/config-social/twitch-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Twitch to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Twitch.
```
await auth.loginWithSocial('twitch')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Twitch.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitter
In this guide, you will learn how a 'Vanilla HTML/CSS/JS' app integrated with the Arcana Auth SDK can onboard users via custom login UI and Twitter as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitter](../../../../../../setup/config-social/twitter-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Twitter to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Twitter.
```
await auth.loginWithSocial('twitter')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Twitter.
No Aggregate Login with Twitter OAuth
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the Steam OAuth login mechanism.
When a user has the same email registered with a social login provider and Steam OAuth, logging in with Steam makes a new unique account. Even if the user later logs in with the same email through a social login provider or passwordless, it creates a different wallet address for the same user.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'Vue' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../custom-ui/) and onboard users in a 'Vue' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the app that uses `wagmi` and configure the SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Vue'.
- [Integrate](../../../integrate/wagmi/) 'Vue' app, create and initialize the `AuthProvider`.
## Steps
### 1. `connect`
Use the `connect()` function to bring up the plug-and-play pop-up modal in the app context and display the available options for user onboarding. Only those options are displayed that were earlier configured by the developer using the Arcana Developer Dashboard. The passwordless login option is enabled by default.
```
await auth.connect();
```
Plug-and-Play Login UI
Compact Mode
While creating the `AuthProvider`, use `connectoOptions` to optionally choose the [compact mode](../../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
```
connectOptions: {
compact: true // default - false
},
```
Login UI Options
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use..
No plug-and-play support for Firebase authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Firebase. Developers must build a custom login UI and add code to onboard users. For details, see [onboarding users via Firebase and custom login UI](../../vanilla/custom-ui/build-idm/firebase-login/)
No plug-and-play support for Telegram authentication.
The [plug and play feature](../../../../concepts/plug-and-play-auth/) of the Arcana Auth SDK does not support social login via Telegram. Developers must build a custom login UI and add code to onboard users. For details, see \[\[{{ no such element: dict object['telegram_custom_ui_tag'] }}|onboarding users via Telegram and custom login UI\]\].
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Vue'** integration example: See `sample-auth-vue` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
[Try Demo App](https://demo.arcana.network)
# Custom Login UI
[Passwordless Auth](build-pwdless-auth/)
[Social Login Provider](build-social/)
[IAM Provider](build-idm/)
# Build Custom Passwordless Auth
In this guide, you will learn how to integrate Vue app with the Arcana Auth SDK and then onboard users through custom login UI and passwordless login option.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- The app must be [registered using the Arcana Developer Dashboard](../../../../../setup/config-auth/register-app/). A unique Client ID is assigned after app registration. It is required for integrating the app with the Arcana Auth SDK
- Follow the instructions as per the app type and [integrate the app](../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK.
Configuring App
Unlike other user onboarding options that require enabling authentication providers, passwordless login can be enabled without any configuration setup using the Arcana Developer Dashboard.
Developers can optionally choose to modify the default settings for branding and the Arcana wallet settings in the Arcana Developer Dashboard.
## Steps
*Follow these steps for enabling passwordless login in a Web3 app that is integrated with the Arcana Auth SDK.*
After integrating the app, add the code to onboard users in a passwordless manner using the SDK method listed below.
App users must supply an email ID to receive the OTP for logging into the app. An OTP is sent to the specified email ID. When the user provides the same OTP in the app context, authentication is complete and a wallet address is assigned to the user.
### Login with link
```
await auth.loginWithLink(`${email}`)
```
Deprecated
`loginWithLink` is deprecated.
Use `loginWithOTPStart`, `loginWithOTPComplete` for passwordless login with OTP. The OTP will be received via email supplied in `loginWithOTPStart` call.
### Login with OTP
```
try {
const loginState = await auth.loginWithOTPStart("john.doe@somemail.com");
await loginState.begin()
if(loginState.isCompleteRequired) {
// App is using default app-specific keys
// App must ask the user to input a 6-digit code received in mail
var userInput = prompt("Please enter a 6-digit code:", "111111");
// Validate if the input is a 6-digit code
if (userInput !== null &&
userInput.length === 6 &&
!isNaN(userInput)) {
const complete = await auth.loginWithOTPComplete(
userInput,
onMFARequired() => {
//Hide overlay, if used in the app
});
console.log("complete:",complete);
} else {
console.log("Invalid input. Please enter a valid 6-digit code.");
}
} else {
// App is using global keys, built-in OTP input UI is displayed by the SDK
// App is not required to add code for OTP input
}
} catch (e) {
console.log(e);
}
```
Global vs. App Specific Keys
Apps using app-specific keys must use a custom login UI that allows users to input the OTP. In this case, the `isCompleteRequired` boolean returns `true` after initiating login with OTP.
Apps using global keys are not required to use a custom login UI. A built-in login UI is automatically displayed for the user for OTP. Users must enter the OTP received via email in this UI.
MFA Enabled / Disabled
During passwordless login via OTP, apps configured for MFA and those using overlays must hide it to enable OTP input. Use the `isMFARequired` callback in the `loginWithOTPComplete` method to hide the overlay.
Check if the user has logged in successfully:
```
const connected = await auth.isLoggedIn()
```
Log out the dApp user when requested:
```
await auth.logout()
```
**That is all.**
Your dApp is all set for onboarding users via the passwordless login option.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../concepts/authtype/)
- [Configure Social Providers](../../../../../setup/)
- [Arcana Auth SDK Errors](../../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../../auth-usage-guide/)
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
# IAM Providers: Custom Login UI
Developers can choose to **not** use Arcana's plug-and-play login UI for third-party IAM providers and instead build a custom login UI to onboard users.
In this case, developers must build the custom login UI themselves after configuring the IAM providers in the Arcana Developer Dashboard. This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for the third-party IAM providers.
[Cognito](cognito-oauth/)
[Firebase](firebase-login/)
# User Login with AWS Cognito
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and AWS Cognito as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure AWS Cognito](../../../../../../setup/config-idm/cognito-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using AWS Cognito to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
### Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via AWS Cognito.
```
await auth.loginWithSocial('aws')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
Your app is all set for authenticating users via AWS Cognito. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
Apps using IAM Providers
Apps usually use Arcana Auth SDK for user onboarding and blockchain transaction signing. Authentication providers must be set up in the Arcana Developer Dashboard before integrating with the SDK.
Some apps might use third-party IAM providers like AWS Cognito for authentication but still use Arcana Auth SDK to access Arcana wallet. The setup is different since third-party IAM providers support authentication verifiers like Google directly.
Developers only need to set up the IAM provider in the Arcana Developer Dashboard. They don't need to configure authentication verifiers that work directly with the IAM providers. Use the IAM provider's console, like Cognito Developer Console, to set up authentication verifiers like Google, not the Arcana Developer Dashboard.
No Aggregate Login with Cognito
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the third-party IAM providers such as Cognito.
If a user has the same email ID registered with say a social login provider and with Cognito, logging into an app using Cognito will create a new unique user account even if the user uses the same email as the one used with a social login provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Cognito is used to log in and subsequently a social login provider or passwordless login is used by the same user having the same email ID.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Firebase
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK and Firebase SDK can onboard users via custom login UI and Firebase as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Firebase](../../../../../../setup/config-idm/firebase-auth/) as the authentication provider.
- Install the Firebase SDK and integrate the app as explained in the Firebase documentation for [iOS apps](https://firebase.google.com/docs/ios/setup), [Android apps](https://firebase.google.com/docs/android/setup) and [web apps](https://firebase.google.com/docs/web/setup). Use [Firebase authentication](https://firebase.google.com/docs/auth) as per the Web3 app type, mobile or web app. Once a user is authenticated by Firebase, the developer must obtain the token and user identifier and provide it as input to the `loginWithBearer` function of the Arcana Auth SDK for onboarding users to Web3.
- Install the Arcana Auth SDK and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK by using the appropriate integration method as per the app type. After that follow the steps listed below and add code to onboard users to Web3 and enable them to sign blockchain transactions.
## Steps
*Using Firebase to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
### Call `loginWithBearer` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with both the Firebase SDK as well as the Arcana Auth SDK, before adding code to onboard users via Firebase.
App.vue
```
import { initializeApp } from 'firebase/app'
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from 'firebase/auth'
import { AuthProvider, BearerAuthentication } from '@arcana/auth'
const config = {
apiKey: "AIzaSyBddysLWM9CcpNEVLbUz52YwyQL_uytQX0", // Obtain this after registering app at Firebase console
authDomain: "arc4n4-docx.firebaseapp.com", // Project ID Domain setting in the Firebase console
projectId: "some-projectid-example-arc4n4-docx",
storageBucket: "some-storage-arc4n4-docx.appspot.com",
messagingSenderId: "2xxxx318486297382",
appId: "4:3184ddddddd7382:web:8b639axxxxxxxx39f85fe7",
measurementId: "G-EGccccccLDR"
};
const firebaseApp = initializeApp(config)
const firebaseAuth = getAuth(firebaseApp)
//Create Arcana Auth Provider
// Get client ID 'xar_live_xxxxxx' from Arcana Developer Dashboard
const auth = new AuthProvider("xar_live_123940ytyoxxxxxxx343o404",{
network: "mainnet", //change it to testnet or mainnet
})
export default {
name: 'App',
data: () => ({
email: '',
password: ''
}),
mounted () {
AP.init().then((k) => console.log(k)).catch(e => console.error(e)) //Initialize the Auth Provider
},
methods: {
async ultimate (upm) {
if (await AP.isLoggedIn()) {
window.alert('Already logged in')
return
}
await auth.loginWithBearer(BearerAuthentication.firebase, {
uid: upm.user.uid,
token: upm.user.accessToken
})
},
async login () { //Sign in existing Firebase users
const data = await signInWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
},
async register () { //Sign up new users with Firebase Auth
const data = await createUserWithEmailAndPassword(firebaseAuth, this.email, this.password)
console.log('Data:', data)
return this.ultimate(data)
}
}
}
...
```
Refer to the [Sample Firebase Vue app integration example](https://github.com/arcana-network/auth-examples) to see how the `loginWithBearer` function is used.
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
**That is all.**
Your app is all set for authenticating users via Firebase. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
No Aggregate Login with Firebase
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for third-party IAM providers such as Firebase.
If a user has the same email ID registered with say a social login provider and with Firebase, logging into an app using Firebase will create a new unique user account even if the user uses the same email as the one used with a social login provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Firebase is used to log in and subsequently a social login provider or passwordless login is used by the same user having the same email ID.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Get Firebase User token](https://firebase.google.com/docs/reference/js/auth.user.md#usergetidtoken)
- [Using Firebase Auth](https://firebase.google.com/docs/auth)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Social Login Providers: Custom Login UI
Developers can choose to **not** use the plug-and-play login UI and instead build a custom login UI to onboard users.
In this case, developers must build custom login UI themselves after configuring the social login providers in the Arcana Developer Dashboard. This custom login UI must call appropriate user onboarding functions offered by the Arcana Auth SDK for every configured social login provider.
[Apple](apple-oauth/)
[Discord](discord-oauth/)
[GitHub](github-oauth/)
[Google](google-oauth/)
[Steam](steam-oauth/)
[Telegram](telegram-oauth/)
[Twitch](twitch-oauth/)
[Twitter](twitter-oauth/)
# User Login with Apple
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Apple as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- [Follow the instructions to configure Apple](../../../../../../setup/config-social/apple-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Apple to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Apple.
```
await auth.loginWithSocial('apple')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all**
The Web3 app is all set for onboarding users via Apple.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Discord
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Discord as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Discord](../../../../../../setup/config-social/discord-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Discord to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Discord.
```
await auth.loginWithSocial('discord')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Discord.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with GitHub
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and GitHub as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure GitHub](../../../../../../setup/config-social/github-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using GitHub to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via GitHub.
```
await auth.loginWithSocial('github')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via GitHub.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Google
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Google as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Google](../../../../../../setup/config-social/google-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Google to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Google.
```
await auth.loginWithSocial('google')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Google.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Steam OAuth
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Steam as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to obtain Steam API key and set it up in the dashboard](../../../../../../setup/config-social/steam-oauth/) for user authentication.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Steam to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Steam OAuth.
```
await auth.loginWithSocial('steam')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See [Arcana Auth SDK Usage Guide](../../../../../auth-usage-guide/) for details.
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
Your app is all set for authenticating users via Steam OAuth. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.
No Aggregate Login with Steam OAuth
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the Steam OAuth login mechanism.
When a user has the same email registered with a social login provider and Steam OAuth, logging in with Steam makes a new unique account. Even if the user later logs in with the same email through a social login provider or passwordless, it creates a different wallet address for the same user.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handing authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Telegram
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Telegram as the social authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- [Follow the instructions to configure Telegram](../../../../../../setup/config-social/telegram-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Telegram to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithBearer` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Telegram.
```
window.onload = () => {
const btn = document.getElementById("telegram-login");
btn.onclick = () => {
const url = new URL("/auth", "https://oauth.telegram.org");
url.searchParams.append("bot_id", "7097916610");
url.searchParams.append("scope", "profile");
url.searchParams.append("origin", "https://zcnk5z-5000.csb.app");
url.searchParams.append("return_to", "https://zcnk5z-5000.csb.app/redirect");
setTimeout(() => (window.location.href = url.toString()), 50);
};
};
```
```
const { AuthProvider } = window.arcana.auth;
window.onload = async () => {
const auth = new AuthProvider( //Use ClientID to create AuthProvider
"xar_dev_92ecc87db08e4c13b1fcd9b37ca9bf54fa874355"
);
await auth.init(); //Initialize the Auth Provider
const u = new URL(window.location.href);
if (u.hash) {
const p = new URLSearchParams(u.hash.substring(1));
const t = p.get("tgAuthResult");
if (t) {
cleanURL();
//Initiate social login, must set app domain in Telegram bot for successful login
await auth.loginWithBearer("telegram", { token: t });
}
}
};
function cleanURL() {
const cleanUrl = window.location.origin + window.location.pathname;
window.history.replaceState(null, "", cleanUrl);
}
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Telegram.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitch
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Twitch as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitch](../../../../../../setup/config-social/twitch-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Twitch to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Twitch.
```
await auth.loginWithSocial('twitch')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the app to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Twitch.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# User Login with Twitter
In this guide, you will learn how a Vue app integrated with the Arcana Auth SDK can onboard users via custom login UI and Twitter as the authentication provider.
## Prerequisites
- Make sure you can access the Arcana Developer Dashboard:
- Use the [Arcana Developer Dashboard](../../../../../../concepts/dashboard/) to [register the app](../../../../../../setup/config-auth/register-app/) and obtain a unique Client ID required for integrating the app with the Arcana Auth SDK.
- Carefully [follow the instructions to configure Twitter](../../../../../../setup/config-social/twitter-oauth/) as the authentication provider.
- Use the appropriate integration method as per the app type and [integrate the app](../../../../../integrate/vanilla-html-css-js/) with the Arcana Auth SDK before accessing the user onboarding function of the Arcana Auth SDK.
## Steps
*Using Twitter to onboard users in a Web3 app that is integrated with the Arcana Auth SDK requires a single line of code.*
## Step 1: Call `loginWithSocial` function
Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via Twitter.
```
await auth.loginWithSocial('twitter')
```
Check if a user is logged in:
```
const connected = await auth.isLoggedIn()
```
Add code in the application to log out an authenticated user:
```
await auth.logout()
```
**That is all.**
The Web3 app is all set for onboarding users via Twitter.
No Aggregate Login with Twitter OAuth
The [aggregate login feature](../../../../../../concepts/aggregatelogin/) does not work for the Steam OAuth login mechanism.
When a user has the same email registered with a social login provider and Steam OAuth, logging in with Steam makes a new unique account. Even if the user later logs in with the same email through a social login provider or passwordless, it creates a different wallet address for the same user.
Arcana JWT Token
Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the [Arcana JWT Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `loginToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/jwt-token-validation/) and subsequently generate another token for app use if required.
In the future, the Arcana JWT Token will be deprecated. Use `userDIDToken` to verify user.
Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the [Arcana DID Token](../../../../../../concepts/an-jwt-token/). App developers can access this token via `getUser()` method and refer to the `userDIDToken` field of the [`UserInfo`](https://authsdk-ref-guide.netlify.app/interfaces/userinfo) object.
Developers can use this token to [verify the user](../../../../../../concepts/an-did-token/#verify-did-token) and subsequently generate another token for app use.
## What's Next?
Authenticated users can instantly access the in-app Arcana wallet UI for signing blockchain transactions. Use the `AuthProvider` EIP-1193 standard Ethereum provider to call JSON/RPC functions and Web3 wallet operations in the app. [Learn more...](../../../../../web3-ops/evm/)
## See also
- [Authentication Types](../../../../../../concepts/authtype/)
- [Handling authentication errors](../../../../../auth-error-msg/)
- [Auth Examples](https://github.com/arcana-network/auth-examples)
# Custom Login UI
Onboard users in a 'Wagmi' app integrated with the Arcana Auth SDK through a custom login UI.
Plug-and-Play Login UI
You can onboard users in a 'Wagmi' app faster through the built-in, [plug-and-play login UI](../../../../concepts/plug-and-play-auth/) instead of choosing to build a custom login UI. [Learn more...](../wagmi-pnp-ui/)
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Wagmi'.
- [Integrate](../../../integrate/wagmi/) 'Wagmi' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Configure `ArcanaConnector`
`ArcanaConnector` is created earlier as part of SDK integration. When using a custom login UI to onboard users, configure `ArcanaConnector` differently.
Add code in the custom UI for onboarding via social login and passwordless options by using the `setLogin` function.
*Enable Authentication Provider*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for user login via Google */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'google', //See 'Custom Login UI' section in the documentation for other supported providers.
} // Optional, specify here during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'google'
})
*/
...
```
*Enable Passwordless Login*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for Passwordless user login */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'passwordless',
email: 'abc@example.com' //optional
} // Optional, specify login details here or during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'passwordless',
email: 'abc@example.com' //optional
})
*/
...
```
Single Provider Optimization
When using a single social login provider, specify it when creating ArcanaConnector to optimize onboarding. There's no need to use setLogin later in the custom login UI code.
For multiple social login providers, create ArcanaConnector without specifying a provider. Use the setLogin function later based on the user's choice.
### 2. Set up `WagmiConfig`
Use the `ArcanaConnector` and set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { AuthProvider } from '@arcana/auth';
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"xar_dev_c2fb7be163754e57d384e24257ea2c8d2a5dd31a"
);
}
export const connector = () => {
return new ArcanaConnector({auth,})
};
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }),
connector(),
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
```
```
// Note:
// This sample code is for
// wagmi versions 1.x.y and auth-wagmi 2.a.b
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { newAuthProvider } from "./utils/newArcanaAuth";
import { useAccount, useConnect, useDisconnect, useBalance } from 'wagmi'
import "../styles/globals.css";
const { chains, provider, webSocketProvider } = configureChains(
[mainnet, polygon, polygonAmoy],
[publicProvider()],
{ targetQuorum: 1 }
);
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: newAuthProvider(),
login: {
provider: "google",
},
},
});
};
const { chains, publicClient } = configureChains(
[polygon, polygonAmoy],
[publicProvider()]
);
export const wagmiEntity = createConfig({
autoConnect: true,
connectors: [connector(chains)],
publicClient,
});
...
```
### 3. Initialize Wagmi App Components
```
//
// For apps using Wagmi versions v2.a.b and auth-wagmi v3.x.y
//
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
```
//
// For apps using Wagmi versions v1.a.b and auth-wagmi v2.x.y
//
function App({ Component, pageProps }: AppProps) {
return (
);
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Wagmi'** integration example: See `sample-auth-wagmi-2`, `sample-auth-wagmi-viem`, `sample-auth-wagmi` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'Wagmi' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../wagmi-custom-ui/) and onboard users in a 'Wagmi' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure Arcana Auth SDK SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Wagmi'.
- [Integrate](../../../integrate/wagmi/) 'Wagmi' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Setup `WagmiConfig`
Use the `ArcanaConnector` created during app integration to set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
//
// For apps using Wagmi versions v2.a.b and auth-wagmi v3.x.y
//
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { AuthProvider } from '@arcana/auth'
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"Your-app-Client-ID"
);
}
const connector = new ArcanaConnector({ auth });
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }),
connector(),
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
...
```
```
//
// For apps using Wagmi versions v1.x.y and auth-wagmi v2.a.b
//
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
import { polygon, polygonAmoy } from "wagmi/chains";
import { useAccount, useConnect, useDisconnect, useBalance } from 'wagmi'
import "../styles/globals.css";
import { AuthProvider } from '@arcana/auth'
import { ArcanaConnector } from "@arcana/auth-wagmi"
let auth: AuthProvider | null;
if (!auth) {
auth = new AuthProvider(
"Your-app-Client-ID"
);
}
const { chains, provider, webSocketProvider } = configureChains(
[mainnet, polygon, polygonAmoy],
[publicProvider()],
{ targetQuorum: 1 }
);
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
},
});
};
const { chains, publicClient } = configureChains(
[polygon, polygonAmoy],
[publicProvider()]
);
export const wagmiEntity = createConfig({
autoConnect: true,
connectors: [connector(chains)],
publicClient,
});
...
```
### 2. Initialize `WagmiProvider`
Use the Wagmi config to initialize the `WagmiProvider`.
```
//
// For apps using Wagmi versions v2.a.b and auth-wagmi v3.x.y
//
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
```
//
// For apps using Wagmi versions v1.a.b and auth-wagmi v2.x.y
//
function App({ Component, pageProps }: AppProps) {
return (
);
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Wagmi'** integration example: See `sample-auth-wagmi-2`, `sample-auth-wagmi-viem`, `sample-auth-wagmi` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Custom Login UI
Onboard users in a 'WalletConnect' app integrated with the Arcana Auth SDK through a custom login UI.
Plug-and-Play Login UI
You can onboard users in a 'WalletConnect' app faster through the built-in, [plug-and-play login UI](../../../../concepts/plug-and-play-auth/) instead of choosing to build a custom login UI. [Learn more...](../walletconnect-pnp-ui/)
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'WalletConnect'.
- [Integrate](../../../integrate/wagmi/) 'WalletConnect' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Configure `ArcanaConnector`
`ArcanaConnector` is created earlier as part of SDK integration. When using a custom login UI to onboard users, configure `ArcanaConnector` differently.
Add code in the custom UI for onboarding via social login and passwordless options by using the `setLogin` function.
*Enable Authentication Provider*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for user login via Google */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'google', //See 'Custom Login UI' section in the documentation for other supported providers.
} // Optional, specify here during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'google'
})
*/
...
```
*Enable Passwordless Login*
```
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonAmoy } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
/* Using Custom UI for Passwordless user login */
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
login: {
provider: 'passwordless',
email: 'abc@example.com' //optional
} // Optional, specify login details here or during ArcanaConnector instantiation or in the setLogin function
},
});
};
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth
},
});
};
connector.setLogin({
provider: 'passwordless',
email: 'abc@example.com' //optional
})
*/
...
```
Single Provider Optimization
When using a single social login provider, specify it when creating ArcanaConnector to optimize onboarding. There's no need to use setLogin later in the custom login UI code.
For multiple social login providers, create ArcanaConnector without specifying a provider. Use the setLogin function later based on the user's choice.
### 2. Set up `WagmiConfig`
Use the `ArcanaConnector` and set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
//Use "`auth-wagmi` version > v2.0.0"
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
### 3. Initialize WalletConnect App Component
```
//
// For apps using Wagmi versions v2.a.b and auth-wagmi v3.x.y
//
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
```
//
// For apps using Wagmi versions v1.a.b and auth-wagmi v2.x.y
//
function App({ Component, pageProps }: AppProps) {
return (
);
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'WalletConnect'** integration example: See `sample-auth-walletconnect` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'WalletConnect' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../walletconnect-custom-ui/) and onboard users in a 'WalletConnect' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'WalletConnect'.
- [Integrate](../../../integrate/wagmi/) 'WalletConnect' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Setup `WagmiConfig`
Use the `ArcanaConnector` created during app integration to set up [Wagmi config](https://wagmi.sh/react/getting-started).
```
//Use "`auth-wagmi` version > v2.0.0"
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Buffer } from 'buffer'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { WagmiProvider } from 'wagmi'
import App from './App.tsx'
import { config } from './wagmi.ts'
import './index.css'
globalThis.Buffer = Buffer
const queryClient = new QueryClient()
ReactDOM.createRoot(document.getElementById('root')!).render(
,
)
```
### 2. Set up `WagmiProvider`
Next, use the `WagmiProvider` with this specified Wagmi config and initialize `WagmiProvider` in the app.
```
//This example uses Arcana Wallet connector and Coinbase Wallet
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { getAuthProvider } from './arcanaConnector';
export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({
projectId: '3fcc6bba6f1de962d911bb5b5c3dba68', //WalletConnect ProjectID
}),
ArcanaConnector(
{
auth: getAuthProvider(),
}
)
],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
```
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'WalletConnect'** integration example: See `sample-auth-walletconnect` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Custom Login UI
Onboard users in a 'Web3-React' app integrated with the Arcana Auth SDK through a custom login UI.
Plug-and-Play Login UI
You can onboard users in a 'Web3-React' app faster through the built-in, [plug-and-play login UI](../../../../concepts/plug-and-play-auth/) instead of choosing to build a custom login UI. [Learn more...](../web3-react-pnp-ui/)
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Web3-React'.
- [Integrate](../../../integrate/wagmi/) 'Web3-React' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Configure `ArcanaConnector`
`ArcanaConnector` is created earlier as part of SDK integration. When using a custom login UI to onboard users, configure `ArcanaConnector` differently.
Add code in the custom UI for onboarding via social login and passwordless options by using the `setLogin` function.
#### Social Login
example/connectors/arcanaWallet.ts
```
// custom ui onboarding - google
import { ArcanaConnector } from "@arcana/auth-web3-react"
import { AuthProvider } from "@arcana/auth"
import { initializeConnector } from "@web3-react/core"
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const [authConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
login: {
provider: 'google',
} // either add here or in setLogin function
})
)
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
export const [authConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
})
)
authConnect.setLogin({ provider: 'google' })
*/
...
```
#### Passwordless Login
example/connectors/arcanaWallet.ts
```
//custom ui onboarding - passwordless
import { ArcanaConnector } from "@arcana/auth-web3-react"
import { AuthProvider } from "@arcana/auth"
import { initializeConnector } from "@web3-react/core"
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const [authConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
login: {
provider: 'passwordless',
email: 'abc@example.com'
} // either add here or in setLogin function
})
)
// Custom UI Alternative
// Use setLogin function after creating the connector.
/*
export const [authConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
})
)
authConnect.setLogin({ provider: 'passwordless', email: 'abc@example.com' })
*/
...
```
Single Provider Optimization
When using a single social login provider, specify it when creating ArcanaConnector to optimize onboarding. There's no need to use setLogin later in the custom login UI code.
For multiple social login providers, create ArcanaConnector without specifying a provider. Use the setLogin function later based on the user's choice.
### 2. Use `ArcanaConnector`
In the Web3-React app, use the `ArcanaConnector` created earlier and set up the required hooks:
```
import { useEffect, useState } from "react";
import { MAINNET_CHAINS } from "../../chains";
import { hooks, arcanaConnect } from "../../connectors/arcanaWallet";
import { Card } from "../Card";
const CHAIN_IDS = Object.keys(MAINNET_CHAINS).map(Number);
const {
useChainId,
useAccounts,
useIsActivating,
useIsActive,
useProvider,
useENSNames,
} = hooks;
export default function ArcanaConnectCard() {
const chainId = useChainId();
const accounts = useAccounts();
const isActivating = useIsActivating();
const isActive = useIsActive();
const provider = useProvider();
const ENSNames = useENSNames(provider);
const [error, setError] = useState(undefined);
// attempt to connect eagerly on mount
useEffect(() => {
arcanaConnect.connectEagerly().catch((error) => {
console.debug("Failed to connect eagerly to arcanaConnect", error);
});
}, []);
return (
);
}
```
Now, you are all set to onboard users in the Web3-React app using the custom login UI and enable Arcana wallet for the authenticated users.
pages/index.tsx
```
import ArcanaConnectCard from "../components/connectorCards/ArcanaConnectCard";
import CoinbaseWalletCard from "../components/connectorCards/CoinbaseWalletCard";
import GnosisSafeCard from "../components/connectorCards/GnosisSafeCard";
import MetaMaskCard from "../components/connectorCards/MetaMaskCard";
import NetworkCard from "../components/connectorCards/NetworkCard";
import WalletConnectCard from "../components/connectorCards/WalletConnectCard";
import WalletConnectV2Card from "../components/connectorCards/WalletConnectV2Card";
import ProviderExample from "../components/ProviderExample";
export default function Home() {
return (
<>
);
>
}
```
Web3-React App integrated with the Arcana Auth
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Web3-React'** integration example: See `sample-auth-web3-react` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
- [Arcana Auth SDK Usage Guide](../../../auth-usage-guide/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# Plug-and-Play Login UI
Use the built-in, [plug-and-play login UI modal](../../../../concepts/plug-and-play-auth/) to quickly onboard users in a 'Web3-React' app integrated with the Arcana Auth Wagmi SDK.
Custom Login UI
You can onboard users through a [custom login UI](../../../../concepts/custom-login-ui/) instead of the [built-in plug-and-play](../../../../concepts/plug-and-play-auth/) one. See [how to use custom login UI](../web3-react-custom-ui/) and onboard users in a 'Web3-React' app.
## Prerequisites
- [Register](../../../../setup/config-auth/register-app/) the Wagmi app and configure SDK usage [settings for social login](../../../../setup/) providers, [manage app chains](../../../../setup/config-wallet-chains/) and [wallet user experience](../../../../setup/config-wallet/).
- Install the [required SDK packages](../../../sdk-installation/) for 'Web3-React'.
- [Integrate](../../../integrate/wagmi/) 'Web3-React' app and create `AuthProvider`, `ArcanaConnector`.
## Steps
### 1. Create `AuthProvider` and `ArcanaConnector`
```
import { initializeConnector } from "@web3-react/core";
import { ArcanaConnector } from "@arcana/auth-web3-react";
import { AuthProvider } from "@arcana/auth";
import { URLS } from "../chains";
const auth = new AuthProvider(
"xar_test_b2ddexxxxxxxxxxxxxxxxxxxx8b1fa3f" //App client ID via Dashboard
);
export const [arcanaConnect, hooks] = initializeConnector(
(actions) =>
new ArcanaConnector(auth, {
actions,
})
);
...
```
Compact Mode
While creating the `AuthProvider`, you can choose the [compact mode (optional)](../../../../concepts/plug-and-play-auth/#compact-modal) for the plug-and-play login UI.
### 2. Use `ArcanaConnector`
In the Web3-React app, use the `ArcanaConnector` and React hooks to connect `ArcanaConnector` with the Web3-React ecosystem via `ArcanaConnectCard`.
```
import { useEffect, useState } from "react";
import { MAINNET_CHAINS } from "../../chains";
import { hooks, arcanaConnect } from "../../connectors/arcanaWallet";
import { Card } from "../Card";
const CHAIN_IDS = Object.keys(MAINNET_CHAINS).map(Number);
const {
useChainId,
useAccounts,
useIsActivating,
useIsActive,
useProvider,
useENSNames,
} = hooks;
export default function ArcanaConnectCard() {
const chainId = useChainId();
const accounts = useAccounts();
const isActivating = useIsActivating();
const isActive = useIsActive();
const provider = useProvider();
const ENSNames = useENSNames(provider);
const [error, setError] = useState(undefined);
// attempt to connect eagerly on mount
useEffect(() => {
arcanaConnect.connectEagerly().catch((error) => {
console.debug("Failed to connect eagerly to arcanaConnect", error);
});
}, []);
return (
);
}
```
Now, you are all set to onboard users in the Web3-React app using the plug-and-play login UI and enable Arcana wallet for the authenticated users.
pages/index.tsx
```
import ArcanaConnectCard from "../components/connectorCards/ArcanaConnectCard";
import CoinbaseWalletCard from "../components/connectorCards/CoinbaseWalletCard";
import GnosisSafeCard from "../components/connectorCards/GnosisSafeCard";
import MetaMaskCard from "../components/connectorCards/MetaMaskCard";
import NetworkCard from "../components/connectorCards/NetworkCard";
import WalletConnectCard from "../components/connectorCards/WalletConnectCard";
import WalletConnectV2Card from "../components/connectorCards/WalletConnectV2Card";
import ProviderExample from "../components/ProviderExample";
export default function Home() {
return (
<>
);
>
}
```
Web3-React App integrated with the Arcana Auth
## What's Next?
Use `AuthProvider`, the EIP-1193 provider offered by the SDK, to call supported JSON/RPC functions and [Web3 wallet operations](../../../web3-ops/evm/) in the authenticated user's context.
## See also
**'Web3-React'** integration example: See `sample-auth-web3-react` submodule in [SDK Example GitHub repository.](https://github.com/arcana-network/auth-examples)
- [FAQ](../../../../faq/faq-gen/)
- [Troubleshooting Guide](../../../../troubleshooting/)
- [Arcana Auth SDK Errors](../../../auth-error-msg/)
Arcana Auth SDK Quick Links
- [Arcana Auth SDK Reference](https://authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth)
Arcana Auth Wagmi SDK Quick Links
- [Arcana Auth Wagmi SDK Reference Guide](https://wagmi-authsdk-ref-guide.netlify.app/)
- [Release notes](../../../../relnotes/latest-auth-release-note/)
- [Changelog](https://github.com/arcana-network/auth-wagmi/releases)
- [Download SDK](https://www.npmjs.com/package/@arcana/auth-wagmi)
[Try Demo App](https://demo.arcana.network)
# EVM Wallet Ops
The Arcana wallet supports [standard Ethereum JSON-RPC specification API](https://ethereum.org/en/developers/docs/apis/json-rpc/) via the `AuthProvider`.
Non-EVM Chains
Note that the JSON/RPC functions and Web3 wallet operations supported by the `AuthProvider` may vary across EVM chains and other chains such as [Solana](../solana/), [MultiversX](../mvx/), [Near](../near/), etc.
## Prerequisites
- [Register](../../../setup/config-auth/register-app/) the Near app and configure SDK usage [settings for social login](../../../setup/) providers, [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/), integrate the SDK with the app and create `AuthProvider`.
## Handle Events
```
const auth = new AuthProvider(
"xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
)
```
```
try {
await auth.init()
} catch (e) {
// Handle exception case
}
```
```
// Assuming Auth SDK is integrated and initialized
try {
provider = auth.provider
const connected = await auth.isLoggedIn()
console.log({ connected })
setHooks()
} catch (e) {
// Handle exception case
}
// setHooks: Manage chain or account switch in Arcana wallet
function setHooks() {
provider.on('connect', async (params) => {
console.log({ type: 'connect', params: params })
const isLoggedIn = await auth.isLoggedIn()
console.log({ isLoggedIn })
})
provider.on('accountsChanged', (params) => {
//Handle
console.log({ type: 'accountsChanged', params: params })
})
provider.on('chainChanged', async (params) => {
console.log({ type: 'chainChanged', params: params })
})
}
```
## Supported Web3 Operations
- `eth_getBalance`
- `eth_accounts`
- `eth_signTransaction`
- `eth_sendTransaction`
- `wallet_addEthereumChain`
- `wallet_switchEthereumChain`
- `wallet_watchAsset`
- `_arcana_getAccountType`
- `_arcana_switchAccountType`
### Get Accounts
```
// get from eth_accounts
let from = ''
async function getAccounts() {
console.log('Requesting accounts')
try {
const accounts = await provider.request({ method: 'eth_accounts' })
console.log({ accounts })
from = accounts[0] // Use this account address to get wallet balance
} catch (e) {
console.log({ e })
}
}
```
### Get Balance
```
let balance = ''
async function getBalance() {
console.log('Requesting Balance')
try {
provider.request({ method: 'eth_getBalance' }).then((balance) => {
// convert a currency unit from wei to ether
const balanceInEth = ethers.utils.formatEther(balance)
console.log(`balance: ${balanceInEth} ETH`)
})
} catch (e) {
console.log({ e })
}
}
```
### Add Network
Only EVM Chains
Apps can programmatically add only the EVM-compatible chains to the preconfigured chain list if not already present.
The `wallet_addEthereumChain` method is specified by [EIP-3085](https://eips.ethereum.org/EIPS/eip-3085).
```
try {
await provider.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0xABCDEF',
chainName: 'My Custom Chain',
rpcUrls: ['...']
}]
})
} catch(error) {
...
}
// Parameters
// wallet_addEthereumChain accepts a single object parameter,
// specified by the AddEthereumChainParameter TypeScript interface
interface AddEthereumChainParameter {
chainId: string; // A 0x-prefixed hexadecimal string
chainName: string;
nativeCurrency: {
name: string;
symbol: string; // 2-6 characters long
decimals: 18;
};
rpcUrls: string[];
blockExplorerUrls?: string[];
}
```
### Switch Network
This method is specified by [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326).
Chain Switching
Apps can programmatically switch to another chain as long as it is of the same chain type. If an app is configured to use EVM chains, you cannot switch to a non-EVM chain and vice-versa.
```
try {
await provider.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xf00' }],
});
} catch(error) {
...
}
interface SwitchEthereumChainParameter {
chainId: string; // A 0x-prefixed hexadecimal string
}
```
Network Switch Error
If the error code (error.code) is 4902, then the requested chain has not been added, and you have to request to add it via `wallet_addEthereumChain`.
### Get Account Type
```
const accountType = await auth.provider.request({
method: "_arcana_getAccountType",
});
console.log(accountType);
```
### Watch Assets
```
async function watchAsset() {
setRequest('eth_sendTransaction')
const hash = await provider.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: '0xB983E01458529665007fF7E0CDdeCDB74B967Eb6',
symbol: 'FOO',
decimals: 18,
image: 'https://foo.io/token-image.svg',
},
},
})
console.log({ hash })
}
```
### Sign Transaction
```
async function signTransaction() {
const { sig } = await auth. provider.request({
method: 'eth_signTransaction',
params: [
{
from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0",
gasPrice: "20000000000",
gas: "21000",
to: '0x3535353535353535353535353535353535353535',
value: "1000000000000000000",
data: "some data"
},
],
})
console.log({ sig })
}
```
### Send Transactions
```
const auth = new AuthProvider(
"xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
)
```
```
try {
await auth.init()
} catch (e) {
// Handle exception case
}
```
```
async function sendTransaction() {
setRequest('eth_sendTransaction')
const hash = await auth.provider.request({
method: 'eth_sendTransaction',
params: [{
from,
gasPrice: 0,
to: '0xE28F01Cf69f27Ee17e552bFDFB7ff301ca07e780',
value: '0x0de0b6b3a7640000',
},],
})
console.log({ hash })
}
```
Send Transaction
Approve/Reject Send Transaction
### Show Wallet
Apps that use `alwaysVisible=false` when initializing the `AuthProvider` can use `showWallet` to display it in the app's context when required.
```
import { AuthProvider } from '@arcana/auth'
try {
const auth = new AuthProvider(
"xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
{
position: 'left', // default: right
theme: 'light', // default: dark
alwaysVisible: false,
}
)
await auth.init()
await auth.showWallet()
} catch (e) {
// Handle exception case
}
```
Arcana Wallet
# MultiversX Wallet Ops
Use `AuthProvider`, the standard EIP-1193 Ethereum provider offered by the Arcana Auth SDK, for issuing Web3 wallet operations via the Arcana wallet.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-mvx/) the app and configure SDK usage [settings for social login](../../../setup/) providers, [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) as per the app type, [integrate the SDK](../../integrate/mvx/) and create `AuthProvider`.
## Supported Web3 Operations
- `mvx_signMessage`
- `mvx_signTransaction`
- `mvx_signTransactions`
- `getAccounts`
- `getPublicKey`
Other MultiversX wallet connect JSON RPC methods listed [here](https://docs.multiversx.com/integrators/walletconnect-json-rpc-methods/) are not supported at the moment.
### `getAccounts`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
// Get Accounts
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// Returns an array of public keys
// ["pub-key-1"]
```
### `getPublicKey`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
//Get Public Key
await provider.request({
method: "getPublicKey",
params: [from],
});
// Returns public key
// {pk: "some-pub-key"}
```
### `SignMessage`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
// Get Accounts
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// Onboard users via plug-n-play login or custom login UI
// auth.connect() or auth.loginWithSocial
try {
const provider = await auth.connect()
console.log({ provider })
} catch (error) {
console.log({ error })
}
...
// For authenticated users, add code for signing message
const personalSign = await provider.request({
method: 'mvx_signMessage',
params: {
message: 'SignMessage to test MultiversX signmessage',
address: from,
},
})
// Returns signature object
// {signature: "some-sig"}
```
### `SignTransaction`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
// Get Accounts
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// Onboard users via plug-n-play login or custom login UI
// auth.connect() or auth.loginWithSocial
try {
const provider = await auth.connect()
console.log({ provider })
} catch (error) {
console.log({ error })
}
...
// For authenticated users, add code for signing transaction
const params = {
transaction: {
gasLimit: 100000,
sender: from,
receiver:
'erdXXXXXXXX-some-address-YYYYYYYYYY',
value: '0.01',
chainID: 'T',
data: 'helloWorld-from MultiversX',
version: 1,
},
}
const data = await provider.request({
method: 'mvx_signTransaction',
params,
})
// Returns signature object
// {signature: "some-sig", options: 0, version: 1}
```
### `SignTransactions`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
// Get Accounts
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// Onboard users via plug-n-play login or custom login UI
// auth.connect() or auth.loginWithSocial
try {
const provider = await auth.connect()
console.log({ provider })
} catch (error) {
console.log({ error })
}
...
// For authenticated users, add code for signing transaction
const transaction = {
gasLimit: 100000,
sender: from,
receiver: "erdXXXXXXXX-some-address-YYYYYYYYYY",
value: "0.001",
chainID: "T",
data: "helloWorld-from MultiversX",
version: 1,
};
const params = {
// You can use multiple transactions, this sample just
// repeats the same one.
transactions: [transaction, transaction, transaction],
};
const data = await provider.request({
method: 'mvx_signTransactions',
params,
})
//Returns Signature Object - see format below
//
// {
// signatures: [
// {signature: "some-sig-1", options: 0, version: 1},
// {signature: "some-sig-2", options: 0, version: 1},
// {signature: "some-sig-3", options: 0, version: 1}
// ]
// }
```
# Near Wallet Ops
The Arcana wallet supports [standard Ethereum JSON-RPC specification API](https://ethereum.org/en/developers/docs/apis/json-rpc/) via the `AuthProvider`.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-near/) the Near app and configure SDK usage [settings for social login](../../../setup/) providers, [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) as per the app type, [integrate the SDK](../../integrate/near/) and create `AuthProvider`.
## Supported Web3 Operations
- `getAccounts`
- `near_signMessage`
- `near_signAndSendTransaction`
### `getAccounts`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
//Initialize AuthProvider
await auth.init()
...
// User login add code via plug and play `connect` or custom login UI
// auth.connect() or auth.loginWithSocial
// Get User Account address post login
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
```
### `SignMessage`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
//Initialize AuthProvider
await auth.init()
// Onboard users via plug-n-play login or custom login UI
// auth.connect() or auth.loginWithSocial
try {
const provider = await auth.connect()
console.log({ provider })
} catch (error) {
console.log({ error })
}
// Get User Account address
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// For authenticated users, add code for signing message
import base58 from "bs58";
const message = base58.encode(Buffer.from("This is a test message for trying 'SignMessage'."));
const signedMessage = await auth.provider.request({
method: "near_signMessage",
params: { message },
});
console.log(signedMessage);
```
### `SignAndSendTransaction`
```
// Integrate App with the Auth SDK
const { AuthProvider } = window.arcana.auth
let provider
let from = ''
const auth = new AuthProvider('xar_dev_34-arcana-registered-client-id-xxxxx')
provider = auth.provider
...
//Initialize AuthProvider
await auth.init()
// Onboard users via plug-n-play login or custom login UI
// auth.connect() or auth.loginWithSocial
try {
const provider = await auth.connect()
console.log({ provider })
} catch (error) {
console.log({ error })
}
...
// Get Accounts
try {
const accounts = await provider.request({ method: 'getAccounts' })
from = accounts[0]
} catch (e) {
console.log({ e })
}
// Get Receiver Account address
// Read from app user interface
// receiver = Buffer.to('input address')
...
// For authenticated users, add code for signing transaction
const transaction = {
receiverId: receiver,
actions: [
{
transfer: {
deposit: BigInt(1000),
},
},
{
transfer: {
deposit: BigInt(1000),
},
},
{
transfer: {
deposit: BigInt(1000),
},
},
],
}
const signedTransaction = await auth.provider.request({
method: "near_signAndSendTransaction",
params: { transaction },
});
console.log(signedTransaction);
```
# Solana Wallet Ops
Solana chain is a bit different from typical EVM chains in how it [supports Solana JSON-RPC calls](https://docs.solana.com/api/http) and Web3 wallet operations.
## Prerequisites
- [Register](../../../setup/config-dApp-with-db-for-Solana/) the Solana app and configure SDK usage [settings for social login](../../../setup/) providers, [manage app chains](../../../setup/config-wallet-chains/) and [wallet user experience](../../../setup/config-wallet/).
- Install the [required SDK packages](../../sdk-installation/) as per the app type, [integrate the SDK](../../integrate/solana/) and create `AuthProvider`. Make sure you also initialize the `Solana Provider`.
```
import { AuthProvider } from '@arcana/auth'
```
```
const auth = new AuthProvider(
"xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
{
alwaysVisible: false, // default: true, wallet always visible
connectOptions: {
compact: true // default: false, regular plug-and-play login UI
},
position: 'left', // default: right
setWindowProvider: true, // default: false, window.ethereum not set
theme: 'light', // default: dark
})
```
```
try {
await auth.init()
} catch (e) {
// Handle exception case
}
```
Solana apps can use the `auth.provider` to make standard JSON RPC calls in the context of an authenticated user.
```
const provider = auth.provider;
```
Use the Solana provider for issuing Solana Web3 wallet operations in the context of an authenticated user.
```
const solanaP = auth.solana;
```
## Supported Web3 Wallet Operations
### Get Public Key
```
import SolanaWeb3 from "@solana/web3.js";
const provider = auth.provider;
const accounts = await auth.provider.request({
method: "getAccounts",
params: [],
});
const publicKey = new SolanaWeb3.PublicKey(accounts[0])
console.log(publicKey);
```
The `publicKey` is returned as a string: ["your-public-key-in-string-format"].
## Supported JSON/RPC Functions
- `signMessage`
- `signTransaction`
- `signAllTransactions`
- `signAndSendTransaction`
### `SignMessage`
```
const message = `Sign below to authenticate with CryptoCorgis to avoid digital dognappers`;
const encodedMessage = new TextEncoder().encode(message);
// To get a proper signature, the second parameter in signMessage call
// can be either "hex" or "utf8", depending on what kind of message we are signing.
// For plaintext, use "utf8";
// For hex message, use "hex"
try {
const signature = await solanaP.signMessage(encodedMessage, "hex");
window.solanaSig = signature;
console.log(signature);
} catch (e) {
console.error(e);
}
```
#### Signature Format
```
{
signature: Uint8Array // Encode it by using `bs58.encode(signature)`
// to get the string format. See npm library: bs58
publicKey: BN // Use `new SolanaWeb3.PublicKey(publicKey)`
// to get the 'BN' string format. See npm library: @solana/web3.js
}
```
### `SignTransaction`
```
try {
const pk = new SolanaWeb3.PublicKey(auth.solana.publicKey)
const connection = new SolanaWeb3.Connection(
SolanaWeb3.clusterApiUrl("testnet") // can be "devnet", "testnet" or "mainnet-beta"
);
const minRent = await connection.getMinimumBalanceForRentExemption(0);
const blockhash = await connection.getLatestBlockhash().then((res) => res.blockhash);
const payer = auth.solana
const instructions = [
SolanaWeb3.SystemProgram.transfer({
fromPubkey: pk,
toPubkey: pk,
lamports: minRent // lamports is the minimum unit of solana, like wei is for Ethereum. 1 SOL = 10^9 Lamports
})
];
// Compiles the message to V0 format
const messageV0 = new SolanaWeb3.TransactionMessage({
payerKey: pk,
recentBlockhash: blockhash,
instructions
}).compileToV0Message();
const transaction = new SolanaWeb3.VersionedTransaction(messageV0);
// sign your transaction with the required `Signers`
const signature = await payer.signTransaction(transaction);
} catch (e) {
console.error(e);
}
```
#### Signature Format
```
{
signatures: [Uint8Array],
message: {
header: {
numRequiredSignatures: 1,
numReadonlySignedAccounts: 0,
numReadonlyUnsignedAccounts: 1
},
staticAccountKeys: [
StaticAccountKey1, // In string format
StaticAccountKey2 // In string format
],
recentBlockhash: LatestBlockHashSubmittedWhileSigning, // In string format
compiledInstructions: [
{
programIdIndex: 1,
accountKeyIndexes: [
0,
0
],
data: Uint8Array // Data that was signed
],
addressTableLookups: [] // Not sure what is this, will need to check, but we can pass this during signing
}
}
```
### `SignAllTransactions`
```
try {
const pk = new SolanaWeb3.PublicKey(auth.solana.publicKey);
const connection = new SolanaWeb3.Connection(
window.solanaWeb3.clusterApiUrl("testnet")
);
const minRent = await connection.getMinimumBalanceForRentExemption(0);
const blockhash = await connection.getLatestBlockhash().then((res) => res.blockhash);
const payer = auth.solana;
const instructions = [
SolanaWeb3.SystemProgram.transfer({
fromPubkey: pk,
toPubkey: pk,
lamports: minRent,
}),
];
const messageV0 = new SolanaWeb3.TransactionMessage({
payerKey: pk,
recentBlockhash: blockhash,
instructions,
}).compileToV0Message();
const transaction = new SolanaWeb3.VersionedTransaction(messageV0);
// sign your transaction with the required `Signers`
const signatures = await payer.signAllTransactions([
transaction,
transaction,
transaction,
]); // Should/can send multiple different transactions,
// right now sending 1 transaction multiple times just as an example
} catch (e) {
console.error(e);
}
```
The signature format here is same as above with a minor difference:
```
[Signature0, Signature1, Signature2, and so on]
```
### `SignAndSendTransaction`
```
try {
const pk = new SolanaWeb3.PublicKey(auth.solana.publicKey);
const connection = new SolanaWeb3.Connection(
SolanaWeb3.clusterApiUrl("testnet")
);
const minRent = await connection.getMinimumBalanceForRentExemption(0);
const blockhash = await connection.getLatestBlockhash().then((res) => res.blockhash);
const payer = auth.solana; // Arcana Solana API
const instructions = [
SolanaWeb3.SystemProgram.transfer({
fromPubkey: pk,
toPubkey: pk,
lamports: minRent,
}),
];
const messageV0 = new SolanaWeb3.TransactionMessage({
payerKey: pk,
recentBlockhash: blockhash,
instructions,
}).compileToV0Message();
const transaction = new SolanaWeb3.VersionedTransaction(messageV0);
// sign your transaction with the required `Signers`
const txHash = await payer.signAndSendTransaction(transaction);
} catch (e) {
console.error(e);
}
```
#### Response Format
```
{
publicKey: BN,
signature: Uint8Array // This is the transaction hash itself
// we can verify this in solana explorer,
// need to convert it to string first using `bs58.encode(signature)`
}
```
# Unity Web3 Wallet Operations
Use `AuthProvider`, the standard EIP-1193 Ethereum provider offered by the Arcana Auth SDK, to call Web3 wallet operations in Unity apps.
## Supported Web3 Operations
Call `Request` to make Web3 Wallet operation requests from within the app context. Provide the 'method' parameter for any supported Web3 wallet operations.
Supported Wallet Operations
The supported methods in the `Request` function may vary depending on the selected blockchain network, EVM chains, or non-EVM chains, such as Solana or MultiversX. See the [supported JSON/RPC Web3 operations](../evm/) for a list of chain-specific methods supported via the `Request` call of the Arcana Auth Unity SDK.
```
responseTextField.text = "";
if (parameters.text != null)
{
response = (await arcanaSDK.Request(new RequestParams {
Method = method.text,
Params = JsonConvert.DeserializeObject