0xSpaceShard/starknet-hardhat-plugin

Argent Account not working in js

jrcarlos2000 opened this issue · 11 comments

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

What is the format of the private key?

What is the format of the private key?

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

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

Private key is set

Was this Argent account deployed using the Hardhat plugin?

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.

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

Also having this exact same issue

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.

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

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.