Skip to content

how to calculate a contract address that is deployed with an AA wallet? #586

@moneyDev1111

Description

@moneyDev1111

Hi, I wonder how do I get the deployed contract address that I just deployed with a AA wallet? not the AA wallet address, but I sent a deployment tx with it, and somewhere on the blockchain my custom contract has been deployed, but how do I receive its address?? tx.contract address is null etc etc. And I cannot find it anywhere in the logs... Ok, I'm trying to get it with ethers.js getCreate2Address, but sth is wrong.. Could you tell how to do it properly? Thank you

btw I'm using a thirdweb's sdk but it really doens't matter I guess

const client = createThirdwebClient({
		clientId,
		secretKey,
	})

	const personalAccount = privateKeyToAccount({
		client,
		privateKey: 'myPK',
	}) 

	const wallet = smartWallet({
		chain: sepolia,
		sponsorGas: true,
	})

	const smartAccount = await wallet.connect({
		client,
		personalAccount,
	})


	const entryPointAddress = '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789'

	const iface = new Interface(abi)
	const constructorArgs = iface.encodeDeploy([0n, 100n, ''])
	const fullBytecode = bytecode.object + constructorArgs.slice(2)

        const salt = keccak256('0x00')
	const initCodeHash = keccak256(fullBytecode)
	const contractAddress = getCreate2Address(entryPointAddress, salt, initCodeHash)

	console.log(contractAddress)

	const tx = await smartAccount.sendTransaction({
		chainId: sepolia.id,
		data: fullBytecode as any,
	})

	console.log(tx)
}

deploy()

Thank you

btw here's the tx example if it's helpful 0x6348eb161ee26a582e6c7a0e928c1730b5610965bf8190df1e99de4c8ba5dcd6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions