Skip to Content
dApps

Migrate from Near Web Wallet

Use the provider methods in this integration guide for new applications. The compatibility methods below can help migrate an existing NEAR Web Wallet integration. They use the legacy near-api-js API described in Install the Provider SDK.

import * as nearAPI from "near-api-js"; import { OneKeyNearProvider } from "@onekeyfe/onekey-near-provider"; const config = { networkId: 'mainnet', nodeUrl: 'https://rpc.mainnet.near.org', // networkId: 'testnet', // nodeUrl: 'https://rpc.testnet.near.org', headers: {}, keyStore: new nearAPI.keyStores.BrowserLocalStorageKeyStore(), } const near = new nearAPI.Near(config); const connection = near.connection; const provider = new OneKeyNearProvider({ connection, networkId: 'mainnet', // `mainnet` or `testnet` // reloading page after signIn or signTransaction that likes web wallet callback url working enablePageReload: true, }); provider.requestSignIn({ successUrl, failureUrl, // contractId: optionalContractId, }); provider.getAccountId(); provider.isSignedIn(); provider.signOut(); provider.requestSignTransactions({ transactions: [], callbackUrl, // meta: optionalMetadata, }); provider.account().signAndSendTransaction({ receiverId, actions: [], walletCallbackUrl, // walletMeta: optionalMetadata, });

Legacy compatibility methods have limited test coverage. Prefer the provider methods documented in the integration guide, and verify your existing callback and redirect behavior when migrating.

Last updated on