Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
monitorchain-interface-library
Advanced tools
NodeJS libraries for interfacing and integrating MonitorChain by subscribers.
NodeJS libraries for interfacing and integrating MonitorChain by subscribers.
$ npm install monitorchain-interface-library
Following modules are being exported by the library:
It supports both promises and the async-await calls with or without the callbacks.
const {AccessInterface} = require('monitorchain-interface-library');
const log = console.log;
const mc = new AccessInterface(
'http://main.infura.io/<API KEY>',
'0xF8CE9D2....71337Bd6201a', //The MonitorChain address
'12 words mnemonic is here'
);
// Get the list of supported tokens (resolve a promise)
mc.getAllSupportedTokens().then(console.log);
// Get number of the supported tokens (using a callback)
mc.getNumberSupportedTokens((err, result) => {console.log(err, result)})
// Calculate a subscription price (async-await syntax)
const calc = async () => {
// 45-days subscription for 50 tokens
const price = await mc.calculatePrice(45, 50);
console.log(price);
};
calc();
// Subscribe to given list of tokens (default period)
const tokens = [
"0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
"0xf230b790E05390FC8295F4d3F60332c93BEd42e2"
];
mc.subscribe(tokens, (err, result) => {
console.log(`${err ? 'Fail':'Success'}`)
});
// 45 days subscription
let token = "0xE41d2489571d322189246DaFA5ebDe1F4699F498";
mc.subscribe([token], 45, (err, result) => {
console.log(`${err ? 'Fail':'Success'}`)
});
// Add a token to subscription (30 days), remit 1 eth for further purposes
const weiPerEth = "1000000000000000000";
let newToken = "0xA4e8C3Ec456107eA67d3075bF9e3DF3A75823DB0";
mc.init().then(() => {
mc.wallet = 1; // use the second address from the 'addresses' array generated by the truffle hdwallet provider
mc.addTokenToSubscription(newToken, null, null, weiPerEth, (err, result) => {
console.log(`${err ? err:'Success'}`)
})
});
const {AccessInterface} = require('monitorchain-interface-library');
const log = console.log;
const mc = new AccessInterface(
'http://localhost:8545',
'0xF8CE9D27Ff65E59cc5499a44f3fd71337Bd6201a',
'12 words mnemonic is here'
);
const subscribe = async() => {
mc.wallet = 2;
log(await mc.getSubscriptionData());
log(await mc.getTokensSubscribedTo());
await mc.subscribe([
"0xB8c77482e45F1F44dE1745F52C74426C631bDD52"
]);
log(await mc.getSubscriptionData());
log(await mc.remainingSubscriptionDays());
log(await mc.getTokensSubscribedTo());
};
subscribe();
const {AccessInterface} = require('monitorchain-interface-library');
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const nodeAddress = 'http://localhost:8545';
const monitorChainAddress = '0xF8CE9D27Ff65E59cc5499a44f3fd71337Bd6201a';
const mnemonic = '12 words mnemonic is here';
const web3 = new Web3(new HDWalletProvider(mnemonic, nodeAddress, 0, 20));
// A static method 'web3' allows to pass a custom web3 instance
const mc = AccessInterface.web3(web3, monitorChainAddress);
mc.getAllSupportedTokens(console.log);
const {AccessInterface, ERC20Interface} = require('monitorchain-interface-library');
const log = console.log;
const monitorChainAddress = '0xF8CE9D27Ff65E59cc5499a44f3fd71337Bd6201a';
const mc = new AccessInterface(
'http://localhost:8545',
monitorChainAddress,
'12 words mnemonic is here'
);
const ws = new AccessInterface(
'ws://localhost:8543',
monitorChainAddress
);
const callback = async (err, result) => {
if(err) throw err;
const tokenAddress = await mc.getTokenForEventId(result);
if (!tokenAddress) return; // return if a customer is not subscribed to token
log(`${tokenAddress}: a status has been changed: ${result}`);
log(await mc.getCurrentStatusDetails(tokenAddress));
const token =ERC20Interface.web3(mc.w3, tokenAddress);
const tokenInfo = await token.tokenInfo();
log(JSON.stringify(tokenInfo, null, 4));
};
ws.onStatusChanged(callback);
Increase a gas price:
const {ERC20Interface} = require('monitorchain-interface-library');
const token = new ERC20Interface(...);
...
token.gasPrice = 3; //gWei
...
Decrease the gasLimit:
const {ERC20Interface} = require('monitorchain-interface-library');
const token = new ERC20Interface(...);
...
token.gasLimit = '3000000'
...
$ npm uninstall ethereumjs-wallet
$ npm install ethereumjs-wallet@0.6.0
FAQs
NodeJS libraries for interfacing and integrating MonitorChain by subscribers.
The npm package monitorchain-interface-library receives a total of 1 weekly downloads. As such, monitorchain-interface-library popularity was classified as not popular.
We found that monitorchain-interface-library 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.