zksync-sdk / zksync2-js

MIT License
25 stars 29 forks source link

Implement method to retrieve deployment nounce #10

Closed idea404 closed 10 months ago

idea404 commented 11 months ago

🌟 Feature Request

📝 Description

Implement a new method like wallet.getDeployNonce() that returns the deployment nounce.

🤔 Rationale

To get the deployment nounce for a deploy transaction now, you need to ask for the rawNonce for an account (the param is uint256, you need to pad the address with zeroes to the left) https://github.com/matter-labs/era-system-contracts/blob/3e954a629ad8e01616174bde2218241b360fda0a/contracts/NonceHolder.sol#L35

After you get the value it will be of form 2^128 * deploymentNonce + normalNonce. You then need to do the floored division (BigNumber.div(..)).

danijelTxFusion commented 10 months ago

After you get the value it will be of form 2^128 * deploymentNonce + normalNonce. You then need to do the floored division (BigNumber.div(..)).

This is already implemented in _splitRawNonce() which is used by getDeploymentNonce().

danijelTxFusion commented 10 months ago

Implented in both SDKs: