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

Argent Account not working in js #117

Closed
jrcarlos2000 opened this issue Jun 6, 2022 · 11 comments · Fixed by #124
Closed

Argent Account not working in js #117

jrcarlos2000 opened this issue Jun 6, 2022 · 11 comments · Fixed by #124

Comments

@jrcarlos2000
Copy link

deploying an Argent account and invoking a function works well
but when reading an existing account and invoking a function in a contract there this issue :

var msgSignature = keyPair.sign(fixMessage(msgHash));
^
TypeError: Cannot read properties of null (reading 'sign')

using the private key exported from argent google extension

Screen Shot 2022-06-06 at 7 02 37 PM

@badurinantun
Copy link
Contributor

What is the format of the private key?

@jrcarlos2000
Copy link
Author

What is the format of the private key?

Is a hex string , from argent google extension casted to hex

@badurinantun
Copy link
Contributor

I'm not sure why it's null, are you sure process.env.PRIVATE_KEY is set?

@jrcarlos2000
Copy link
Author

Private key is set

@badurinantun
Copy link
Contributor

Was this Argent account deployed using the Hardhat plugin?

@jrcarlos2000
Copy link
Author

No it wasn’t , it’s an existing argent account . Don’t know if there is an extra workaround to import such wallets . For a wallet deployed from the plug-in , it doesn’t face this problem.

@badurinantun
Copy link
Contributor

Artifacts probably don't match, you would need to deploy the exact contract that was deployed previously

@rzmahmood
Copy link

Also having this exact same issue

@FabijanC
Copy link
Collaborator

FabijanC commented Jun 17, 2022

When you deploy your Argent Account, also store its guardian key. Then next time when you are loading it with starknet.getAccountFromAddress, also set the guardian:

const deployedAccount = await starknet.deployAccount("Argent");
const address = deployedAccount.address;
const privateKey = deployedAccount.privatekey;
const guardianPrivatekey = deployedAccount.guardianPrivateKey;

... doStuffHere() ...

const loadedAccount = (await starknet.getAccountFromAddress(address, privateKey, "Argent")) as ArgentAccount;
await loadedAccount.setGuardian(guardianPrivateKey);

Note that deploying ArgentAccounts currently (with Plugin v0.5.5) only works on Devnet because internally this requires invoking the initialize method of the account contract, which incurs cost (and requires a fee). Future versions will probably separate the initialization from the deployment.

@rzmahmood
Copy link

rzmahmood commented Jun 23, 2022

What if my Argent Account uses the 0 address as the guardian key? This is the default used by ArgentX. I'm still having this issue

@FabijanC
Copy link
Collaborator

What if my Argent Account uses the 0 address as the guardian key? This is the default used by ArgentX. I'm still having this issue

This will be fixed in the next plugin version.

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

Successfully merging a pull request may close this issue.

4 participants