Solana Anchor: src.toTwos or src.toArrayLike is not a function

This is a quick debugging post for development with https://github.com/project-serum/anchor

If you’re getting the error message

TypeError: src.toTwos is not a function

or

TypeError: src.toArrayLike is not a function

then you might have forgotten to turn your number into a Big Number

use

new anchor.BN() to parse your existing number into a Big Number, and the error should go away.

--

--

Technical Instructor and Software Engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store