Download

arrow_down

Build

arrow_down

More

arrow_down
activityactivityactivityactivity
  • themelight
  • languageIcon

  • menu
Skip to Content
En Docs
Reference
Dapp OmniConnect

OmniConnect

OmniConnect is a software development kit launched by Bitget Wallet aimed at developers, enabling seamless integration of Mini-Apps within the Telegram ecosystem to a multi-chain environment. After integrating this kit, Telegram Mini Apps can directly interact with Bitget Wallet for signing, transactions, and other DApp operations across multiple chains.

  • OmniConnect: An open protocol that links wallets and DApps (Web3 applications) via a bridge server, establishing remote connections between TG MiniApp and/or Bitget Wallet Lite.
  • Chains officially supported by OmniConnect:
    • EVM (Ethereum Virtual Machine-compatible blockchains, such as Fantom, Base, Arbitrum, etc.)
  • Wallets supported by OmniConnect:
    • Bitget Wallet Lite
  • Quick experience with the online demo:
  • NPM Package:

Installation and Initialization

To integrate Omni Connect into your DApp, you can use pnpm:

        
pnpm add @bitget-wallet/omni-connect

Before connecting the wallet, you need to instantiate an object for subsequent operations such as connecting the wallet and sending transactions.

        
const connector = new OmniConnect({ metadata, namespace })

Request Parameters

  • metaData - object: Application metadata
    • name - string: Application name
    • iconUrl - string: Application icon url
    • url - string: The main website of the application
    • privacyPolicyUrl - string(optional):
    • termsOfUseUrl - string(optional):
  • namespace - object: Necessary namespace information for requesting a connection. The value must be within the supported range, otherwise the connection will fail.
    • eip155 - object: EVM value is “eip155”
      • chains: - Array: Chain ID information

Example

        
import { OmniConnect, PreventType } from "@bitget-wallet/omni-connect"; const connector = new OmniConnect({ metadata: { name: "<Your DAppName>", iconUrl: "<Your iconUrl>", url: "<Your website url>", privacyPolicyUrl: "", // optional termsOfUseUrl: "", // optional }, namespace: { eip155: { chains: ["1", "56"], }, }, });

Connect to Wallet

Connect to the wallet to get the wallet address, which serves as an identifier and is necessary for signing transactions; connector.connect(options)

Request Parameters

  • options - object(optional)
    • ret - string: PreventType.CLOSE You can specify not to close the wallet after connecting to it (the default behavior is to close it)

Restore Connection

If the user has previously connected their wallet, use this method to restore the connection state. (The SDK has restored the connection by default)

Example

        
connector.restoreConnection();

Sign message

Method for sign messages to wallets, supporting signatures;

connector.signMessage({ method, params: [address, message] })

Request Parameters

  • method - string: Request method name value eth_sign | personal_sign | eth_signTypedData | eth_signTypedData_v4
  • params - Array:
    • [0] - address - string: Wallet Address
    • [1] - message - string | object: Message to sign
  • settings - object(optional): Open the TG wallet configuration
    • preventPopup - string: PreventType.OPEN(Prevent new windows from opening)

Example

        
const address = "0x.."; try { await connector.signMessage({ method: "eth_sign", params: [address, "Hello World!"], }); } catch (error) { console.log(error); }

Send transaction

Methods for sending messages to wallets to support transactions;

connector.sendTransaction({ method: "eth_sendTransaction", params: [txData], })

Request Parameters

  • method - string: Request method name value eth_sendTransaction
  • params - Array:
    • [0] - txData - object:
      • chainId - hexstring: Chain id
      • from - string: Sender address.
      • to - string: Recipient address, or null if this is a contract creation transaction.
      • value - hexstring: Value to be transferred, in wei.
      • nonce - hexstring(optional): Anti-replay parameter.
      • gasLimit - hexstring: gasLimit
      • maxPriorityFeePerGas - hexstring(optional): Maximum fee, in wei, the sender is willing to pay per gas above the base fee.
      • maxFeePerGas - hexstring(optional): Maximum total fee (base fee + priority fee), in wei, the sender is willing to pay per gas.
  • settings - object(optional): Open the TG wallet configuration
    • preventPopup - string: PreventType.OPEN(Prevent new windows from opening)

Example

        
const address = "0x.."; try { await connector.signTransaction({ method: "eth_signTransaction", params: [ { chainId: "0x38", data: "0x", from: address, to: "0x..", value: "0x0", gasLimit: "0x5208", maxPriorityFeePerGas: "0x3b9aca00", //wei maxFeePerGas: "0x2540be400", //wei }, ], }); } catch (error) { console.log(error); }

Monitor wallet state changes

The wallet statuses are: connection status, sign result, etc. You can use this method to get the status.

onStatusChange( callback: (walletInfo) => void, errorsHandler?: (err) => void ): () => void;

Request Parameters

  • callback - (walletInfo) => void
    • id - number | string: Request id
    • namespaceKey - string: ‘eip155’
    • event - string: Event type
    • connected - boolean: Connection Status
    • result - object
      • address - string: Wallet connection address
      • signature - string: Sign result
  • errorsHandler - (err) => void
    • code - number: Error code
    • message - string: Error message

Example

        
const subscription = connector.onStatusChange( (walletInfo) => { console.log("onStatusChange", walletInfo); const { id, namespaceKey, event, connected, result } = walletInfo; switch (event) { case "connect": case "disconnect": // connected or disconnect logic.. break; case "signMessage": break; case "signTransaction": case "sendTransaction": // handle result?.signature, result?.reciept break; default: break; } }, (err) => { const { code, message } = err; console.error(`error stream: code: ${code}, message: ${message}`); } );

Call unsubscribe to save resources when you no longer need to listen for updates.

        
subscription?.unsubscribe();

Disconnect

Disconnect the connected wallet

connector.disconnect()

Error codes

Exceptions that may be thrown during connection:

UNKNOWN_ERROR Unknown Exception
BAD_REQUEST_ERROR Request error
UNKNOWN_APP_ERROR Unknown app exception
USER_REJECTS_ERROR User Rejected
METHOD_NOT_SUPPORTED Method not supported

        
export enum SIGN_DATA_ERROR_CODES { UNKNOWN_ERROR = 0, BAD_REQUEST_ERROR = 1, UNKNOWN_APP_ERROR = 100, USER_REJECTS_ERROR = 300, METHOD_NOT_SUPPORTED = 400 } export enum SEND_TRANSACTION_ERROR_CODES { UNKNOWN_ERROR = 0, BAD_REQUEST_ERROR = 1, UNKNOWN_APP_ERROR = 100, USER_REJECTS_ERROR = 300, METHOD_NOT_SUPPORTED = 400 }

Complete development example

OmniConnect DappDemo

Supported ChainIds

See Supported Mainnet

Last updated on