mirror of
https://github.com/tornadocash/tornado-cli.git
synced 2024-11-21 17:27:07 +01:00
chore: naming
This commit is contained in:
parent
4dbdd42252
commit
d4f673a2ba
@ -1,15 +1,11 @@
|
||||
MERKLE_TREE_HEIGHT=20
|
||||
# in wei
|
||||
ETH_AMOUNT=100000000000000000
|
||||
# check config.js
|
||||
TOKEN_AMOUNT=100000000000000000
|
||||
PRIVATE_KEY=
|
||||
ERC20_TOKEN=
|
||||
|
||||
# DAI mirror in Kovan
|
||||
#ERC20_TOKEN=0xd2b1a6b34f4a68425e7c28b4db5a37be3b7a4947
|
||||
# the block when 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1 has some DAI is 13146218
|
||||
PRIVATE_KEY=
|
||||
|
||||
# USDT mirror in Kovan
|
||||
#ERC20_TOKEN=0xf3e0d7bf58c5d455d31ef1c2d5375904df525105
|
||||
#TOKEN_AMOUNT=1000000
|
||||
# the block when 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1 has some USDT is 13147586
|
||||
|
10
README.md
10
README.md
@ -1,15 +1,15 @@
|
||||
# Warning!
|
||||
Current cli version doesn't support [Anonymity Mining](https://tornado-cash.medium.com/tornado-cash-governance-proposal-a55c5c7d0703)
|
||||
|
||||
### Kovan, Mainnet
|
||||
### Goerli, Mainnet
|
||||
1. Add `PRIVATE_KEY` to `.env` file
|
||||
2. `./cli.js --help`
|
||||
|
||||
Example:
|
||||
```bash
|
||||
$ ./cli.js deposit ETH 0.1 --rpc https://kovan.infura.io/v3/27a9649f826b4e31a83e07ae09a87448
|
||||
$ ./cli.js deposit ETH 0.1 --rpc https://goerli.infura.io/v3/27a9649f826b4e31a83e07ae09a87448
|
||||
|
||||
Your note: tornado-eth-0.1-42-0xf73dd6833ccbcc046c44228c8e2aa312bf49e08389dadc7c65e6a73239867b7ef49c705c4db227e2fadd8489a494b6880bdcb6016047e019d1abec1c7652
|
||||
Your note: tornado-eth-0.1-5-0xf73dd6833ccbcc046c44228c8e2aa312bf49e08389dadc7c65e6a73239867b7ef49c705c4db227e2fadd8489a494b6880bdcb6016047e019d1abec1c7652
|
||||
Tornado ETH balance is 8.9
|
||||
Sender account ETH balance is 1004873.470619891361352542
|
||||
Submitting deposit transaction
|
||||
@ -18,14 +18,14 @@ Sender account ETH balance is 1004873.361652048361352542
|
||||
```
|
||||
|
||||
```bash
|
||||
$ ./cli.js withdraw tornado-eth-0.1-42-0xf73dd6833ccbcc046c44228c8e2aa312bf49e08389dadc7c65e6a73239867b7ef49c705c4db227e2fadd8489a494b6880bdcb6016047e019d1abec1c7652 0x8589427373D6D84E98730D7795D8f6f8731FDA16 --rpc https://kovan.infura.io/v3/27a9649f826b4e31a83e07ae09a87448 --relayer https://kovan-frelay.duckdns.org
|
||||
$ ./cli.js withdraw tornado-eth-0.1-5-0xf73dd6833ccbcc046c44228c8e2aa312bf49e08389dadc7c65e6a73239867b7ef49c705c4db227e2fadd8489a494b6880bdcb6016047e019d1abec1c7652 0x8589427373D6D84E98730D7795D8f6f8731FDA16 --rpc https://goerli.infura.io/v3/27a9649f826b4e31a83e07ae09a87448 --relayer https://goerli-frelay.duckdns.org
|
||||
|
||||
Relay address: 0x6A31736e7490AbE5D5676be059DFf064AB4aC754
|
||||
Getting current state from tornado contract
|
||||
Generating SNARK proof
|
||||
Proof time: 9117.051ms
|
||||
Sending withdraw transaction through relay
|
||||
Transaction submitted through the relay. View transaction on etherscan https://kovan.etherscan.io/tx/0xcb21ae8cad723818c6bc7273e83e00c8393fcdbe74802ce5d562acad691a2a7b
|
||||
Transaction submitted through the relay. View transaction on etherscan https://goerli.etherscan.io/tx/0xcb21ae8cad723818c6bc7273e83e00c8393fcdbe74802ce5d562acad691a2a7b
|
||||
Transaction mined in block 17036120
|
||||
Done
|
||||
```
|
||||
|
24
cli.js
24
cli.js
@ -19,7 +19,7 @@ const config = require('./config')
|
||||
const program = require('commander')
|
||||
const { GasPriceOracle } = require('gas-price-oracle')
|
||||
|
||||
let web3, tornado, mixerContract, tornadoInstance, circuit, proving_key, groth16, erc20, senderAccount, netId
|
||||
let web3, tornado, tornadoContract, tornadoInstance, circuit, proving_key, groth16, erc20, senderAccount, netId
|
||||
let MERKLE_TREE_HEIGHT, ETH_AMOUNT, TOKEN_AMOUNT, PRIVATE_KEY
|
||||
|
||||
/** Whether we are in a browser or node.js */
|
||||
@ -125,7 +125,7 @@ async function generateMerkleProof(deposit, amount) {
|
||||
|
||||
const startBlock = cachedEvents.lastBlock
|
||||
|
||||
let rpcEvents = await mixerContract.getPastEvents('Deposit', {
|
||||
let rpcEvents = await tornadoContract.getPastEvents('Deposit', {
|
||||
fromBlock: startBlock,
|
||||
toBlock: 'latest'
|
||||
})
|
||||
@ -158,8 +158,8 @@ async function generateMerkleProof(deposit, amount) {
|
||||
|
||||
// Validate that our data is correct
|
||||
const root = await tree.root()
|
||||
const isValidRoot = await mixerContract.methods.isKnownRoot(toHex(root)).call()
|
||||
const isSpent = await mixerContract.methods.isSpent(toHex(deposit.nullifierHash)).call()
|
||||
const isValidRoot = await tornadoContract.methods.isKnownRoot(toHex(root)).call()
|
||||
const isSpent = await tornadoContract.methods.isSpent(toHex(deposit.nullifierHash)).call()
|
||||
assert(isValidRoot === true, 'Merkle tree is corrupted')
|
||||
assert(isSpent === false, 'The note is already spent')
|
||||
assert(leafIndex >= 0, 'The deposit is not found in the tree')
|
||||
@ -540,7 +540,7 @@ function parseNote(noteString) {
|
||||
|
||||
async function loadDepositData({ deposit }) {
|
||||
try {
|
||||
const eventWhenHappened = await mixerContract.getPastEvents('Deposit', {
|
||||
const eventWhenHappened = await tornadoContract.getPastEvents('Deposit', {
|
||||
filter: {
|
||||
commitment: deposit.commitmentHex
|
||||
},
|
||||
@ -553,7 +553,7 @@ async function loadDepositData({ deposit }) {
|
||||
|
||||
const { timestamp } = eventWhenHappened[0].returnValues
|
||||
const txHash = eventWhenHappened[0].transactionHash
|
||||
const isSpent = await tornado.methods.isSpent(deposit.nullifierHex).call()
|
||||
const isSpent = await tornadoContract.methods.isSpent(deposit.nullifierHex).call()
|
||||
const receipt = await web3.eth.getTransactionReceipt(txHash)
|
||||
|
||||
return {
|
||||
@ -574,7 +574,7 @@ async function loadWithdrawalData({ amount, currency, deposit }) {
|
||||
|
||||
const startBlock = cachedEvents.lastBlock
|
||||
|
||||
let rpcEvents = await mixerContract.getPastEvents('Withdrawal', {
|
||||
let rpcEvents = await tornadoContract.getPastEvents('Withdrawal', {
|
||||
fromBlock: startBlock,
|
||||
toBlock: 'latest'
|
||||
})
|
||||
@ -617,7 +617,7 @@ async function loadWithdrawalData({ amount, currency, deposit }) {
|
||||
* Init web3, contracts, and snark
|
||||
*/
|
||||
async function init({ rpc, noteNetId, currency = 'dai', amount = '100' }) {
|
||||
let contractJson, mixerJson, erc20ContractJson, erc20tornadoJson, tornadoAddress, tokenAddress
|
||||
let contractJson, instanceJson, erc20ContractJson, erc20tornadoJson, tornadoAddress, tokenAddress
|
||||
// TODO do we need this? should it work in browser really?
|
||||
if (inBrowser) {
|
||||
// Initialize using injected web3 (Metamask)
|
||||
@ -626,7 +626,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100' }) {
|
||||
transactionConfirmationBlocks: 1
|
||||
})
|
||||
contractJson = await (await fetch('build/contracts/TornadoProxy.abi.json')).json()
|
||||
mixerJson = await (await fetch('build/contracts/Mixer.abi.json')).json()
|
||||
instanceJson = await (await fetch('build/contracts/Instance.abi.json')).json()
|
||||
circuit = await (await fetch('build/circuits/tornado.json')).json()
|
||||
proving_key = await (await fetch('build/circuits/tornadoProvingKey.bin')).arrayBuffer()
|
||||
MERKLE_TREE_HEIGHT = 20
|
||||
@ -637,7 +637,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100' }) {
|
||||
// Initialize from local node
|
||||
web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 })
|
||||
contractJson = require('./build/contracts/TornadoProxy.abi.json')
|
||||
mixerJson = require('./build/contracts/Mixer.abi.json')
|
||||
instanceJson = require('./build/contracts/Instance.abi.json')
|
||||
circuit = require('./build/circuits/tornado.json')
|
||||
proving_key = fs.readFileSync('build/circuits/tornadoProvingKey.bin').buffer
|
||||
MERKLE_TREE_HEIGHT = process.env.MERKLE_TREE_HEIGHT || 20
|
||||
@ -670,7 +670,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100' }) {
|
||||
} else {
|
||||
try {
|
||||
tornadoAddress = config.deployments[`netId${netId}`].proxy
|
||||
tornadoInstance = config.deployments[`netId${netId}`][currency].mixerAddress[amount]
|
||||
tornadoInstance = config.deployments[`netId${netId}`][currency].instanceAddress[amount]
|
||||
|
||||
if (!tornadoAddress) {
|
||||
throw new Error()
|
||||
@ -682,7 +682,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100' }) {
|
||||
}
|
||||
}
|
||||
tornado = new web3.eth.Contract(contractJson, tornadoAddress)
|
||||
mixerContract = new web3.eth.Contract(mixerJson, tornadoInstance)
|
||||
tornadoContract = new web3.eth.Contract(instanceJson, tornadoInstance)
|
||||
erc20 = currency !== 'eth' ? new web3.eth.Contract(erc20ContractJson.abi, tokenAddress) : {}
|
||||
}
|
||||
|
||||
|
24
config.js
24
config.js
@ -4,7 +4,7 @@ module.exports = {
|
||||
deployments: {
|
||||
netId1: {
|
||||
'eth': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'1': '0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936',
|
||||
'10': '0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF',
|
||||
'100': '0xA160cdAB225685dA1d56aa342Ad8841c3b53f291',
|
||||
@ -15,7 +15,7 @@ module.exports = {
|
||||
'decimals': 18
|
||||
},
|
||||
'dai': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0xD4B88Df4D29F5CedD6857912842cff3b20C8Cfa3',
|
||||
'1000': '0xFD8610d20aA15b7B2E3Be39B396a1bC3516c7144',
|
||||
'10000': '0x07687e702b410Fa43f4cB4Af7FA097918ffD2730',
|
||||
@ -28,7 +28,7 @@ module.exports = {
|
||||
'gasLimit': '55000'
|
||||
},
|
||||
'cdai': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'5000': '0x22aaA7720ddd5388A3c0A3333430953C68f1849b',
|
||||
'50000': '0x03893a7c7463AE47D46bc7f091665f1893656003',
|
||||
'500000': '0x2717c5e28cf931547B621a5dddb772Ab6A35B701',
|
||||
@ -41,7 +41,7 @@ module.exports = {
|
||||
'gasLimit': '425000'
|
||||
},
|
||||
'usdc': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0xd96f2B1c14Db8458374d9Aca76E26c3D18364307',
|
||||
'1000': '0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D',
|
||||
'10000': '',
|
||||
@ -54,7 +54,7 @@ module.exports = {
|
||||
'gasLimit': '80000'
|
||||
},
|
||||
'usdt': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0x169AD27A470D064DEDE56a2D3ff727986b15D52B',
|
||||
'1000': '0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f',
|
||||
'10000': '',
|
||||
@ -67,7 +67,7 @@ module.exports = {
|
||||
'gasLimit': '100000'
|
||||
},
|
||||
'wbtc': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'0.1': '0x178169B423a011fff22B9e3F3abeA13414dDD0F1',
|
||||
'1': '0x610B717796ad172B316836AC95a2ffad065CeaB4',
|
||||
'10': '0xbB93e510BbCD0B7beb5A853875f9eC60275CF498',
|
||||
@ -83,7 +83,7 @@ module.exports = {
|
||||
},
|
||||
netId5: {
|
||||
'eth': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'1': '0x3aac1cC67c2ec5Db4eA850957b967Ba153aD6279',
|
||||
'10': '0x723B78e67497E85279CB204544566F4dC5d2acA0',
|
||||
'100': '0x0E3A09dDA6B20aFbB34aC7cD4A6881493f3E7bf7',
|
||||
@ -94,7 +94,7 @@ module.exports = {
|
||||
'decimals': 18
|
||||
},
|
||||
'dai': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0x76D85B4C0Fc497EeCc38902397aC608000A06607',
|
||||
'1000': '0xCC84179FFD19A1627E79F8648d09e095252Bc418',
|
||||
'10000': '0xD5d6f8D9e784d0e26222ad3834500801a68D027D',
|
||||
@ -107,7 +107,7 @@ module.exports = {
|
||||
'gasLimit': '55000'
|
||||
},
|
||||
'cdai': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'5000': '0x833481186f16Cece3f1Eeea1a694c42034c3a0dB',
|
||||
'50000': '0xd8D7DE3349ccaA0Fde6298fe6D7b7d0d34586193',
|
||||
'500000': '0x8281Aa6795aDE17C8973e1aedcA380258Bc124F9',
|
||||
@ -120,7 +120,7 @@ module.exports = {
|
||||
'gasLimit': '425000'
|
||||
},
|
||||
'usdc': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0x05E0b5B40B7b66098C2161A5EE11C5740A3A7C45',
|
||||
'1000': '0x23173fE8b96A4Ad8d2E17fB83EA5dcccdCa1Ae52',
|
||||
'10000': '',
|
||||
@ -133,7 +133,7 @@ module.exports = {
|
||||
'gasLimit': '80000'
|
||||
},
|
||||
'usdt': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'100': '0x538Ab61E8A9fc1b2f93b3dd9011d662d89bE6FE6',
|
||||
'1000': '0x94Be88213a387E992Dd87DE56950a9aef34b9448',
|
||||
'10000': '',
|
||||
@ -146,7 +146,7 @@ module.exports = {
|
||||
'gasLimit': '100000'
|
||||
},
|
||||
'wbtc': {
|
||||
'mixerAddress': {
|
||||
'instanceAddress': {
|
||||
'0.1': '0x242654336ca2205714071898f67E254EB49ACdCe',
|
||||
'1': '0x776198CCF446DFa168347089d7338879273172cF',
|
||||
'10': '0xeDC5d01286f99A066559F60a585406f3878a033e',
|
||||
|
Loading…
Reference in New Issue
Block a user