casper-ecosystem / casper-js-sdk

TypeScript Casper Client SDK
Apache License 2.0
71 stars 60 forks source link

[Uploading the secret key from a file] #368

Closed Fabrice-Fabio closed 9 months ago

Fabrice-Fabio commented 10 months ago

Describe the bug I'm trying to do a native casper transfer with a wallet using the casper-js-sdk library directly from my frontend. As specified in the documentation: https://docs.casper.network/developers/dapps/sdk/client-library-usage/ it would be necessary to initialize: const keypair = Keys.Ed25519.loadKeyPairFromPrivateFile("./secret_key.pem");

However, I have this error which appears on my react: Uncaught (in promise) TypeError: f.readFileSync is not a function at t.readBase64File (Keys.ts:348:1) at t.parsePrivateKeyFile (Keys.ts:299:1)

Impossible to retrieve the value of keypair to subsequently call the line: const signedDeploy = DeployUtil.signDeploy(deploy, keypair); to validate my transaction.

To Reproduce

Identify if any Prequisites:

Steps to reproduce the behavior:

  1. "react": "^18.2.0",
  2. "react-scripts": "5.0.1",
  3. "casper-js-sdk": "^2.15.2",

Expected behavior Validate a native transaction from the front knowing that the user is connecting with their Casper wallet and therefore we do not have direct access to the private key

Screenshots Screenshot 2023-09-13 at 18 27 26

Thanks for your contribution