@tajirwallet/provider
v22.1.2
Published
A JavaScript Ethereum provider that connects to the wallet over a stream
Readme
TajirWallet provider
Ethereum provider used by TajirWallet in web pages (window.ethereum). This package is based on the stream-connected inpage provider pattern; it keeps compatible metamask_* RPC and stream names so the extension and inpage script stay in sync.
The BaseProvider implements EIP-1193. StreamProvider adds stream-based JSON-RPC. The inpage implementation is TajirWalletInpageProvider (DevTools shows Proxy(TajirWalletInpageProvider)). The package still exports MetaMaskInpageProvider as a deprecated alias for the same class. The injected window.ethereum exposes isTajirWallet: true, _tajirwallet for the experimental API, and a _metamask getter that returns the same object for older snippets.
Usage
import { initializeProvider } from '@tajirwallet/provider';
const walletStream = new LocalMessageDuplexStream({
name: 'inpage',
target: 'contentscript',
});
initializeProvider({
connectionStream: walletStream,
});
const { ethereum } = window;Types
Types ship with the package. You may need Node types for EventEmitter and streams (e.g. @types/node).
Do not modify the provider
Do not mutate the provider object; unsupported mutations can break wallet behavior.
Contributing
Setup
- Node.js 18+ (see
package.jsonengines) - Yarn (this repo uses Yarn 3; see
packageManagerinpackage.json) - Install dependencies with
yarn install
Testing and linting
yarn testyarn lint
Release
Use your normal version bump, changelog, and npm publish flow for @tajirwallet/provider.
