@cometh/hosted-sdk-ethers
v0.1.0-dev.19
Published
SDK Cometh Hosted-Connect
Downloads
12
Keywords
Readme
Connect Hosted SDK
Installing Wallet SDK
npm install @cometh/connect-hosted-sdk
Initialize Wallet SDK
import { ComethAuth, ComethWallet, ComethProvider, ComethSigner } from '@cometh/connect-hosted-sdk'
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 auth = new ComethAuth(apiKey)
// Login to Cometh OIDC and get a session token
const oauthToken = await auth.login()
// Logout from Cometh OIDC
await auth.logout()
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.
const wallet = new ComethWallet(apiKey)
await wallet.connect()
Get Address
wallet.getAddress()
This function returns the address of the wallet.
Send Transaction
const txParams = { to: DESTINATION, value: VALUE, data: DATA }
const tx = await 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 txReceipt = await provider.waitTransaction(tx.safeTxHash);
This function relays the transaction data to the target address. The transaction fees can be sponsored.
Sign Message
const signature = await wallet.signMessage('hello')
Sign the given message using the EOA, owner of the smart wallet.