Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cometh/connect-sdk

Package Overview
Dependencies
Maintainers
4
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cometh/connect-sdk

SDK Cometh Connect

  • 1.0.0-rc.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
292
decreased by-6.11%
Maintainers
4
Weekly downloads
 
Created
Source

Account Abstraction SDK

Cometh Connect SDK allows developers to onboard their users with a seedless, gasless experience familiar to Web2 using Biometrics and web2 logins.

Account Abstraction (AA) improves transaction user experience by using smart contract wallets as primary accounts.

Instanciate Wallet

import {
  ComethWallet,
  ConnectAdaptor,
  SupportedNetworks
} from '@cometh/connect-sdk'

const walletAdaptor = new ConnectAdaptor({
  chainId: SupportedNetworks.POLYGON,
  jwtToken: TOKEN,
  apiKey: API_KEY,
  userName: USERNAME
})

const wallet = new ComethWallet({
  authAdapter: walletAdaptor,
  apiKey: API_KEY,
  rpcUrl: RPC_URL
})

To get an API key please Contact us

Available methods

Connect

await wallet.connect()

This function create your credentials and identify you to the connect API.

Logout

await wallet.logout()

This function logs the user out and clears the cache.

Get Address

await wallet.getAddress()

This function returns the address of the wallet.

Get user infos

await wallet.getUserInfos()

If the user is logged in with social media accounts, this function can be used to fetch user related data such as email, etc.

Send transaction

const tx = { to: DESTINATION, value: VALUE, data: DATA }
const relayId = await wallet.sendTransaction(tx)

This function relays the transaction data to the target address. The transaction fees can be sponsored.

Send Batch transactions

const txBatch = [
  { to: DESTINATION, value: VALUE, data: DATA },
  { to: DESTINATION, value: VALUE, data: DATA }
]
const relayId = await wallet.sendBatchTransactions(txBatch)

This function relays a batch of transaction data to the targeted addresses. The transaction fees can be sponsored as well.

Sign Message

const signature = await wallet.signMessage('hello')

Sign the given message using the EOA, owner of the smart wallet.

Create New Signer Request

await wallet.createNewSignerRequest()

This function create a new signer request that, when validated, enables to add a new device as signer of your smart wallet.

Validate New Signer Request

const newSignerRequest = {
  projectId: PROJECT_ID;
  userId: USER_IDENTIFIER;
  chainId: CHAIN_ID;
  walletAddress: WALLET_ADDRESS;
  signerAddress: SIGNER_ADDRESS;
  deviceData: DEVICE_DATA;
  type: NEW_SIGNER_REQUEST_TYPE;
}
 await wallet.validateNewSignerRequest(newSignerRequest)

This function validates a new signer request, enabling the targeted device to become a signer of your smart wallet.

Get New Signer Request By User

const newSignerRequests = await wallet.getNewSignerRequestByUser()

This function gets all new signer request for a given user.

Delete a New Signer Request

const signerAddress = SIGNER_ADDRESS

await wallet.deleteNewSignerRequest(signerAddress)

This function deletes a new signer request.

Go further

Interact with contract interface

import {
  ComethWallet,
  ConnectAdaptor,
  ComethProvider,
  SupportedNetworks
} from '@cometh/connect-sdk'

const walletAdaptor = new ConnectAdaptor({
  chainId: SupportedNetworks.POLYGON,
  jwtToken: TOKEN,
  apiKey: API_KEY,
  userName: USERNAME
})

const wallet = new ComethWallet({
  authAdapter: walletAdaptor,
  apiKey: API_KEY,
  rpcUrl: RPC_URL
})

const provider = new ComethProvider(wallet)

const nftContract = new ethers.Contract(
  NFT_CONTRACT_ADDRESS,
  nftContractAbi,
  provider.getSigner()
)

const tx = await nftContract.count()
const txResponse = await tx.wait()

You can also interact with the interface of a contract, calling directly the contract functions.

Web3Onboard connector

import {
  ConnectAdaptor,
  SupportedNetworks,
  ConnectOnboardConnector
} from '@cometh/connect-sdk'
import injectedModule from '@web3-onboard/injected-wallets'
import Onboard from '@web3-onboard/core'

const walletAdaptor = new ConnectAdaptor({
  chainId: SupportedNetworks.POLYGON,
  jwtToken: TOKEN,
  apiKey: API_KEY,
  userName: USERNAME
})

const connectOnboardConnector = ConnectOnboardConnector({
  apiKey: process.env.NEXT_PUBLIC_ALEMBIC_API_KEY,
  authAdapter: walletAdaptor,
  rpcUrl: RPC_URL
})

const web3OnboardInstance = Onboard({
  wallets: [injectedModule(), connectOnboardConnector],
  chains: [
    {
      id: ethers.utils.hexlify(DEFAULT_CHAIN_ID),
      token: 'MATIC',
      label: 'Matic Mainnet',
      rpcUrl: 'https://polygon-rpc.com'
    }
  ]
})

You can also incorporate cometh connect to web3Onboard wallet modal solution.

FAQs

Package last updated on 21 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc