starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.21k stars 739 forks source link

Deploying the Argent X encountered an error. #649

Closed infra403 closed 1 year ago

infra403 commented 1 year ago

Describe the bug Instance deployment: Account instance address: 0x0767e0e47E468f0871023D16A4047a581B661e4b6c547D69170804B17B65d0Dd

Error: private key must be 32 bytes, hex or bigint, not string

The error occured in the following stack trace: at normPrivateKeyToScalar (/node_modules/@noble/curves/abstract/weierstrass.js:161:19) at Point.fromPrivateKey (/node_modules/@noble/curves/abstract/weierstrass.js:231:40) at Object.getPublicKey (/node_modules/@noble/curves/abstract/weierstrass.js:718:22) at getPublicKey (/node_modules/micro-starknet/lib/index.js:56:18) at Object.getStarkKey (/node_modules/micro-starknet/lib/index.js:102:21) at deployAccount (/dist/plugins/starknet/deploy_account.js:16:41)

`//new Argent X account v0.2.3 : const argentXproxyClassHash = "0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"; const argentXaccountClassHash = "0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2";

export const deployAccount = async (address: string, privateKey: string) => { // Generate public and private key pair. const privateKeyAX = stark.randomAddress(); console.log('AX_ACCOUNT_PRIVATE_KEY=', privateKeyAX, typeof privateKeyAX);

console.log( privateKey, typeof privateKey) const starkKeyPubAX = ec.starkCurve.getStarkKey(privateKey);

console.log('AX_ACCOUNT_PUBLIC_KEY=', starkKeyPubAX);

// Calculate future address of the ArgentX account const AXproxyConstructorCallData = CallData.compile({ implementation: argentXaccountClassHash, selector: hash.getSelectorFromName("initialize"), calldata: CallData.compile({ signer: starkKeyPubAX, guardian: "0" }), }); const AXcontractAddress = hash.calculateContractAddressFromHash( starkKeyPubAX, argentXproxyClassHash, AXproxyConstructorCallData, 0 );

const accountAX = new Account(provider, address, privateKey);

const deployAccountPayload = { classHash: argentXproxyClassHash, constructorCalldata: AXproxyConstructorCallData, contractAddress: AXcontractAddress, addressSalt: starkKeyPubAX };

const { transaction_hash: AXdAth, contract_address: AXcontractFinalAdress } = await accountAX.deployAccount(deployAccountPayload); console.log('✅ ArgentX wallet deployed at :',AXcontractFinalAdress);

}`

To Reproduce Steps to reproduce the behavior

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

ivpavici commented 1 year ago

Hello! You are using privateKey instead of using privateKeyAX later in your code... try to modify your code and it should work