Consensys / anonymous-zether

A private payment system for Ethereum-based blockchains, with no trusted setup.
Other
296 stars 78 forks source link

Error while executing transfer #27

Closed kpv9 closed 4 years ago

kpv9 commented 4 years ago

I am trying to execute packages/example but it is failing while transferring the tokens from alice to bob. The error is transaction reverted. What am i supposed to do?

ibudisteanu commented 4 years ago

Are you sure you have an updated ethereum node? I recommend you to install ganache

kpv9 commented 4 years ago

Are you sure you have an updated ethereum node? I recommend you to install ganache

yes the ethereum node is updated. I am unable to try it on ganache as i dont know how to enable websocket in ganache-cli.

ibudisteanu commented 4 years ago

Again, try using ganache. It is really easy to set up. After you start it, increase the gas limit for the block and then set the port in the anonymous-zether

kpv9 commented 4 years ago

hey i have completed the setuo for ganache and having new error . I am attaching the screenshot of the error i am facing. please help me to solve it. zether error

ibudisteanu commented 4 years ago

You are doing it well. Your sender account doesn't have enough funds (probably it has 0 eth). The thing is that when the transfer is called it requires eth gas for the sender. Just give some eth from ganache to the sender address.

benediamond commented 4 years ago

This is because gas is not free in your environment, and Anonymous Zether generates a random account to send from. please see the discussion here https://github.com/jpmorganchase/anonymous-zether/issues/24#issuecomment-595441559 and below! thank you.

benediamond commented 4 years ago

The quickest way to fix it is to use instead of throwaway, a fixed account, which you have pre-funded with ether.

kpv9 commented 4 years ago

Thank you so much @benediamond and @ibudisteanu . It worked perfectly.

benediamond commented 4 years ago

@kpv9 good to hear!

benediamond commented 4 years ago

actually, @kpv9 @ibudisteanu, can you do me a big favor, and tell me whether the issue is solved by adding 'gasPrice': 0, to line 275? https://github.com/jpmorganchase/anonymous-zether/blob/8cafe19e2fb6a56f8c45a4718c3fc2b24e59ccee/packages/anonymous.js/src/client.js#L275 if this works, it might be the easiest solution; in that case i'll push a fix for it. thanks.

kpv9 commented 4 years ago

no it didn't work if we use throwaway.

benediamond commented 4 years ago

ok interesting, thanks for giving that a try.

kpv9 commented 4 years ago

@benediamond hey can you please give me a javascript in which Alice transfers b amount confidentially to Bob and then that b ZTH are burnt back in Bob's account.

ibudisteanu commented 4 years ago

Just follow the example. It is more than clear.

    const alice = new Client(web3, deployed, accounts[0]);
    await alice.register();
    await alice.deposit(100);
    const bob = new Client(web3, deployed, accounts[0]);
    await bob.register();
    alice.friends.add("Bob", bob.account.public());
    await alice.transfer('Bob', 10);
    await bob.withdraw(10);
kpv9 commented 4 years ago

hey, now i want to check the balance of bob's ethereum account before transfer and after burn has executed. which address to use in getBalance()?????

ibudisteanu commented 4 years ago

@kpv9 as far as I know, the tests code is a simplification of the entire process because it is used only for testing. I recommend you just use the console.log(bob.account._state.available) for printing out the balance.

I know that the Burn is sending the burned coins to the msg.sender namely to the address which is making the burn transaction namely accounts[0], where accounts = web3.eth.getAccounts();

kpv9 commented 4 years ago

Thank You so much.

console.log(bob.account._state.available)

This worked. zether_transfer