Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation incorrectly reports ContractFunctionExecutionError instead of ContractFunctionRevertedError #3020

Closed
1 task done
TilakMaddy opened this issue Nov 18, 2024 · 3 comments
Labels
needs reproduction Misc: Needs Reproduction

Comments

@TilakMaddy
Copy link

Check existing issues

Viem Version

2.21.40

Current Behavior

Code

try {
    const simulation = await this.client.simulateContract({
        abi: faucetAbi,
        address: FAUCET_ADDRESS,
        functionName: 'mint',
        chain: arbitrum,
        account: this.address,
        args: [],
      });
    console.log(simulation);

    const hash = await this.client.writeContract({
        abi: faucetAbi,
        address: FAUCET_ADDRESS,
        functionName: 'mint',
        chain: arbitrum,
        account: this.address,
    })
    console.log(hash)
    await this.readTokenBalance()
} catch (err) {
    console.log(err);
    if (err instanceof BaseError) {
        const revertErr = err.walk(err => err instanceof ContractFunctionRevertedError);
        if (revertErr instanceof ContractFunctionRevertedError) {
            const errorName = revertErr.data?.errorName ?? ''
            console.log(errorName);
        }
    }
}
ContractFunctionExecutionError: Data size of 4 bytes is too small for given parameters.

Params: ()
Data:   0x7ec6cd58 (4 bytes)
 
Contract Call:
  address:   0x16D218938416d58C58CaC586D57F27fD8CAfBec1
  function:  mint()
  sender:    0x72598C4C5cFD3685E2F908FC3D3B9DF7320149D4

Docs: https://viem.sh/docs/contract/simulateContract
Version: [email protected]
    at getContractError (chunk-TZAFQCCV.js?v=3abc04ce:889:10)
    at simulateContract (chunk-TZAFQCCV.js?v=3abc04ce:4904:11)
    at async WalletConnection.mintTokensFromFaucet (wallet.svelte.ts:125:19)
    at async HTMLButtonElement.handleMintRequest [as __click] (+page.svelte:18:25)Caused by: AbiDecodingDataSizeTooSmallError: Data size of 4 bytes is too small for given parameters.

Params: ()
Data:   0x7ec6cd58 (4 bytes)

Version: [email protected]
    at decodeAbiParameters (chunk-ZF6VVK62.js?v=3abc04ce:2661:11)
    at decodeFunctionResult (chunk-D4AFAUKJ.js?v=3abc04ce:1482:18)
    at simulateContract (chunk-TZAFQCCV.js?v=3abc04ce:4884:20)
    at async WalletConnection.mintTokensFromFaucet (wallet.svelte.ts:125:19)
    at async HTMLButtonElement.handleMintRequest [as __click] (+page.svelte:18:25)

Expected Behavior

I'm unable to make sense of how 4 bytes is too small data size for an empty parametered function.

AbiDecodingDataSizeTooSmallError: Data size of 4 bytes is too small for given parameters.

Steps To Reproduce

No response

Link to Minimal Reproducible Example

No response

Anything else?

No response

@jxom
Copy link
Member

jxom commented Nov 18, 2024

Hard to tell what's going on without a minimal reproducible example, but likely your ABI expects an input for the "mint" function.

@jxom jxom added the needs reproduction Misc: Needs Reproduction label Nov 18, 2024
Copy link
Contributor

Hello @TilakMaddy.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@TilakMaddy
Copy link
Author

No, the mint function has no parameters.
I'll try to create a minimal reproducible example tomorrow and link it here

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants