Pay3 Javascript SDK

Functions

8min

pay3.connect()

Opens login modal of Pay3 web wallet. User will be able to connect to the wallet using Social, Email & Phone OTP or Wallet connect.

On completion of connecting pay3-sdk-login-status event is published to the DApp.

index.js


pay3.isConnected()

Return true if the user has successfully connected with Pay3 Wallet, else returns false.

index.js


pay3.getAccount()

Returns wallet address of the connected wallet.

index.js


pay3.getBalance({rpcURL [, tokenAddress]})

Returns logged in user's balance in the connected chain. It accepts an optional ERC20 Address in which case it returns user token address balance on the chain. The amount is returned is in WEI.

Parameters

  1. rpcUrl: You can pass your favourite rpcUrl that matches your dApp's chain. This URL is used for reading data from block chain from the JS sdk with in the dApp's / client application context.
  2. tokenAddress (Type string, Optional): Address of any ERC20 token available on the connected chain. If tokenAddress is undefined the function returns coin balance of the connected user.
    

Get chain native coin balance

index.js


Get ERC20 token balance

index.js


pay3.readContract({contractAddress, abi, functionName [, args]}, rpcURL)

Pay3 readContract is a helpful utility which accepts parameters for read functionality for any contract interaction deployed on blockchain. This uses the rpcUrl passed in the constructor to interact with blockchain.

Parameters

  1. Contract Details
    1. contractAddress (string): Contract address deployed on the connected chain.
    2. abi (Array of Objects): ABI of the function that is being called.
    3. functionName (string): Name of the function that need to be invoked.
    4. args (Array of Objects: Optional): List of arguments to be passed while invoking the function.
  2. rpcUrl (string): You can pass your favourite rpcUrl that matches your dApp's chain.
index.js


pay3.disconnect()

Opens Pay3 Web Wallet and triggers logout for the user. Emits pay3-sdk-login-status event.

On completion of disconnect pay3-sdk-login-status ,event is published to the DApp.

index.js




Updated 25 Mar 2024
Doc contributor
Did this page help you?