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

sign transaction in react-native #33

Closed
AmazingBeerBelly opened this issue Jul 4, 2019 · 5 comments
Closed

sign transaction in react-native #33

AmazingBeerBelly opened this issue Jul 4, 2019 · 5 comments

Comments

@AmazingBeerBelly
Copy link

Hi,

I have developed algorand wallet in react-native, and I find I can't sign the transaction in ios simulator. I find the problem is Buffer.from(). I run the test code in the node env and I can send the transaction. I have compared the transaction's blob and find the node's transaction's blob is different from the react-native's transaction's blob. How should I solve this problem?

thanks a lot.

@JasonWeathersby
Copy link
Contributor

can you post a sample of the code where this failing?

@AmazingBeerBelly
Copy link
Author

async sendTx(mnemonic, amount, toAddr) {
const algodclient = new algosdk.Algod(token, server, port)
const recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic)
const params = await algodclient.getTransactionParams()
const endRound = params.lastRound + parseInt(1000, 10)
const txn = {
from: recoveredAccount.addr,
to: toAddr,
fee: 1000,
amount,
firstRound: params.lastRound,
lastRound: endRound,
genesisID: params.genesisID,
genesisHash: params.genesishashb64,
note: new Uint8Array(0),
}
const signedTxn = algosdk.signTransaction(txn, recoveredAccount.sk)
// signedTxn.blob's length is 247 in node, and 767 in react native.
// I have found result of the Buffer.from() is different.
const tx = (await algodclient.sendRawTransaction(signedTxn.blob))
return tx
},

@AmazingBeerBelly
Copy link
Author

AmazingBeerBelly commented Jul 11, 2019

And I have an error when generating an account in react native without "Debug JS Remotely" mode.

code:
const account = algosdk.generateAccount()

then it reports errors "[Error: no PRNG]"

@JasonWeathersby
Copy link
Contributor

I believe this is an issue with Native React's lack of support for Crypto facebook/react-native#22933 . This is not a model we support currently

@AmazingBeerBelly
Copy link
Author

Ok, I will follow the react native issue. Thank you very much.

@rotemh rotemh closed this as completed Jul 12, 2019
bricerisingalgorand pushed a commit to bricerisingalgorand/js-algorand-sdk that referenced this issue Jul 20, 2021
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

3 participants