Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is possible get transaction hash from NIS or SDKs? #57

Open
JokerCatz opened this issue Sep 17, 2018 · 1 comment
Open

is possible get transaction hash from NIS or SDKs? #57

JokerCatz opened this issue Sep 17, 2018 · 1 comment

Comments

@JokerCatz
Copy link

JokerCatz commented Sep 17, 2018

is possible get transaction hash from NIS or SDKs?

I can't get transaction hash (like btc : txid or eth : txhash) without broadcast , & I can't get it from NIS API like /block/at/public too ( if I want get it without from my account or offline sign ) ... anybody can help me or use SDKs (without the web explorer ... ) ?

@fewCat
Copy link

fewCat commented Jul 8, 2019

`
import { Convert, SHA3Hasher, SignSchema } from 'nem2-sdk';

  const transferTransaction = TransferTransaction.create(
        TimeWindow.createWithDeadline(),
        new Address('your address'),
        new XEM(amount),
        EmptyMessage
    );
    const privateKey: string = 'your private key';
    const account = Account.createWithPrivateKey(privateKey);
    const signedTransaction = account.signTransaction(transferTransaction);

    const payload = signedTransaction.data;
    const signature = signedTransaction.signature;

    const byteBuff = Convert.hexToUint8(signedTransaction.data);
    const hashInUnit8 = new Uint8Array(32);
    SHA3Hasher.func(hashInUnit8, byteBuff, 32, SignSchema.KECCAK_REVERSED_KEY);
    const hash = Convert.uint8ToHex(hashInUnit8);
    console.log(`tx hash: ${hash}`);

`
work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants