Created
June 18, 2020 09:51
-
-
Save alexroan/69cfca435c5cfdc92f5e870955fe5e1c to your computer and use it in GitHub Desktop.
exchange-script.js
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
// Contracts | |
const Exchange = artifacts.require("Exchange") | |
// Utils | |
const ether = (n) => { | |
return new web3.utils.BN( | |
web3.utils.toWei(n.toString(), 'ether') | |
) | |
} | |
module.exports = async function(callback) { | |
try { | |
// Fetch accounts from wallet - these are unlocked | |
const accounts = await web3.eth.getAccounts() | |
// Fetch the deployed exchange | |
const exchange = await Exchange.deployed() | |
console.log('Exchange fetched', exchange.address) | |
// Set up exchange users | |
const user1 = accounts[0] | |
// User 1 Deposits Ether | |
amount = 2 | |
await exchange.depositEther({ from: user1, value: ether(amount) }) | |
console.log(`Deposited ${amount} Ether from ${user1}`) | |
//... | |
} | |
catch(error) { | |
console.log(error) | |
} | |
callback() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment