Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
web3-eth-accounts
Advanced tools
Web3 module to generate Ethereum accounts and sign data and transactions.
The web3-eth-accounts package is a part of the Web3.js library that provides functionalities for managing Ethereum accounts. It allows you to create, sign, and recover accounts, as well as sign data and transactions.
Create Account
This feature allows you to create a new Ethereum account. The account object contains the address, private key, and other relevant information.
const Web3 = require('web3');
const web3 = new Web3();
const account = web3.eth.accounts.create();
console.log(account);
Sign Transaction
This feature allows you to sign a transaction using an account's private key. The signed transaction can then be sent to the Ethereum network.
const Web3 = require('web3');
const web3 = new Web3();
const account = web3.eth.accounts.privateKeyToAccount('YOUR_PRIVATE_KEY');
const tx = {
to: '0xRecipientAddress',
value: '1000000000',
gas: 2000000
};
account.signTransaction(tx).then(signed => {
console.log(signed);
});
Recover Account
This feature allows you to recover an account address from a signed message. It is useful for verifying the authenticity of a message.
const Web3 = require('web3');
const web3 = new Web3();
const message = 'Hello, world!';
const signature = '0xSignature';
const account = web3.eth.accounts.recover(message, signature);
console.log(account);
Sign Data
This feature allows you to sign arbitrary data using an account's private key. The signed data can be used for various purposes, such as authentication.
const Web3 = require('web3');
const web3 = new Web3();
const account = web3.eth.accounts.privateKeyToAccount('YOUR_PRIVATE_KEY');
const data = 'Hello, world!';
const signature = account.sign(data);
console.log(signature);
The ethers.js library is a complete and compact library for interacting with the Ethereum blockchain. It provides similar functionalities for managing accounts, signing transactions, and interacting with smart contracts. Compared to web3-eth-accounts, ethers.js is known for its simplicity and ease of use.
The eth-lightwallet package is a lightweight JavaScript library for managing Ethereum accounts and signing transactions. It is designed to be used in browser environments and provides functionalities for creating and managing HD wallets. Compared to web3-eth-accounts, eth-lightwallet focuses more on hierarchical deterministic (HD) wallets.
The ethereumjs-wallet library is a simple library for creating and managing Ethereum wallets. It provides functionalities for generating wallets, importing/exporting wallets, and signing transactions. Compared to web3-eth-accounts, ethereumjs-wallet is more focused on wallet management and less on interacting with the Ethereum network.
This is a sub package of web3.js
This is the accounts package to be used in the web3-eth
package.
Please read the documentation for more.
npm install web3-eth-accounts
Build running the following in the web3.js repository:
npm run-script build-all
Then include dist/web3-eth-accounts.js
in your html file.
This will expose the Web3EthAccounts
object on the window object.
// in node.js
var Web3EthAccounts = require('web3-eth-accounts');
var account = new Web3EthAccounts('ws://localhost:8546');
account.create();
> {
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
signTransaction: function(tx){...},
sign: function(data){...},
encrypt: function(password){...}
}
All the typescript typings are placed in the types folder.
[1.2.5]
eth_requestAccounts
as requestAccounts
added to web3-eth package (#3219)sha3Raw
and soliditySha3Raw
added to web3-utils package (#3226)eth_getProof
as getProof
added to web3-eth package (#3220)BN
and BigNumber
objects are now supported by the abi.encodeParameter(s)
method (#3238)getPendingTransactions
added to web3-eth package (#3239)handleRevert
module property (#3248)receipt
does now exist as property on the error object for transaction related errors (#3259)internalType
added to AbiInput
TS interface in web3-utils
(#3279)HttpProvider
options (#2980)eth-lib
dependency updated (0.2.7 => ^0.2.8) (#3242)defaultBlock
property handling fixed (#3247)clearSubscriptions
does no longer throw an error if no running subscriptions do exist (#3246)Accounts.signTransaction
fixed (#3280)FAQs
Package for managing Ethereum accounts and signing
The npm package web3-eth-accounts receives a total of 322,421 weekly downloads. As such, web3-eth-accounts popularity was classified as popular.
We found that web3-eth-accounts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.