eth-toolbox
v0.2.3
Published
Ethereum Toolbox
Downloads
21
Readme
eth-toolbox
Simple Ethereum toolbox
Table of Contents
- Get Started
- Usages
- Extra tools
- Install
- Example
- Dev
- Test
- Build doc
- Dependencies
- Dev Dependencies
- Bugs
- License
- Donation
Get Started
npm install --save eth-toolbox
Usages
Create Keystore
const ks = await ethToolbox.createKeystore(entropy, password)
Inputs
entropy
: Random numberpassword
: Password to decode keystore
Return value
Return serialize keystore
Decode Keystore
const ks = await ethToolbox.decodeKeystore(keystore, password);
Inputs
keystore
: Deserialize keystorepassword
: Password to decode keystore
Return value
ks = {
address,
privateKey,
}
Send Ether
const tsx = await ethToolbox.sendEther(address, amount, keystore, password);
Inputs
address
: Ethereum addressamount
: Amountkeystore
: Deserialize keystorepassword
: Password to decode keystore
Return value
tsx = {
from, // Eth address
to, // Eth address
value, // Amount
date, // Date of the transaction
dether: {
detherContract, // Boolean
receive, // Boolean
},
etherscan: { // Etherscan link
kovan,
ropsten,
ether,
},
}
Get All Transactions
const allTsx = await ethToolbox.getAllTsx(address, network, etherScanKey, providerUrl);
Inputs
address
: Ethereum addressnetwork
: Network numberetherScanKey
: API key etherscanproviderUrl
: Provider URL
Return value
allTsx = [
{
etherscan, // Etherscan link
value, // Amount
to, // Eth address
from, // Eth address
date, // Date of the transaction
timeStamp, // TimeStamp
error, // Boolean
dether: {
receive, // Boolean
myEther, // Boolean
},
},
...
]
Get Balance
const balance = await ethToolbox.getEthBalance(address, providerUrl);
Inputs
address
: Ethereum addressproviderUrl
: Provider URL
Return value
Return ether amount in address
Account Amount
const amount = await ethToolbox.accountAmount(address, providerUrl);
Inputs
address
: Ethereum addressproviderUrl
: Provider URL
Return value
{
usd: {
price: 338.73,
balance: 11.70036773046875,
total: 3963.26556134168,
},
eur: {
price: 284.53,
balance: 11.70036773046875,
total: 3329.1056303502733,
},
cny: {
price: 2269.82,
balance: 11.70036773046875,
total: 26557.72868197258,
},
krw: {
price: 386628.54,
balance: 11.70036773046875,
total: 4523696.093094246,
},
jpy: {
price: 38280.56,
balance: 11.70036773046875,
total: 447896.6289282728,
}
}
Get Seed
const seed = await ethToolbox.getSeed(keystore, password);
Inputs
keystore
: Deserialize keystorepassword
: Password to decode keystore
Return value
Return seed
Extra tools
Create Vault
const ks = ethToolbox.utils.createVault({ password, seedPhrase, hdPathString });
Inputs
password
: New passwordseedPhrase
: Seed phrase (12 words)hdPathString
Return value
New serialized keystore
Deserialize keystore
const dsKeystore = ethToolbox.utils.deserializeKeystore(serializedKeystore);
Inputs
serializedKeystore
: Serialized keystore
Return value
Deserialize keystore
Generate Random Seed
const seed = ethToolbox.utils.generateRandomSeed(entropy);
Inputs
entropy
Return value
Random phrase of 12 words
is Address
const test = ethToolbox.utils.isAddr(ethAddr);
Inputs
ethAddr
: Ethereum address
Return value
Return true if ethAddr is a Etherem address valid
Add 0x
const formated = ethToolbox.utils.add0x(ethAddr);
Inputs
ethAddr
: Ethereum address
Return value
Formated address
Get Signed web3
const web3 = ethToolbox.utils.getSignedWeb3(privateKey, address)
Inputs
privateKey
: Private keyaddressy
: Ethereum address
Return value
New Web3 instance
Install
// use npm
npm install --save eth-toolbox
// use yarn
yarn add eth-toolbox
Example
git clone https://github.com/dethertech/eth-toolbox.git
yarn
yarn run example
Dev
git clone https://github.com/dethertech/eth-toolbox.git
cd eth-toolbox
yarn
Test
npm test
Build doc
# Install ESDoc
yarn
# Run ESDoc.
yarn run:doc
Dependencies
Dev Dependencies
- babel-cli
- babel-core
- babel-eslint
- babel-polyfill
- babel-preset-latest
- chai
- chai-as-promised
- esdoc
- esdoc-standard-plugin
- eslint
- eslint-config-airbnb-base
- eslint-plugin-import
- mocha
Bugs
When you find issues, please report them: