I'm using ethers.js to encode in ABI a IPFS hash provided by a text box on an html page, in order to save it on the blockchain. To do that, I have an input id'd as "ipfs-hash", called with a variable. An then, another variable which encodes it. Nevertheless, this last step doen't work, and when I try to take the hash from a variable the code breaks. However, the second variable seems to work fine when I change
INPUTHASH
variable for an actual value.
'Qm...'
const INPUTHASH = $('#ipfs-hash').html //Direct input from text box
const ABIOUTPUT = ethers.utils.defaultAbiCoder.encode([ 'string' ], [ INPUTHASH ] );
Solved! It was a problem with Jquery.js, not ethers.js.
const INPUTHASH = $('#ipfs-hash').val();