near_wallet_connect 0.4.0 copy "near_wallet_connect: ^0.4.0" to clipboard
near_wallet_connect: ^0.4.0 copied to clipboard

Drop-in NEAR wallet connection for Flutter — adaptive connect (web redirect, mobile deep links), persistent key storage, and a NearConnectButton widget.

near_wallet_connect #

License: MIT

One button. Every NEAR wallet. Drop-in wallet connection for Flutter — NearConnectButton opens a wallet picker (MyNearWallet, Intear, HOT), and one controller gives you the same API whatever the user picked. Built on near_dart.

NEAR Flutter demo on Android

Add it #

dependencies:
  near_wallet_connect: ^0.4.0

Use it (this is the whole integration) #

import 'package:near_wallet_connect/near_wallet_connect.dart';

final wallet = NearWalletController(
  network: MyNearWalletNetwork.testnet,
  contractId: AccountId('app.testnet'),
  callbackScheme: 'myapp', // your mobile deep-link scheme
);

@override
void initState() {
  super.initState();
  wallet.init(); // restores the session + processes redirect callbacks
}

// In your build() — tapping it opens the wallet picker:
NearConnectButton(controller: wallet);

Connected. Now one API, whatever the wallet:

// 1. Gas-only contract calls, signed locally (function-call key — no popups):
final signer = await wallet.signer();
await signer!.callFunction(
  contractId: AccountId('app.testnet'),
  methodName: 'add_message',
  args: {'text': 'hello'},
);

// 2. "Sign in with NEAR" (NEP-413) — e.g. against a better-near-auth API:
final signed = await wallet.signMessage(Nep413Payload(
  message: 'Sign in to app.com',
  recipient: 'app.com',
  nonce: generateNep413Nonce(),
));

// 3. Payments & deposits, approved in the user's wallet:
await wallet.sendTransactions([
  {
    'receiverId': 'app.testnet',
    'actions': [
      {
        'type': 'FunctionCall',
        'params': {
          'methodName': 'tip',
          'args': {'message': 'gm'},
          'gas': '30000000000000',
          'deposit': '1000000000000000000000000', // 1 NEAR
        },
      },
    ],
  },
]);

That's it. See example/ for a complete minimal app.

Customize the UI #

Use the default button for fast integration:

NearConnectButton(controller: wallet, compact: true);

Or keep the controller/picker logic and replace the visual states:

NearConnectButton(
  controller: wallet,
  connectBuilder: (context, controller, onPressed) {
    return OutlinedButton.icon(
      onPressed: onPressed,
      icon: const Icon(Icons.account_balance_wallet_outlined),
      label: const Text('Connect'),
    );
  },
  connectedBuilder: (context, controller, onDisconnect) {
    return NearAccountBadge(
      accountId: controller.account!.accountId,
      wallet: controller.walletOption,
      onDisconnect: onDisconnect,
      compact: true,
    );
  },
);

Reusable pieces:

  • NearWalletPicker
  • NearAccountBadge
  • NearBalanceText
  • NearTransactionStatusView

Supported wallets #

Wallet Networks Connect flow signer() signMessage sendTransactions
MyNearWallet testnet + mainnet browser redirect via redirect² via redirect²
Intear testnet + mainnet native app + WebSocket bridge¹
HOT mainnet native/Telegram app + relay¹

¹ Resolves in place — no inbound deep link needed. ² MyNearWallet signs per-transaction in the browser; use MyNearWalletAdapter.buildTransactionUrl / buildSignMessageUrl from near_dart for those flows.

MyNearWallet remains fully supported until its announced sunset (October 31, 2026). Intear and HOT are additional options, not replacements — pick per user, at runtime.

Platform setup (one-time) #

The MyNearWallet callback uses a custom URL scheme (default nearsdk://). Register it:

Androidandroid/app/src/main/AndroidManifest.xml, inside <activity>:

<intent-filter android:autoVerify="false">
  <action android:name="android.intent.action.VIEW"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <category android:name="android.intent.category.BROWSABLE"/>
  <data android:scheme="nearsdk"/>
</intent-filter>

iOSios/Runner/Info.plist:

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array><string>nearsdk</string></array>
  </dict>
</array>

Web — no setup; the callback returns to your app URL. Intear and HOT need no callback setup on any platform (responses arrive over their bridges).

How it works #

  • MyNearWallet: full-page redirect (web) or system browser + deep-link callback (mobile). Connecting provisions a function-call key, stored so gas-only calls sign locally afterwards.
  • Intear: a per-request WebSocket bridge session + intear:// deep link; the wallet's response arrives over the socket. Connecting can also add a function-call key, so signer() works here too.
  • HOT: requests are queued on HOT's relay and opened via hotwallet://; the app polls the relay for the response.
  • Keys persist via SecureKeyStore by default (Android Keystore / Apple Keychain / Windows DPAPI / Linux libsecret); on web — where no OS secret storage exists — a plain SharedPrefsKeyStore is used. Sessions from older versions migrate to secure storage automatically. Details: docs/security.md.

License #

MIT

0
likes
150
points
54
downloads

Documentation

API reference

Publisher

verified publisher0xj.dev

Weekly Downloads

Drop-in NEAR wallet connection for Flutter — adaptive connect (web redirect, mobile deep links), persistent key storage, and a NearConnectButton widget.

Homepage
Repository (GitHub)
View/report issues

Topics

#near #wallet #flutter #web3 #blockchain

License

MIT (license)

Dependencies

app_links, flutter, flutter_secure_storage, near_dart, shared_preferences, url_launcher

More

Packages that depend on near_wallet_connect