Portal Connect allows you to connect your Portal MPC Wallet to any dApp that supports WalletConnect without extra dependency bloat.
Portal
instance to connect your Portal MPC Wallet to dApps via WalletConnect. When connecting via Portal Connect, a few things happen in the background:
uri
for Portal Connect to connect withuri
portal.provider
to perform the request like normal@portal-hq/connect
package in your project.
@portal-hq/core
. Portal Connect depends on an existing Portal
instance to operate properly.PortalConnect
. The PortalConnect
class takes one argument, the Portal
instance you’d like it to use under the hood.
connect(uri)
function on your PortalConnect
instance. This will initialize the WebSocket session with the WalletConnect relay and begin passing messages to your Portal Provider using your Portal MPC Wallet.
connect
and disconnect
events to get confirmation of connecting and disconnecting.
Session Requests
represent the initial connection request from the dApp to create a new session. These are triggered when Portal responds to the dApp after the connect(uri)
function is called. These events will be triggered with a SessionProposal
object. These objects can be used to display information about the dApp the user is connecting to and the specific permissions being requested by the dApp.
addChainsToProposal
. This can be used to add all the chains in your gateway config to the proposal object.
PortalConnect
instance.
autoApprove
is turned off.
portal_connectError
in order to handle specific errors and warnings from Portal Connect. Check out our Portal Connect Error Codes here.
setChainId
method.
chainId
in the gateway config with a gateway url on initialization of your Portal Object, otherwise, you can not switch chains.