neow3j / neow3j-examples-java

neow3j: Java Examples
Apache License 2.0
11 stars 8 forks source link

How to cancel the vote ? #17

Closed bxlkm closed 2 years ago

bxlkm commented 3 years ago

please help me ths!

gsmachado commented 3 years ago

Hello @bxlkm

Can you please tell me more?

Would you like that we create a Java example using neow3j to cancel a vote?

bxlkm commented 3 years ago

@gsmachado Yes, examples of canceling voting and withdrawing awards。ths!!!

gsmachado commented 3 years ago

@bxlkm you can find an example on how to vote for a pubKey candidate in this file.

If you would like to withdraw GAS, you just need to make a GAS transfer to another Neo address. You can find an example here.

If you want to check the GAS balance of your wallet, you can use the GasToken class (check the available methods).

gsmachado commented 3 years ago

@mialbu any example on how to cancel a vote?

Correct me if I'm wrong, but to cancel a vote someone could simply give null to the "candidateKey" param on the .vote() method here... right?

csmuller commented 3 years ago

@bxlkm, to cancel a vote do this with neow3j:

        NeoSendRawTransaction response = new NeoToken(neow3j)
                .invokeFunction("vote", hash160(account.getScriptHash()), any(null))
                .signers(AccountSigner.calledByEntry(account))
                .sign()
                .send();
bxlkm commented 3 years ago

@csmuller @mialbu thank you very much!

bxlkm commented 3 years ago

@csmuller @mialbu How to write the GAS Claim code?

csmuller commented 3 years ago

You can do it by transferring any amount of NEO to yourself. In the example below, a transfer from account to itself is made assuming that its balance is 1 or higher.

        new NeoToken(neow3j).transfer(account, account.getScriptHash(), BigInteger.ONE)
                .sign()
                .send();
bxlkm commented 3 years ago

@csmuller ths。

gsmachado commented 2 years ago

@bxlkm I will close this issue. If any questions remain, please re-open it. Thanks! 👍