Plurality Network
  • Overview
  • What is Plurality Network?
    • Layer 3 - The Open Context Layer
    • Smart Profiles
  • The Core Protocol
    • Core Mechanics of a Smart Profile
    • Structure of a Smart Profile
    • Chain Abstraction
    • Zero Knowledge Proofs
    • Personal AI
  • Concepts
    • Web2 Data and Login
      • Digital Footprint
        • Reputation and Interests
      • Login Mechanism
    • Web3 UX Challenges
      • Wallet Abstraction
      • Chain Abstraction
      • Fragmentation
      • Cold Start Problem
      • Network Effects
    • Web3 Data and Login
      • Data
      • Login
    • Data Ownership
  • Use Cases
    • Easy Login
    • Universal Reputation
    • Social Communities
    • Personalization
    • Profile Gating
    • DAO Governance
    • Sybil Resistance
    • Airdrop Whitelisting
    • Interoperability
    • Proof of Social Reputation
    • Cross Platform Experiences
    • Engagement and Loyalty
  • Developer Guides
    • Wallet Integration
    • Wallet SDK
    • Smart Profiles SDK
    • Server Side Sessions
  • Tokenomics
  • Products
    • Smart Profiles Wallet
  • Resources and Support
    • Workshops and Sessions
    • Explorers
    • Demos
  • Ecosystem
    • Apps Marketplace
    • Participate
      • Hack'n Heights Hackathon (May '24)
  • Contact Us
Powered by GitBook
On this page
  • AuthMethod
  • ProfileSession
  • Wallet SDK
  • Get All Connected Accounts
  • Get Current Connected Account
  • Get Signature
  • Verify Message Signature
  • Get Balance
  • Send Transaction
  • Get Block Number
  • Get Transaction Count
  • Read from contract
  • Write to contract

Was this helpful?

  1. Developer Guides

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.

import { PluralitySocialConnect } from '@plurality-network/smart-profile-wallet';
import { 
            AllAccountsDataType, 
            ConnectedAccountDataType, 
            SignMessageDataType, 
            VerifySignedMessageDataType,
            GetBalanceDataType, 
            GetBlockNumberDataType, 
            GetTransactionCountDataType, 
            ReadFromContractDataType, 
            SendTransactionDataType, 
            WriteToContractDataType 
        } from '@plurality-network/smart-profile-wallet';

You can add/remove the types based on the functions you actually use on the page.

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…].

const response = (await PluralitySocialConnect.getAllAccounts()) as AllAccountsDataType;

if (response) {
    const allAccounts = response.data;
    return allAccounts[0]?.address;
}

Get Current Connected Account

Get current account connected

const response = (await PluralitySocialConnect.getConnectedAccount()) as ConnectedAccountDataType;

if (response) {
    const connectedAccount = response.data;
    return connectedAccount?.address;
}

Get Signature

Gets the message signed using the connected account and returns the signature.

const response = (await PluralitySocialConnect.getMessageSignature(message)) as SignMessageDataType;
if (response) {
    const signMessage = response.data;
    return signMessage;
}

Verify Message Signature

Verify if the signature matches the message using the current connected account and returns boolean true or false.

const response = (await PluralitySocialConnect.verifyMessageSignature(message, key)) as VerifySignedMessageDataType;
if (response) {
    const verifyMessage = response.data;
    return verifyMessage;
}

Get Balance

Returns balance of the current account in wei. You need to convert it to the required denomination yourself.

const response = (await PluralitySocialConnect.getBalance(rpc, chainId)) as GetBalanceDataType;
if (response) {
    const getBalance = response.data;
    return getBalance;
}

Send Transaction

Send a certain amount (in ethers) to a certain address. Returns the transaction object.

const response = (await PluralitySocialConnect.sendTransaction(rawTx, rpc, chainId)) as SendTransactionDataType;
if (response) {
    const sendTransactionData = response.data;
    return sendTransactionData;
}

Get Block Number

Returns the latest block number.

const response = (await PluralitySocialConnect.getBlockNumber(rpc, chainId)) as GetBlockNumberDataType;
if (response) {
    const blockNumber = response.data;
    return blockNumber;
}

Get Transaction Count

Returns the transaction count of the given address

const response = (await PluralitySocialConnect.getTransactionCount(address, rpc, chainId)) as GetTransactionCountDataType;
if (response) {
    const transactionCount = response.data;
    return transactionCount;
}

Read from contract

Returns the response of executing the given get method of the contract with the given parameters

const response = (await PluralitySocialConnect.readFromContract(address, abiVal, action, params, rpc, chainId)) as ReadFromContractDataType;
if (response) {
    const readContract = response.data;
    return readContract;
}

Write to contract

Returns the transaction response of executing the given write method of the contract with the given parameters

const response = (await PluralitySocialConnect.writeToContract(address, abiVal, action, params, rpc, chainId, options)) as WriteToContractDataType;
if (response) {
    const writeContract = response.data;
    return writeContract;
}
PreviousWallet IntegrationNextSmart Profiles SDK

Last updated 3 months ago

Was this helpful?

to have a basic application with embedded widget and all the wallet functions already in there.

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 . We currently support only EVM-compatible chains.

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 . We currently only support EVM-compatible chains.

Didn't find what you were looking for? Contact us on discord .

Clone our boilerplate
link
link
here