Skip to content

InfinityWallet/infinity-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Infinity Wallet Connector SDK for DApps & Web3 platforms

Infinity Wallet provides users with the ability to access DApps & Web3 platforms directly within the Infinity Wallet, through a feature we call “Browser-less DApps”. This feature provides users, DApps and chains with a wide range of benefits, while enhancing the overall user experience and allowing for more fluid and uninterrupted use.



Free Promotion

If you integrate the Infinity Connector and make a tweet tagging @infinitywallet on Twitter regarding your support for Infinity Wallet connecting, we may retweet your tweet.

How to add Infinity Wallet connecting to a DApp?

To integrate Infinity Wallet connecting to your DApp please follow this Integration Guide.

You will need to add to your interface an option to connect with the Infinity Wallet, either with the Infinity Wallet logo or Infinity Wallet logo + text. As an example:

Connect Wallet UI Example

Media Assets

Integration Guide:

To integrate Infinity Wallet Connector for a DApp on a supported EVM Chain please use the following guide. If you already support the web3 standards within your DApp the integration of Infinity Wallet connecting should take no longer than 5 minutes.

Requirement:

To support Infinity Wallet connecting your DApp should be EIP1193 compatible. This is the same protocol that is used to interact with other EVM compatible wallets such as Metamask. Meaning if your DApp supports Metamask connecting you will be able to support Infinity Wallet connecting with a few lines of code.

Package Installation

To use the SDK you can install the package in your project by:

Using yarn

yarn add @infinitywallet/infinity-connector

Using npm

npm install @infinitywallet/infinity-connector

Usage

Detect Infinity Wallet

The first thing you are going to need to do is detect whether your DApp is being accessed via the Infinity Wallet and if the Infinity Wallet is installed. To do this please use:

window.ethereum && window.ethereum?.isInfinityWallet

If returns TRUE then the DApp is currently running within the Infinity Wallet, you can initialize the wallet connection with Initiate Connector followed by calling the web3 method Activate

If returns FALSE then it means the Infinity Wallet needs to be opened using Open Infinity Wallet function;

Initiate Connector

This function should be called when Detect Infinity Wallet returns TRUE.

import { InfinityWalletConnector } from '@infinitywallet/infinity-connector';

const infinitywalletConnector = new InfinityWalletConnector({
  supportedChainIds: [CHAIN_ID]
});

Activate Connection

This function should be called when Detect Infinity Wallet returns TRUE and after initiating InfinityWalletConnector as shown in Initiate Connector. Pass the initialized connector into the useWeb3ReactCore method (activate) to activate the wallet connection.

const { activate, active } = useWeb3ReactCore()

activate(infinitywalletConnector)

Open Infinity Wallet

This function should be called when Detect Infinity Wallet Wallet returns FALSE.

By calling this function and passing your DApp url (replace "YOUR_DAPP_URL") and Chain ID (replace "CHAIN_ID") it will open your DApp in the Infinity Wallet if the user has the Infinity Wallet installed. If the user does not have Infinity Wallet installed it will redirect them to download the Infinity Wallet.

import { openInfinityWallet } from '@infinitywallet/infinity-connector';

openInfinityWallet(YOUR_DAPP_URL, CHAIN_ID);

Example

The following is an example on how to use the SDK to detect, connect and open the Infinity Wallet to connect with a DApp.

Using this example make sure to replace the following:

  • CHAIN_ID replace with the ID of the chain you are using. As an example if your DApp is using Ethereum then the CHAIN_ID would be 1 or if using Binance Smart Chain it would set CHAIN_ID to 56;
  • YOUR_DAPP_URL replace this with the URL of your DApp;
import { InfinityWalletConnector, openInfinityWallet } from '@infinitywallet/infinity-connector';

const { activate, active } = useWeb3ReactCore();

const infinitywalletConnector = new InfinityWalletConnector({
  supportedChainIds: [CHAIN_ID]
});

if(window.ethereum && window.ethereum?.isInfinityWallet){
     activate(infinitywalletConnector);
     console.log('Infinity Wallet is connected and can be used with the DApp');
} else {
     openInfinityWallet(YOUR_DAPP_URL, CHAIN_ID);
     console.log('Open DApp on a specific chain in Infinity Wallet if installed, or if not installed it will redirect to download Infinity Wallet');
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published