use examples code into debug.js
MODIFY
README.md
README.md
@@ -46,6 +46,8 @@ Write your code inside file `test/debug.js` and run below code
npm run debug
```
+Above command will build the source code & install the builded version into test folder, which will be used by `debug.js`.
+
**Lint**
```bash

MODIFY
test/debug.js
test/debug.js
-const Matic = require('@maticnetwork/maticjs').default
+const { plasma } = require('../examples/config')
+const { getMaticPlasmaClient, from } = require('../examples/utils')
-const env = process.env
-const from = env.user1_address
-
-const matic = new Matic({
- maticProvider: env.MATIC_PROVIDER,
- parentProvider: env.PARENT_PROVIDER,
- rootChain: env.ROOTCHAIN_ADDRESS,
- withdrawManager: env.WITHDRAWMANAGER_ADDRESS,
- depositManager: env.DEPOSITMANAGER_ADDRESS,
- registry: env.REGISTRY,
-})
-
-const getBalance = async () => {
- await matic.initialize()
- matic.setWallet(env.user1_privateKey)
- const balance = await matic.balanceOfERC20(from, env.GOERLI_ERC20)
+const execute = async () => {
+ const { matic } = await getMaticPlasmaClient()
+ const balance = await matic.balanceOfERC20(from, plasma.child.erc20)
console.log('balance', balance)
}
-getBalance()
+execute().then(_ => {
+ process.exit(0)
+})

MODIFY
test/package.json
test/package.json
"description": "",
"main": "index.spec.js",
"scripts": {
+ "link:lib":"npm link @maticnetwork/maticjs",
"debug": "cross-env-file -p ./config.json node debug.js",
"install:lib": "node install_lib.js",
"install:lib:test": "npm run install:lib && npm run test",

use examples code into debug.js