Skip to content

IND-408 | Add Contract Deployment Support#8

Merged
DrenIncentiv merged 1 commit intomainfrom
IND-408-add-contract-deployment-functionality
Feb 16, 2025
Merged

IND-408 | Add Contract Deployment Support#8
DrenIncentiv merged 1 commit intomainfrom
IND-408-add-contract-deployment-functionality

Conversation

@enis-incentiv
Copy link
Collaborator

Story

https://incentiv-net.atlassian.net/browse/IND-408

Description

This PR adds contract deployment functionality to the UI-SDK, enabling developers to deploy smart contracts through Account Abstraction using CREATE2 for deterministic addresses.

Key Features

  • Support for both ContractFactory and raw bytecode deployments
  • Deterministic addresses using CREATE2
  • Gas estimation with AA overhead calculation
  • Address prediction utilities

Technical Implementation

  1. Contract Deployment:

    • Added ContractDeployer class for handling deployments through AA
    • Support for constructor arguments and bytecode validation
    • Fire-and-forget pattern for UserOperation submission
  2. Configuration:

    • Added deployContractAddress to SDK config
    • Support for per-deployment overrides
    • Flexible gas limit configuration
  3. Error Handling:

    • Specific error types for bytecode and deployer validation
    • Clear error messages for common deployment issues
    • Debug logging for deployment tracking

Example Usage

// Using ContractFactory
const factory = new ContractFactory(ABI, BYTECODE, aaProvider.getSigner());
const txHash = await deployContract(aaProvider, factory);

// Using raw bytecode
const txHash = await deployContract(aaProvider, {
  bytecode: BYTECODE,
  constructorArgs: [arg1, arg2]
}, salt);

// With address prediction
const address = await predictContractAddress(aaProvider, input, salt);
console.log('Contract will be deployed at:', address);

// With custom gas
const txHash = await deployContract(aaProvider, input, salt, undefined, {
  gasLimit: ethers.utils.parseUnits('1000000', 'wei')
});

Testing

  • Verified deployments with both ContractFactory and bytecode
  • Tested address prediction accuracy
  • Validated gas estimation with AA overhead
  • Confirmed proper error handling

Breaking Changes

None. This is a new feature that maintains compatibility with existing functionality.

@DrenIncentiv DrenIncentiv merged commit 6ee7d8a into main Feb 16, 2025
1 check passed
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