Last active
January 11, 2022 20:18
-
-
Save buddies2705/f3ab56e90f79786fcd78db04b95a6f71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3') | |
const httpProvider = "YOUR_QUIKNODE_RINKEBY_URL" | |
var web3 = new Web3(new Web3.providers.HttpProvider(httpProvider)); | |
//create account | |
// console.log(web3.eth.accounts.create(web3.utils.randomHex(32))); | |
const privateKey = "0x8679f89a15e31cbeb7256f37db1a6df215a103261e7c54dd90f8cba9eeba0c70"; | |
const address = "0x3318B0C23621d70B7F22a694d7D7E78f37208AD2"; | |
web3.eth.accounts.wallet.add({ | |
privateKey: '0x8679f89a15e31cbeb7256f37db1a6df215a103261e7c54dd90f8cba9eeba0c70', | |
address: '0x3318B0C23621d70B7F22a694d7D7E78f37208AD2' | |
}); | |
let cETH ="0xbed6d9490a7cd81ff0f06f29189160a9641a358f"; | |
let CEther = new web3.eth.Contract(abi, cETH); | |
let cDAI = "0x2acc448d73e8d53076731fea2ef3fc38214d0a7d" | |
let cDaiInstance = new web3.eth.Contract(daiAbi, cDAI); | |
let comptroller = "0x8d2a2836d44d6735a2f783e6418caedb86da58d8"; | |
const troll = new web3.eth.Contract(trollAbi, comptroller); | |
CEther.methods.supplyRatePerBlock().call().then((result) => { | |
console.log(result / 1e18); | |
}).catch(error => console.log(error)); | |
CEther.methods.mint().send({from: address, value: 2000000000000000000, gas : 2500000}) | |
.on('transactionHash', (hash) => { | |
console.log("hash", hash) | |
}) | |
.on('confirmation', (confirmationNumber, receipt) => { | |
console.log("confirmationNumber", confirmationNumber) | |
console.log("receipt", receipt) | |
}) | |
.on('receipt', (receipt) => { | |
// receipt example | |
console.log("receipt", receipt); | |
}) | |
.on('error', console.error); | |
troll.methods.enterMarkets([cETH, cDAI]).send({from: address , gas : 2500000}).on('transactionHash', (hash) => { | |
console.log("hash", hash) | |
}) | |
.on('confirmation', (confirmationNumber, receipt) => { | |
console.log("confirmationNumber", confirmationNumber) | |
console.log("receipt", receipt) | |
}) | |
.on('receipt', (receipt) => { | |
// receipt example | |
console.log("receipt", receipt); | |
}) | |
.on('error', console.error); | |
cDaiInstance.methods.borrow(5).send({from: address , gas : 2500000}).on('transactionHash', (hash) => { | |
console.log("hash", hash) | |
}) | |
.on('confirmation', (confirmationNumber, receipt) => { | |
console.log("confirmationNumber", confirmationNumber) | |
console.log("receipt", receipt) | |
}) | |
.on('receipt', (receipt) => { | |
// receipt example | |
console.log("receipt", receipt); | |
}) | |
.on('error', console.error); | |
cDaiInstance.methods.borrowBalanceCurrent(address).call().then(result => { | |
console.log(result.toNumber() / 1E18) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment