Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
eth-provider
Advanced tools
Seamlessly connect to HTTP, WebSocket, IPC and Injected RPC transports in Node and the Browser!
npm install eth-provider --save
const provider = require('eth-provider')
const web3 = new Web3(provider())
const provider = require('eth-provider')
const web3 = new Web3(provider('wss://sepolia.infura.io/ws/v3/${INFURA_ID}))
['injected', 'wss://sepolia.infura.io/ws/v3/${INFURA_ID}']
will first try to discover injected providers and if unsuccessful connect to the Infura endpointconst provider = require('eth-provider')
const web3 = new Web3(provider(['injected', 'wss://sepolia.infura.io/ws/v3/${INFURA_ID}']))
'direct'
preset, or by passing custom IPC pathsconst provider = require('eth-provider')
const web3 = new Web3(provider('direct'))
injected
- Discover providers injected by environment, usually by the browser or a browser extension
['injected']
frame
- Connect to Frame running on the user's device
['ws://127.0.0.1:1248', 'http://127.0.0.1:1248']
direct
- Connect to local Ethereum nodes running on the user's device
['ws://127.0.0.1:8546', 'http://127.0.0.1:8545']
[/* Default IPC paths for platform */, 'ws://127.0.0.1:8546', 'http://127.0.0.1:8545']
infura
- Connect to Mainnet Infura
['wss://mainnet.infura.io/ws/v3/${infuraId}', 'https://mainnet.infura.io/v3/${infuraId}']
alchemy
- Connect to Mainnet Alchemy
['wss://eth-mainnet.ws.alchemyapi.io/v2/${alchemyId}', 'https://eth-mainnet.alchemyapi.io/v2/${alchemyId}']
View all possible presets here
If you do not pass any targets, eth-provider will use default targets ['injected', 'frame']
in the Browser and ['frame', 'direct']
in Node and Electron.
When creating the provider you can also pass an options object
infuraId
- Your projects Infura IDalchemyId
- Your projects Alchemy IDorigin
- Used when connecting from outside of a browser env to declare the identity of your connection to interfaces like Frame (this currently doesn't work with HTTP connections)provider('infura', { infuraId: '123abc' })
or provider({ origin: 'DappName', infuraId: '123abc' })
The origin setting will only be applied when a dapp is connecting to from outside of a browser env.
FAQs
A Universal Ethereum Provider
The npm package eth-provider receives a total of 10,633 weekly downloads. As such, eth-provider popularity was classified as popular.
We found that eth-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.