I have the following solidity function that I'm calling from truffle:
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
if (!isOwner(to)) {
owners.push(to);
}
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
This is my call from truffle:
t = await i.safeTransferFrom(accounts[1], accounts[9], 0, "6666666666666666666", "", {from: accounts[1]})
But I'm getting the following error:
Uncaught:
Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.0.5)
at evalmachine.<anonymous>:1:11
at evalmachine.<anonymous>:2:49
at sigintHandlersWrap (vm.js:273:12)
at Script.runInContext (vm.js:140:14)
at runScript (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:328:1)
at Console.interpret (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:343:1)
at bound (domain.js:413:15)
at REPLServer.runBound [as eval] (domain.js:424:12)
at REPLServer.onLine (repl.js:817:10)
at REPLServer.emit (events.js:315:20)
at REPLServer.EventEmitter.emit (domain.js:467:12)
at REPLServer.Interface._onLine (readline.js:337:10)
at REPLServer.Interface._line (readline.js:666:8)
at REPLServer.Interface._ttyWrite (readline.js:1010:14) {
reason: 'invalid arrayify value',
code: 'INVALID_ARGUMENT',
argument: 'value',
value: '',
hijackedStack: 'Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.0.5)\n' +
' at lib_esm_Logger.makeError (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/logger/lib.esm/index.js:166:1)\n' +
' at lib_esm_Logger.throwError (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/logger/lib.esm/index.js:175:1)\n' +
' at lib_esm_Logger.throwArgumentError (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/logger/lib.esm/index.js:178:1)\n' +
' at lib_esm_arrayify (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/bytes/lib.esm/index.js:87:1)\n' +
' at BytesCoder.encode (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js:9:17)\n' +
' at /usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/abi/lib.esm/coders/array.js:49:1\n' +
' at Array.forEach (<anonymous>)\n' +
' at pack (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/abi/lib.esm/coders/array.js:43:1)\n' +
' at TupleCoder.encode (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js:19:16)\n' +
' at AbiCoder.encode (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/node_modules/@ethersproject/abi/lib.esm/abi-coder.js:82:1)\n' +
' at ABICoder.encodeParameters (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/lib/index.js:121:1)\n' +
' at /usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:439:1\n' +
' at Array.map (<anonymous>)\n' +
' at Object._encodeMethodABI (/usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:438:6)\n' +
' at /usr/local/Cellar/truffle/5.4.0/libexec/lib/node_modules/truffle/build/webpack:/packages/contract/lib/execute.js:182:1\n' +
' at runMicrotasks (<anonymous>)'
}
How to fix this?