Although, we strongly recommend using formal API to interact your applicactions with OneKey Wallet, we still provide some legacy API that is very similar to Near Web Wallet, make it easier for you migrating existing codes from Near Web Wallet.
import*as nearAPI from"near-api-js";constconfig= { networkId:'mainnet', nodeUrl:'https://rpc.mainnet.near.org',// networkId: 'testnet',// nodeUrl: 'https://rpc.testnet.near.org', headers: {}, keyStore:newnearAPI.keyStores.BrowserLocalStorageKeyStore(),}constnear=newnearAPI.Near(config);constconnection=near.connection;constprovider=newOneKeyNearProvider({ 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?,});provider.getAccountId();provider.isSignedIn();provider.signOut();provider.requestSignTransactions({ transactions: [], callbackUrl, meta?,});provider.account().signAndSendTransaction({ receiverId, actions: [], walletCallbackUrl, walletMeta?,});
Legacy API is not well tested and full case coveraged. Try to use formal API as possible as you can.