Send value in options in depositEther
MODIFY
examples/node/depositEther.js
examples/node/depositEther.js
-const bn = require('bn.js')
-
const Matic = require('../../dist/index').default
const config = require('./config')
const utils = require('./utils')
-const amount = new bn(1).mul(utils.SCALING_FACTOR)
const from = config.FROM_ADDRESS
// Create Matic object
@@ -18,6 +15,8 @@ const matic = new Matic({
withdrawManager: config.WITHDRAWMANAGER_ADDRESS,
})
+const amount = matic.web3Client.web3.utils.toWei('.001', 'ether')
+
async function execute() {
await matic.initialize()
matic.setWallet(config.PRIVATE_KEY)

MODIFY
src/root/DepositManager.ts
src/root/DepositManager.ts
@@ -132,38 +132,22 @@ export default class DepositManager extends ContractsBase {
)
}
- // async depositEther(amount: BN | string, options: SendOptions = {}) {
-
- // const txObject = this.depositManagerContract.methods.depositEther()
-
- // const _options = await this._fillOptions(
- // options,
- // txObject,
- // this.web3Client.getParentWeb3(),
- // )
-
- // if (options.encodeAbi) {
- // _options.data = txObject.encodeABI()
- // _options.to = this.depositManagerContract.options.address
- // return _options
- // }
-
- // return this.web3Client.send(txObject, Object.assign(_options, { value: this.encode(amount), parent: true }))
- // }
-
async depositEther(amount: BN | string, options: SendOptions = {}) {
const txObject = this.depositManagerContract.methods.depositEther()
const _options = await this._fillOptions(
- options,
+ Object.assign(options, { value: this.encode(amount) }),
txObject,
this.web3Client.getParentWeb3(),
)
- return this.web3Client.send(
- txObject,
- Object.assign(_options, { value: amount }),
- )
+ if (options.encodeAbi) {
+ _options.data = txObject.encodeABI()
+ _options.to = this.depositManagerContract.options.address
+ return _options
+ }
+
+ return this.web3Client.send(txObject, _options)
}
getAddress() {

Send value in options in depositEther