npm

@cometh/connect-hosted-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-dev.1 • Public • Published

Connect Hosted SDK

Installing Wallet SDK

npm install @cometh/hosted-connect-sdk

Initialize Wallet SDK

import { HostedConnect } from '@cometh/hosted-connect-sdk'

const connect = new HostedConnect(apiKey)

Authentication

This method is used to authenticate the user and get the OAuth token through an OAUTH flow with ComethOIDC. An IFrame will be generated to handle the authentication process.

const oauthToken = await connect.auth.authenticate()

Smart Wallet

Initialize

It is required to call this function before any others.

This function initialize the communication with the Cometh Connect wallet and verify that the wallet exist. In order to create a wallet, the user must register on Cometh OIDC.

await connect.wallet.connect()

Get Address

connect.wallet.getAddress()

This function returns the address of the wallet.

Send Transaction

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

This function relays the transaction data to the target address. The transaction fees can be sponsored. The function returns the safeTxHash of the transaction which can be used to wait for the Transaction receipt.

Get Transaction receipt

const txPending = await provider.getTransaction(tx.safeTxHash); 
const txReceipt = await txPending.wait();

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

Sign Message

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @cometh/connect-hosted-sdk

Weekly Downloads

2

Version

0.1.0-dev.1

License

none

Unpacked Size

44.6 kB

Total Files

47

Last publish

Collaborators

  • jb-cometh
  • shoto290
  • kevin-cometh
  • yoanslvy
  • fred-alembic