Transactions
This function opens Pay3 buy crypto modal. The Buy modal will guide the user through the digital asset purchase flow. This function accepts optional second parameter provider for the client that is configured in Payment only mode.
Once the purchase is completed sdk will publish pay3-sdk-transaction-status event.
Parameters
- transactionObj
- requestId (Type string): Dapp needs to provide a unique string for every new buy request triggered by the user. This will be passed back to the dApp along with completed event data.
- nftData (Type Object, Optional): This is an optional parameter. Can be used to improve presentation of NFT buy flow. Keys expected in this object are:
- The address is the NFT collection address. Used for fetching Image of NFT.
- The nftId is the unique ID of the NFT within the collection. Used for fetching Image of NFT.
- The nftName is the name of the NFT. This will be used in the buy flow to keep user context.
- The nftType param helps in classifying NFT based on the ERC type. It can take number values 721 or 1155
- destination (Type Object, Optional): Destination object can be optionally passed to Pay3 payment module if the dApp needs the deposit of the purchased currency in address other than user address. Keys expected in this object are:
- The address is the destination wallet address used in the purchase. For transaction safety, we need to whitelist possible destination addresses during onboarding.
- The currency is Pay3's unique string ID denoting the token that needs to be purchased. Example value are matic_mumbai, weth_polygon.
- The amount in Etherium user needs to purchase. If the value is passed user edit this within Pay3 buy flow.
- provider(Type Web3 Provider, Optional): In Payments Only mode, dApp can provide a Web3 provider from the user's connected wallet. Refer sample code to get provider for example code. In this mode Pay3 Web SDK will provide transaction related features. The digital assets will be managed within the wallet connected to the dApp. The provider object needs at least following functions
- getSigner()
- getNetwork()
- listAccounts()
Game token Buy flow with integrated Pay3 Wallet
Token buy flow where destination address is Game's wallet address
Payments Only mode - NFT buy flow where Game transfer's NFT to its user on receiving the amount passed in destination object.
The Dapp can use openOnRamp to use Pay3's On Ramp only solution. The Pay3 modal will guide user through On Ramp flow with its destination address defined by the Dapp.
Opens sell game token screen. It requires a unique requestId as parameter.
Show current and previous transactions of the connected user.
Opens portfolio screen for the connected user. This displays all the assets owned by the user's wallet and their balances. This will show both fungible and non-fungible assets. There will be options to customise the portfolio page as per the game.
This triggers opening of Pay3 transaction model once user is connected to Pay3 Wallet. dApp can call trigger any transaction with connected Pay3 Wallet. This provides a single interface to interact with Web2 and Web3 wallets.
On completion of the transaction, pay3-sdk-sendtxn-status event is published to the dApp.
Parameters:
- requestId (Type string): dApp needs to provide a unique string for every new transaction request triggered by the user. This will be passed back to the Dapp along with completed event data
- to (Type string): Contract address of which the function needs to be executed
- value(Type string): Coin amount to be spent in gwei while invoking the function
- functionName (Type string): Contract function name that needs to be called
- args (Type Array of Objects): Arguments to be passed while calling the function
- userMessage (Type string): Information text message for user shown while confirming the transaction in the Pay3 wallet.
Sample code to get Web3 provider from browser injected wallet like Metamask
Sample code to get Web3 provider from Wagmi