Dapp Wallet Integration

Two steps:

  1. Connect popup to obtain the user address

  2. Sign popup to review/PIN/broadcast and get txHash


1) Install

npm i @newblet/sign-sdk
# or: pnpm add @newblet/sign-sdk / yarn add @newblet/sign-sdk

2) Connect — get address

import { openNewbletConnectPopup } from '@newblet/sign-sdk'

async function onConnect(){
  const { address } = await openNewbletConnectPopup({
    walletUrl: 'https://newblet.com',  // `${walletUrl}/connect`
    state: `connect-${Date.now()}`
  })
  console.log(address)
}

Errors (Connect): USER_REJECTED, TIMEOUT, ENV_NOT_BROWSER


3) Sign — review/PIN/send

Errors (Sign): USER_REJECTED, TIMEOUT, SUBMIT_FAILED, MALFORMED_TX, ENV_NOT_BROWSER


4) User flow

Connect – Address approval

Connect popup

Sign – Review

Review

Sign – PIN

PIN

After broadcast, the wallet returns { txHash, state } and closes the popup.


5) Result handling

6) Checklist

  • Call popups inside click handlers

  • Cross‑origin dev only: devAllowAnyOrigin: true (never in production)

  • Use state as an idempotency key

Last updated