require('dotenv').config() const { ethers } = require("ethers"); const path = require('path'); const Web3 = require('web3'); const Tx = require('@ethereumjs/tx'); const Contract = require('web3-eth-contract'); const appRoot = require('app-root-path'); // const IERC20 = require('./interfaceAbi/IERC20.json') // const safebox = require(path.resolve(appRoot.path, './src/output/abi/SafeBox.json')) //require('./output/abi/SafeBox.json') const safebox = require('./output/abi/SafeBox.json') // path.resolve("users/admin", "readme.md") const web3 = new Web3('https://rinkeby.infura.io/v3/403238924914456d949289598ceffd80'); const setDeploment = (networkName) => { const deployments = require(`./output/${networkName}.json`)//require(path.join(appRoot.path, `./src/${networkName}.json`)) //console.log(deployments); return deployments } export class SafeBox { deployments uniswapSpell contract network account provider box token constructor(account, provider, network) { this.account = account this.network = network this.provider = provider this.deployments = setDeploment(this.network) this.contract = Contract.setProvider(this.provider) } public async depositEthers (amount) { const provider = new ethers.providers.JsonRpcProvider(this.provider); const signer = provider.getSigner(this.account) let box = new ethers.Contract('0x062AdF7E0C86462099e065Ece95A9546CC466487', safebox.abi, provider) // let box = new web3.eth.Contract(safebox.abi, '0xF333e57BAE092681Df92a9BD5Ff97fA6Bb90567d') //console.log(await web3.eth.getAccounts); const boxWithSigner = await box.connect(signer); //console.log(boxWithSigner); let supply = await boxWithSigner.deposit(amount) } public async deposit (amount) { let box = new web3.eth.Contract(safebox.abi, '0xF333e57BAE092681Df92a9BD5Ff97fA6Bb90567d') let supply = await box.methods.deposit(amount) } public async withdraw (amount) { let box = new web3.eth.Contract(safebox.abi, '0xF333e57BAE092681Df92a9BD5Ff97fA6Bb90567d') let withdrawFunction = await box.methods.withdraw(amount) } } // const main = async () => { // let box = new SafeBox('0x775C72FB1C28c46F5E9976FFa08F348298fBCEC0', 'https://rinkeby.infura.io/v3/403238924914456d949289598ceffd80', 'rinkeby') // await box.deposit(1e6) // } // main()