Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
Encode calldata for function with uint8 argument in ethers.js

I'm trying to encode calldata using ethers.js for the following function:

function myFunction(uint8,uint8,uint256,uint256,uint256)

My code sample:

let iface = new ethers.utils.Interface([
        "function myFunction(uint8,uint8,uint256,uint256,uint256)"
    ]);
let callData = iface.encodeFunctionData("myFunction", [
            0,
            1,
            0,
            0,
            ethers.constants.MaxUint256,
        ]);

As a result, I get following calldata:

0xc4bc81b30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

I guess, it starts with function selector (8 bytes), then arguments (only uints) and it's possible to see that uint8-arguments take up the same amount of space as uint256-arguments (64 bytes). As a result, call with this calldata fails. How to encode it correctly?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!