Setup

JavaScript Setup Functions

Setup

Description

Initializes the Tweed frontend SDK

Parameters

NameTypeRequiredDefaultDescription

defaultBlockchainIds

String[]

✔️

Default blockchains

sendMessageToBackend

String => Promise<String>

✔️

Function that sends a message to the backend and returns an answers

walletConnect

{onConnect?: (connection: WalletConnectConnection) => void, onDisconnect?: (connection: WalletConnectConnection) => void}}

Wallet connect event listeners

Return type

TweedFrontendSDKApi

Usage Example

import { Blockchain, TweedFrontendSDK } from '@paytweed/frontend-sdk'

const frontendSDK = TweedFrontendSDK.setup({
  defaultBlockchainIds: ['ethereum', 'polygon'],
  sendMessageToBackend: async (message) => {
    const response = await fetch('http://localhost:3000/message', {
      body: JSON.stringify({ message }),
      headers: { 'Content-Type': 'application/json' },
      method: 'POST',
    })
    const { answer } = await response.json()
    return answer
  },
})

Last updated