Skip to content

Conversation

zjesko
Copy link
Contributor

@zjesko zjesko commented Mar 10, 2025

Add the ability to pass customData along with overrides to enable paymaster and other interactions.

More details:
As defined in ethers, we can pass an extra override customData which is used for passing along for network-specific values for networks like zksync and sophon.
https://github.com/ethers-io/ethers.js/blob/main/src.ts/providers/provider.ts#L198

This PR adds the ability to pass customData as part of overrides.
Taken inspiration from hardhat-zksync-deploy
https://github.com/matter-labs/hardhat-zksync/blob/main/packages/hardhat-zksync-deploy/src/deployer-helper.ts#L101

A very good use case is zksync/sophon paymaster deployments.

Example usage for sophon network:

export default async function (hre: HardhatRuntimeEnvironment) {
    console.info(chalk.yellow(`Running deploy script for the Greeting contract`));

    const constructorArguments = ["Hello World"];

    const {deployments, getNamedAccounts} = hre;
    const {deploy} = deployments;

    const {deployer} = await getNamedAccounts();

    const params = zk.utils.getPaymasterParams(
      "0x98546B226dbbA8230cf620635a1e4ab01F6A99B2", // Sophon default paymaster address
      {
        type: "General",
        innerInput: new Uint8Array(),
      }
    );

    const contract = await deploy('Greeter', {
      from: deployer,
      args: ["Hello World"],
      log: true,
      customData: {
        paymasterParams: params,
        gasPerPubdata: zk.utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
      }
    });

    console.info(chalk.green(`Greeter was deployed to ${contract.address}`));
}

@zjesko
Copy link
Contributor Author

zjesko commented Mar 10, 2025

@wighawag please review

@wighawag wighawag merged commit 210362e into wighawag:master Mar 11, 2025
2 checks passed
@wighawag
Copy link
Owner

Great, thanks @zjesko !
available in 0.14.1

@zjesko zjesko deleted the add/zksync-custom-data branch March 11, 2025 06:31
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 this pull request may close these issues.

2 participants