deposit ether with example
MODIFY
examples/node/depositEther.js
examples/node/depositEther.js
-const Matic = require('maticjs').default
+const Matic = require('../../lib/index').default
const config = require('./config')
-const amount = '1000000000000000000' // amount in wei
+const amount = '9000000000000000' // amount in wei
const from = config.FROM_ADDRESS // from address
// Create object of Matic
@@ -18,11 +18,10 @@ matic.wallet = config.PRIVATE_KEY // prefix with `0x`
// Approve token
// Deposit tokens
-matic.depositEthers(from, {
+matic.depositEthers({
from,
value: amount,
onTransactionHash: () => {
// action on Transaction success
- // console.log(tx)
},
})

MODIFY
src/index.js
src/index.js
@@ -114,11 +114,11 @@ export default class Matic {
return balance
}
- async depositEthers(user, options = {}) {
- if (options && (!options.from || !user || !options.value)) {
+ async depositEthers(options = {}) {
+ if (options && (!options.from || !options.value)) {
throw new Error('Missing Parameters')
}
- const depositTx = this._rootChainContract.methods.depositEthers(user)
+ const depositTx = this._rootChainContract.methods.depositEthers()
const _options = await this._fillOptions(
options,
depositTx,

deposit ether with example