A node module to interact with blockchain for fmms project
- Install module
npm install --save ppbm@finterra/ppbm.js#master
- Add keystore
Copy past keystore file in
mkdir keystore cd keystore
keystore
folder. - Add abi in root folder
Sample folder structure after adding keystore and abi:
const { init } = require('fmms');
init({
web3Url: 'https://ropsten.infura.io/<token>',
ownerAddress: <owner-address>,
keystorePath: <keystore-path>,
abi: require(<abi-path>),
password: <password>,
contractAddress: <contract-address>,
});
const { createAccount } = require('fmms');
const password = '123';
createAccount(password)
.then(account => {
console.log('Account created');
console.log(account);
})
.catch(error => {
console.log(error);
});
const { changePassword } = require('fmms');
const oldPassword = '123';
const privateKeyObj = {...};
const newPassword = 'new123';
changePassword(oldPassword, privateKeyObj, newPassword)
.then(account => {
console.log('Password changed');
console.log(account);
})
.catch(error => {
console.log(error);
});
const { saveData } = require('fmms');
const dataJSON = { test: 'testing' };
const dataType = 1; // 1 = user info, TBD for others
const userObj = {
userId: 'IN12323',
userAddress: '0x3023427da0f663358f77026add8924b42cb9d332'
};
const privateKeyObj = {...};
const password = '123';
const loginObject = {
password,
privateKeyObj
};
// save data in blockchain
saveData(dataJSON, dataType, userObj, loginObject)
.then(data => {
console.log('saveData done');
console.log(data);
})
.catch(error => {
console.log(error);
});