React Metamask Checker
Live demo
Description
React component which uses Render Props approach for checking Web3 instance object injected by Metamask extension.
Note: since v2.0.0 only new version of Metamask API is supported. Related links:
- https://medium.com/metamask/breaking-changes-to-the-metamask-inpage-provider-b4dde069dd0a,
- https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#new-api
Installation
yarn add react-metamask-checker
Testing
yarn test:jest # Runs Jest with coverage collection yarn test:coverage # Sends coverage to .coveralls.io yarn test # yarn test:jest && yarn test:coverage
Usage
// ./containers/App.js async { console } { const props = /* Ethereum network_id (numeric) which should be selected in Metamask */ // network : null, /* Ethereum account (address) which should be selected in Metamask */ // account : null, /* Function which executes on checking error */ // onCheckError : async (error) => null, /* Function which executes on checking success */ onCheckSuccess : async await this <Loader /> <Err message=errormessage || 'Unexpected error' /> <Content /> return <MetamaskChecker ...props /> }