question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create encoded data

See original GitHub issue

Problem

I cannot get encoded data with a struct param in the test code below.

// TEST CODE

const functionArgs = [
    xxx,
    yyy,
    {
        x: x,
        y: y
    }
]
// console.log(functionArgs.length) => 3

const abi = compiledJSON.abi
const iface = new ethers.utils.Interface(abi)

// console.log(iface.functions.targetFunction) =>
   ...
   inputs:
   [ { internalType: 'string', name: 'title', type: 'string' },
     { internalType: 'string', name: 'name', type: 'string' },
     { components: [Array],
       internalType: 'struct Struct.Str',
       name: 'str',
       type: 'tuple' } ], ...

const calldata = iface.functions.targetFunction.encode(...functionArgs) // Error

Error Message

Error: missing argument in interface function targetFunction (count=2, expectedCount=3, version=4.0.47)

Version

ethers: 4.0.47 solc: 0.5.16 truffle: 5.1.9

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nphsucommented, Apr 27, 2020

Oh, sorry when changing ...functionArgs into functionArgs, then it works. Thank you for your reviewing!

0reactions
nphsucommented, Apr 28, 2020

Thank you very much for your kindness 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot create a Parse.File without valid data URI's or ...
It happens when new Parse.File(fileName, { base64 }) is called. Is there something i am doing wrong, how can i work around this?...
Read more >
How can I fix the UTF-8 error when bulk uploading users?
Answer. This error is created when the uploaded file is not in a UTF-8 format. UTF-8 is the dominant character encoding format on...
Read more >
Choose text encoding when you open and save files
Choose an encoding standard when you open a file · In Control Panel, click Add or Remove Programs. · In the Currently installed...
Read more >
Base64 encoding: What sysadmins need to know
Fundamentally, Base64 is used to encode binary data as printable text. ... the original binary cannot be divided into a 24-bit sequence.
Read more >
Base64 Encode and Decode From Command Line
For encoding data, Base64 uses only alphabet, number and = symbol. For instance, c2FtcGxlCg== is a valid encoded data while b?HV3.Zh2J== is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found