From 890e2fd78b45606e7ea31dfa5f5134d8b7f8b00c Mon Sep 17 00:00:00 2001 From: poma Date: Sat, 13 Jul 2019 17:45:08 +0300 Subject: [PATCH] cli --- cli.js | 116 ++++++++-------- package-lock.json | 338 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 4 +- truffle-config.js | 12 +- 4 files changed, 397 insertions(+), 73 deletions(-) diff --git a/cli.js b/cli.js index 6e0ce58..eb59df6 100755 --- a/cli.js +++ b/cli.js @@ -1,40 +1,55 @@ #!/usr/bin/env node +const assert = require('assert'); const snarkjs = require("snarkjs"); const bigInt = snarkjs.bigInt; const utils = require("./scripts/utils"); const merkleTree = require('./lib/MerkleTree'); -const contract = require("truffle-contract"); -const Mixer = contract(require('./build/contracts/Mixer.json')); +const Web3 = require('web3') -const sender = "";//accounts[0]; -const amount = "1 ether"; +let web3, mixer; +async function init() { + web3 = new Web3('http://localhost:8545', null, {transactionConfirmationBlocks: 1}); + let netId = await web3.eth.net.getId() + const json = require('./build/contracts/Mixer.json'); + mixer = new web3.eth.Contract(json.abi, json.networks[netId].address); + const tx = await web3.eth.getTransaction(json.networks[netId].transactionHash); + mixer.deployedBlock = tx.blockNumber; +} + +function createDeposit(nullifier, secret) { + let deposit = {nullifier, secret}; + deposit.preimage = Buffer.concat([deposit.nullifier.leInt2Buff(32), deposit.secret.leInt2Buff(32)]); + deposit.commitment = utils.pedersenHash(deposit.preimage); + return deposit; +} async function deposit() { - let deposit = { - nullifier: utils.rbigint(31), - secret: utils.rbigint(31), - }; - const preimage = Buffer.concat([deposit.nullifier.leInt2Buff(32), deposit.secret.leInt2Buff(32)]); - deposit.commitment = utils.pedersenHash(preimage); + await init(); + const deposit = createDeposit(utils.rbigint(31), utils.rbigint(31)); console.log("Submitting deposit transaction"); - const mixer = await Mixer.deployed(); - await mixer.deposit(deposit.commitment, { value: amount, from: sender }); + await mixer.methods.deposit("0x" + deposit.commitment.toString(16)).send({ value: web3.utils.toWei("1", "ether"), from: (await web3.eth.getAccounts())[0], gas:1e6 }); - return preimage.toString('hex'); + const note = "0x" + deposit.preimage.toString('hex'); + console.log("Your note:", note); + return note; } async function withdraw(note, receiver) { + await init(); let buf = Buffer.from(note.slice(2), "hex"); - let deposit = { - nullifier: bigInt.leBuff2int(buf.slice(0, 32)), - secret: bigInt.leBuff2int(buf.slice(32, 64)), - }; + let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 32)), bigInt.leBuff2int(buf.slice(32, 64))); console.log("Getting current state from mixer contract"); - const mixer = await Mixer.deployed(); + const events = await mixer.getPastEvents('LeafAdded', {fromBlock: mixer.deployedBlock, toBlock: 'latest'}); + const leaves = events.sort(e => e.returnValues.leaf_index).map(e => e.returnValues.leaf); + const tree = new merkleTree(16, 0, leaves); + const validRoot = await mixer.methods.isKnownRoot(await tree.root()).call(); + assert(validRoot === true); - const {root, path_elements, path_index} = await tree.path(1); + const leafIndex = leaves.indexOf(deposit.commitment.toString()); + assert(leafIndex > 0); + const {root, path_elements, path_index} = await tree.path(leafIndex); // Circuit input const input = { // public @@ -53,17 +68,17 @@ async function withdraw(note, receiver) { const { pi_a, pi_b, pi_c, publicSignals } = await utils.snarkProof(input); console.log("Submitting withdraw transaction"); - await mixer.withdraw(pi_a, pi_b, pi_c, publicSignals, { from: sender }) + await mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).send({ from: (await web3.eth.getAccounts())[0], gas: 1e6 }); + console.log("Done"); } -function printHelp() { - console.log(` -Usage: +function printHelp(code = 0) { + console.log(`Usage: Submit a deposit from default eth account and return the resulting note $ ./cli.js deposit Withdraw a note to 'receiver' account - $ ./cli.js withdraw Example: $ ./cli.js deposit @@ -72,38 +87,29 @@ Example: $ ./cli.js withdraw 0x1941fa999e2b4bfeec3ce53c2440c3bc991b1b84c9bb650ea19f8331baf621001e696487e2a2ee54541fa12f49498d71e24d00b1731a8ccd4f5f5126f3d9f400 0xee6249BA80596A4890D1BD84dbf5E4322eA4E7f0 `); - process.exit(0); + process.exit(code); } -(async () => { - const dep = await deposit(); - console.log(`Your note: 0x${dep}`); +const args = process.argv.slice(2); +if (args.length === 0) { + printHelp(); +} else { + switch (args[0]) { + case 'deposit': + if (args.length === 1) + deposit().then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}); + else + printHelp(1); + break; - const acc = "0xee6249BA80596A4890D1BD84dbf5E4322eA4E7f0";//accounts[1]; - await withdraw(dep, acc); -})(); + case 'withdraw': + if (args.length === 3 && /^0x[0-9a-fA-F]{128}$/.test(args[1]) && /^0x[0-9a-fA-F]{40}$/.test(args[2])) + withdraw(args[1], args[2]).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}); + else + printHelp(1); + break; - -// const args = process.argv.slice(2); -// if (args.length === 0) { -// printHelp(); -// } -// -// switch (args[0]) { -// case 'deposit': -// if (args.length === 1) -// deposit().then(() => process.exit(0)); -// else -// printHelp(); -// break; -// -// case 'withdraw': -// if (args.length === 3 && /^[0-9a-fA-F]{128}$/.test(args[1]) && /^[0-9a-fA-F]{64}$/.test(args[2])) -// withdraw(args[1], args[2]).then(() => process.exit(0)); -// else -// printHelp(); -// break; -// -// default: -// printHelp(); -// } + default: + printHelp(1); + } +} diff --git a/package-lock.json b/package-lock.json index 1ac48c7..9b0d0ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -866,6 +866,39 @@ "eslint": "^5.3.0", "yargs": "^12.0.2" } + }, + "web3": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.0.0-beta.55.tgz", + "integrity": "sha512-yJpwy4IUA3T/F9hWzYQVn0GbJCrAaZ0KTIO3iuqkhaYH0Y09KV7k4GzFi4hN7hT4cFTj4yIKaeVCwQ5kzvi2Vg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/node": "^10.12.18", + "web3-core": "1.0.0-beta.55", + "web3-eth": "1.0.0-beta.55", + "web3-eth-personal": "1.0.0-beta.55", + "web3-net": "1.0.0-beta.55", + "web3-providers": "1.0.0-beta.55", + "web3-shh": "1.0.0-beta.55", + "web3-utils": "1.0.0-beta.55" + } + }, + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } } } }, @@ -7674,6 +7707,25 @@ "web3-providers": "1.0.0-beta.55", "web3-shh": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-bzz": { @@ -7698,6 +7750,25 @@ "web3-core-method": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-core-helpers": { @@ -7710,6 +7781,25 @@ "web3-core": "1.0.0-beta.55", "web3-eth-iban": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-core-method": { @@ -7725,6 +7815,25 @@ "web3-core-helpers": "1.0.0-beta.55", "web3-core-subscriptions": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-core-promievent": { @@ -7840,6 +7949,25 @@ "web3-net": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-eth-abi": { @@ -7851,6 +7979,25 @@ "ethers": "^4.0.27", "lodash": "^4.17.11", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-eth-accounts": { @@ -7877,6 +8024,23 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } } } }, @@ -7896,6 +8060,25 @@ "web3-eth-accounts": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-eth-ens": { @@ -7915,6 +8098,25 @@ "web3-net": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-eth-iban": { @@ -7925,6 +8127,25 @@ "@babel/runtime": "^7.3.1", "bn.js": "4.11.8", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-eth-personal": { @@ -7940,6 +8161,25 @@ "web3-net": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-net": { @@ -7954,6 +8194,25 @@ "web3-core-method": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-providers": { @@ -7972,6 +8231,25 @@ "web3-utils": "1.0.0-beta.55", "websocket": "^1.0.28", "xhr2-cookies": "1.1.0" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-providers-http": { @@ -8201,23 +8479,61 @@ "web3-net": "1.0.0-beta.55", "web3-providers": "1.0.0-beta.55", "web3-utils": "1.0.0-beta.55" + }, + "dependencies": { + "web3-utils": { + "version": "1.0.0-beta.55", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", + "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "requires": { + "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", + "@types/node": "^10.12.18", + "bn.js": "4.11.8", + "eth-lib": "0.2.8", + "ethjs-unit": "^0.1.6", + "lodash": "^4.17.11", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "utf8": "2.1.1" + } + } } }, "web3-utils": { - "version": "1.0.0-beta.55", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.55.tgz", - "integrity": "sha512-ASWqUi8gtWK02Tp8ZtcoAbHenMpQXNvHrakgzvqTNNZn26wgpv+Q4mdPi0KOR6ZgHFL8R/9b5BBoUTglS1WPpg==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0.tgz", + "integrity": "sha512-zm0gdLXLk54ldwxxBMNPS62EuqHI2PaJohEGijTowacNS0BS2vEXdriNA8gp1+EplP2WgoHE0uRVmQIfpAyV+Q==", "requires": { - "@babel/runtime": "^7.3.1", - "@types/bn.js": "^4.11.4", - "@types/node": "^10.12.18", "bn.js": "4.11.8", - "eth-lib": "0.2.8", - "ethjs-unit": "^0.1.6", - "lodash": "^4.17.11", + "eth-lib": "0.2.7", + "ethjs-unit": "0.1.6", "number-to-bn": "1.7.0", - "randombytes": "^2.1.0", - "utf8": "2.1.1" + "randomhex": "0.1.5", + "underscore": "1.9.1", + "utf8": "3.0.0" + }, + "dependencies": { + "eth-lib": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", + "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "utf8": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", + "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==" + } } }, "websnark": { diff --git a/package.json b/package.json index e264ddd..edfabbf 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "build:circuit": "mkdir -p build/circuits && npm run build:circuit:compile && npm run build:circuit:setup && npm run build:circuit:bin && npm run build:circuit:contract", "build:contract": "npx truffle compile", "test": "npx truffle test", - "migrate": "npx truffle migrate --network kovan --reset" + "migrate": "npx truffle migrate --network kovan --reset", + "migrate:dev": "npx truffle migrate --network development --reset" }, "keywords": [], "author": "", @@ -29,6 +30,7 @@ "truffle-artifactor": "^4.0.23", "truffle-contract": "^4.0.24", "truffle-hdwallet-provider": "^1.0.14", + "web3": "^1.0.0-beta.55", "web3-utils": "^1.0.0-beta.55", "websnark": "0.0.4" } diff --git a/truffle-config.js b/truffle-config.js index 5b239cb..369ada4 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -23,12 +23,12 @@ module.exports = { // You should run a client (like ganache-cli, geth or parity) in a separate terminal // tab if you use this network and you must also set the `host`, `port` and `network_id` // options below to some value. - // - // development: { - // host: "127.0.0.1", // Localhost (default: none) - // port: 8545, // Standard Ethereum port (default: none) - // network_id: "*", // Any network (default: none) - // }, + + development: { + host: "127.0.0.1", // Localhost (default: none) + port: 8545, // Standard Ethereum port (default: none) + network_id: "*", // Any network (default: none) + }, // Another network with more advanced options... // advanced: {