ercmanager
v1.0.5
Published
Npm package that simplifies deployment and usage of erc tokens on ethereum Blockchain
Downloads
27
Maintainers
Readme
Installation
npm install ercmanager --save
Usage example
Create a new ERC20 token.
const ERCManager = require('ercmanager');
let erc20 = new ERCManager({
myAddress: "0x9CC14A288BB5cb9Ec0e85b606Cb6585BB7ca6a8E",
privateKey: '88BAEA1C45C1434E494604F48A39EEDB780BA71086D109B78CC3B7D41AA49773'
});
erc20.create(symbol="SNK", token_name = "Kanchan Coin").then(function (data) {
console.log(data)
});
- The constructor creates the ERC20 token.
- The essential parameters are address of the creator and their private key.
- The optional parameters are gas required, maximum limit of gas and the web3 provider(default = rinkeby.infura.io).
Connect to a deployed token.
let deployed_token = new ERCManager({
myAddress: "0x9CC14A288BB5cb9Ec0e85b606Cb6585BB7ca6a8E",
privateKey: '88BAEA1C45C1434E494604F48A39EEDB780BA71086D109B78CC3B7D41AA49773',
contractAddress: "0x8298cb3a2dc8fe592504dea860ad7be1882cdcfa",
});
Check balance of an account.
deployed_token.balance().then(function (data) {
console.log(data);
})
Transfer tokens: transfer(destination_account,amount)
deployed_token.transfer("0x25666A25Ef50B0d87F1f41a47883D7583DCf7980",1).then(function (data) {
console.log(data);
})
Approve spender to spend your tokens: approve(spender_address, amount)
deployed_token.approve("0x25666A25Ef50B0d87F1f41a47883D7583DCf7980",100).then(function (data) {
console.log(data);
})
Transfer token from approved account to another: transferFrom(from_address, to_address, amount)
deployed_token.transferFrom("0x25666A25Ef50B0d87F1f41a47883D7583DCf7980", "0x420493959C379D8375aFFA6Bb0De9E5C87f0A4c3",100).then(function (data) {
console.log(data);
})
Check Allowance: checkAllowance(spender_address, amount)
deployed_token.checkAllowance("0x25666A25Ef50B0d87F1f41a47883D7583DCf7980", 100).then(function (data) {
console.log(data);
})
Watch transfer of tokens.
deployed_token.watch_transfer(function (data) {
console.log(data.returnValues._from,data.returnValues._to,data.returnValues._value)
})
Watch Approval of tokens.
deployed_token.watch_approval(function (data) {
console.log(data.returnValues._from,data.returnValues._to,data.returnValues._value)
})
Development setup
git clone https://github.com/SauravKanchan/ERCManager
cd ERCManager
npm install
npm test
Release History
- 1.0.5
- Fix Bytecode
- 1.0.4
- Add transferFrom, Approve, CheckAllowance
- 1.0.3
- Create new tokens
- 1.0.2
- Fix Minor bugs
- 1.0.1
- Add transfer
- 1.0.0
- Work in progress
Meta
Distributed under the MIT license. See LICENSE
for more information.
Contributing
- We are open to addressing
bug-fixes
. - Feel free to add issues and submit patches
Contributors
- Saurav Kanchan - SauravKanchan
- Owais Khan - owaiswiz
- Rohit Vadali - enigmavadali
- Sandip Kumar - yadavsandip32