
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Ethereum TypeScript Client Library - for perfect types and tiny builds.
web3.js is a very popular Ethereum library, but:
web3x solves the above issues and more.
EvmProvider
which provides a full inplace EVM implementation for executing contract code in your DAPP for simplified development workflows.web3x also adopts a lean, functional design, and resolves many out the outstanding issues in the web3.js repository.
There are two builds of the library. web3x
uses CommonJS style imports and is best used for Node.js backends. web3x-es
uses ES6 imports and is best used for ES6 aware tools like Webpack.
The inbuilt providers are all EIP-1193 compatible, and are used as follows:
import { Address } from 'web3x-es/address';
import { WebsocketProvider } from 'web3x-es/providers';
import { Eth } from 'web3x-es/eth';
import { fromWei } from 'web3x-es/utils';
async function main() {
const provider = new WebsocketProvider('wss://mainnet.infura.io/ws');
const eth = new Eth(provider);
const balance = await eth.getBalance(Address.ZERO);
document.body.innerText = `Balance of 0 address ETH: ${fromWei(balance, 'ether')}`;
}
main().catch(console.error);
Until MetaMask and other providers are EIP-1193 compatible, you can use them with an adapter as follows:
import { LegacyProvider, LegacyProviderAdapter } from 'web3x-es/providers';
import { Eth } from 'web3x-es/eth';
declare const web3: {
currentProvider: LegacyProvider;
};
const eth = new Eth(new LegacyProviderAdapter(web3.currentProvider));
Or a shorthand version:
import { Eth } from 'web3x-es/eth';
const eth = Eth.fromCurrentProvider();
See example projects for more complex usage examples.
Interacting with contracts without type safety is tedious at best, and dangerous at worst. web3x
provides a code generator called web3x-codegen
to generate typings for contract ABIs either local, or remote from a simple configuration file called contracts.json
.
Read more at web3x-codegen.
There is an implementation of the EVM which can be used for simplifying development workflows.
Read more at web3x-evm.
This is not a perfect drop in replacement for web3.js, there are differences.
getTxHash()
, getReceipt()
methods.Address.fromString('0x903ddd91207f737255ca93eb5885c0e087be0fc3')
0x
prefixed strings.wallet.get(0)
rather than wallet[0]
.Two example TypeScript projects are included, one for webpack and one for node.js. They are configured to work with jest for testing. Adapting them to pure JavaScript if you don't want to use TypeScript should be trivial.
API documentation has not yet been ported from web3.js. For now the recommended approach for familiarising yourself with the library would be the following, in preferential order:
[4.0.6] - 2019-11-25
abi.constant
to determing TxCall
or TxSend
.FAQs
Typescript port of web3.js
The npm package web3x receives a total of 2,934 weekly downloads. As such, web3x popularity was classified as popular.
We found that web3x demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.