Wallet SDK
This guide shows how to use standard web3 wallet functions
Every wallet needs to interact with the blockchain for carrying out various functions. Once the widget is embedded and the user connects their profile through their preferred auth method, a session is created for this user after which the standard wallet functions can be utilized.
AuthMethod
To create a wallet, user first needs to choose how do they want to create the wallet i.e. select their AuthMethod. Currently we support 3 auth methods (with support for more auth methods coming soon) i.e. gmail, email and metamask.
Once the user selects a certain auth method, a wallet is created in the network that makes sure that this wallet is accessible only with a valid login jwt of the selected auth method.
If the user uses an email for creation of a wallet and then later on selects gmail for that same email address, we do not create two separate wallets rather tag both authmethods to the same user. Currently no other embedded wallet products offer this feature, resulting in users regularly forgetting what they used to sign up to an application. We reduce this cognitive load for end users.
ProfileSession
After successful login of profile, a session is created that allows user to access the SDK functions. The session expires after a certain time or when the user logs out. Without valid session signatures, the MPC network will not allow for signature signing.
As soon as the login process is complete, the connect profile button will automatically change to a circular profile icon with the user's avatar in it and a dropdown with basic profile functions.
Wallet SDK
To access the wallet functions, the following import should be done on the page/component where the functions need to be called.
You can add/remove the types based on the functions you actually use on the page.
Clone our boilerplate to have a basic application with embedded widget and all the wallet functions already in there.
Once the application has access to a valid session i.e. the user has successfully logged in, the following wallet functions become accessible.
Get All Connected Accounts
Returns all connected accounts/addresses e.g. [0x123…, 0x456…].
Get Current Connected Account
Get current account connected
Get Signature
Gets the message signed using the connected account and returns the signature.
Verify Message Signature
Verify if the signature matches the message using the current connected account and returns boolean true or false.
Get Balance
Returns balance of the current account in wei. You need to convert it to the required denomination yourself.
Please note that since Plurality profiles are chain agnostic, you need to provide the RPC and the chainId to ensure that balance is being read from the current read. You can find the RPC and the chainId of your preferred chain through this link. We currently support only EVM-compatible chains.
Send Transaction
Send a certain amount (in ethers) to a certain address. Returns the transaction object.
Please note that since Plurality profiles are chain agnostic, you need to provide the RPC and the chainId to ensure that balance is being read from the current read. You can find the RPC and the chainId of your preferred chain through this link. We currently only support EVM-compatible chains.
Get Block Number
Returns the latest block number.
Get Transaction Count
Returns the transaction count of the given address
Read from contract
Returns the response of executing the given get method of the contract with the given parameters
Write to contract
Returns the transaction response of executing the given write method of the contract with the given parameters
Didn't find what you were looking for? Contact us on discord here.
Last updated