changed 2 years ago
Published Linked with GitHub

Bug with minting ERC721 token in the initial transaction using Smart Contract Wallets

When we are trying to mint an NFT in the first transaction which deploys the wallet also, one of the internal transactions is failing(which is for minting the ERC 721 Token): https://mumbai.polygonscan.com/tx/0x41bfb9790263af99b9c37f0ebb3204ad4dcc8c50ac76112fcc4d5b74ebb8b375

Here is our verified smart contract proxy: https://mumbai.polygonscan.com/address/0x11e07aF8ac20a75727132AD8A3b0803D14fd6f4A#code

Here is the singleton contract: https://mumbai.polygonscan.com/address/0x66D61387800d62695Df91A2018f54Eec3b832a34#code

This transaction is also containing the init code to deploy the wallet. In the above transaction, we can see that the final transaction is failing and every other transaction is getting succeeded.

Function: handleOps((address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[], address)

User Operation sent
#	Name	Type	Data
0	ops.sender	address	0x11e07aF8ac20a75727132AD8A3b0803D14fd6f4A
0	ops.nonce	uint256	0
0	ops.initCode	bytes	0xe5b37ba779d21d8ab5a2dfa2dfdba7a41f3adc77ec9e80bb00000000000000000000000066d61387800d62695df91a2018f54eec3b832a340000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e4c9e8f18300000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000fcb4cae05f6f47ef8edef98375cd5180e03ad5750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000576a174d229e3cfa37253523e645a78a0c91b5755923b4d6becc71777b65c4f542066be8e0398bb488bc29aa452a2461749ace80438ec0ae49d5a6624812349345b6b1ae80c2b2a4b47919deb9c9222e2a57ea70000000000000000000000007efd1b4c0469f43abbe1a5946ebd4a1734d1b79e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000823d2fcec8a13ceada1922d474071716aa25b47a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0	ops.callData	bytes	0x2694bd1d000000000000000000000000bd48a789c4dd746ce572dc5fdfe20f8fc638cf06000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002440d097c300000000000000000000000011e07af8ac20a75727132ad8a3b0803d14fd6f4a00000000000000000000000000000000000000000000000000000000
0	ops.callGasLimit	uint256	22512
0	ops.verificationGasLimit	uint256	3000000
0	ops.preVerificationGas	uint256	54864
0	ops.maxFeePerGas	uint256	1695000032
0	ops.maxPriorityFeePerGas	uint256	1695000000
0	ops.paymasterAndData	bytes	0x
0	ops.signature	bytes	0xb9e789bac002b730bea63ee2ded130aef38d5b9d930f39d3216bbb2af2680e4c2c08e45426d0bc6c010785ac461a6c2e1f2c088884e26db647164c60474e3b155d24cef6d0f8b4120475f5bc54b7da75de9738b8c29f27e002fb0e5dd00271ff830d90776993ff8bed5aa21535e056c1679d7201244d5ad991357637e4bd1131
2	beneficiary	address	0xd21934eD8eAf27a67f0A70042Af50A1D6d195E81

If I repeat the transaction it gets succeed
txn hash: https://mumbai.polygonscan.com/tx/0xff8faca09868f564fedd3c3d2384b7fc7125ff11fa291dad7e15aa0c73e25087

Function: handleOps((address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[], address)

User Operation 
#	Name	Type	Data
0	ops.sender	address	0x11e07aF8ac20a75727132AD8A3b0803D14fd6f4A
0	ops.nonce	uint256	0
0	ops.initCode	bytes	0x
0	ops.callData	bytes	0x2694bd1d000000000000000000000000bd48a789c4dd746ce572dc5fdfe20f8fc638cf06000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002440d097c300000000000000000000000011e07af8ac20a75727132ad8a3b0803d14fd6f4a00000000000000000000000000000000000000000000000000000000
0	ops.callGasLimit	uint256	114228
0	ops.verificationGasLimit	uint256	3000000
0	ops.preVerificationGas	uint256	49668
0	ops.maxFeePerGas	uint256	1864500034
0	ops.maxPriorityFeePerGas	uint256	1864500002
0	ops.paymasterAndData	bytes	0x
0	ops.signature	bytes	0x7317b70dcbae54a52a62c50687b8605a3ba40f4de159939d5c7c549515697bc5edd541ad403f9bc491230daca84658701bcd899ce696d6a17af0652069cec190b9d73a5c0cdc60dda08f9807fcee8e1df99bc6b9e5a1a26b08177a33ac822ce6a559e26f5456ba82ca6b573596c7645ef3c9e6cf0ffbcbd3beeef23eb2a5ee03
2	beneficiary	address	0xd21934eD8eAf27a67f0A70042Af50A1D6d195E81

I think that in the initial transaction, the wallet deployment is not complete and we call the SCW for checking that it is ERC721 compatible using the function

function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    } 

Our contracts are SAFE smart contract wallets and we are using the latest code from ETH infinitism for Bundler and Entry Point.

Select a repo