bcnmy / biconomy-client-sdk

Biconomy SDK is a plug & play toolkit for dApps to build transaction legos that enable a highly customised one-click experience for their users
MIT License
76 stars 78 forks source link

[BUILD] #545

Closed HarukiKondo closed 3 months ago

HarukiKondo commented 3 months ago

Issue Summary

Faild to send userOp

Error Logs & Messages

I want to burn an NFT generated from a Thirdweb template using Bincomy.

I successfully created a SmartWallet by following the documentation.

However, I encountered the following error when trying to send the user operation to burn the NFT.

ERROR   Error occurred when sending UserOp: SizeExceedsPaddingSizeError: Hex size (65) exceeds padding size (64).

Version: viem@2.17.10
    at padHex (/var/task/index.js:189065:11)
    at encodeBytes (/var/task/index.js:190115:16)
    at prepareParam (/var/task/index.js:190036:12)
    at prepareParams (/var/task/index.js:190010:25)
    at encodeAbiParameters (/var/task/index.js:189998:26)
    at _BiconomySmartAccountV2.getSignatureWithModuleAddress (/var/task/index.js:247367:12)
    at _BiconomySmartAccountV2.signUserOp (/var/task/index.js:247362:115)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _BiconomySmartAccountV2.sendUserOp (/var/task/index.js:247406:15)
    at async sendUserOp (/var/task/index.js:247614:28) {
  details: undefined,
  docsPath: undefined,
  metaMessages: undefined,
  shortMessage: 'Hex size (65) exceeds padding size (64).',
  version: 'viem@2.17.10'

my code is here.

export const sendUserOp = async (
  smartWallet: any, 
  tx: txData
) => {
  try {
    console.log('========================================== [SEND USEROP START] =============================================')
    console.log("build userOp:");

    const userOpResponse = await smartWallet!.sendTransaction(tx, {
      paymasterServiceData: { mode: PaymasterMode.SPONSORED },
    });
    const { transactionHash } = await userOpResponse.waitForTxHash();
    console.log("Transaction Hash", transactionHash);

    // get receipt
    const userOpReceipt = await userOpResponse.wait(5);
    console.log("userOpReceipt", userOpReceipt);
    console.log('========================================== [SEND USEROP END] =============================================')

    return userOpReceipt;
  } catch (err: any) {
    console.error("Error occurred when sending UserOp:", err);
    return null;
  }
};

Environment & Tools

"@biconomy/account": "4.1.1", "viem": "2.9.28", "@thirdweb-dev/sdk": "^4.0.35",

Code of Conduct

HarukiKondo commented 3 months ago

Here is the code for generating the encoded data.

    const sdk = await createThirdWebSdk(TW_SECRET_KEY!, keyId);
    // get contract info
    const contract = await sdk.getContract(NFT_CONTRACT_ADDRESS);

    const encodeData = encodeFunctionData({
      abi: contract.abi,
      functionName: "burn",
      args: [tokenId],
    });

    const tx:TxData = {
      to: NFT_CONTRACT_ADDRESS, 
      data: encodeData
    }

    const receipt = await sendUserOp(smartWallet, tx);
VGabriel45 commented 3 months ago

Hi @HarukiKondo can you please update to latest version of the Biconomy SDK and try again ?

Maybe you can share how you are creating the "smartWallet" as well.

HarukiKondo commented 3 months ago

@VGabriel45 Thank you !!

This problem has been solved!