Git Product home page Git Product logo

infinity-connector's Introduction

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');
}

infinity-connector's People

Contributors

arons1 avatar infinitywallet avatar jackromo888 avatar harusurv avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.