I am trying to submit a Pair of Bytes in a contract call with Taquito but am receiving an error.
The contract interaction documentation does not go into exactly how to submit a Pair, but it does go into how to access a Map with a Pair as a key.
Based on that I arrived at the following code, but am still receiving an error.
Contract has a single entrypoint, run_test
, that accepts a Pair of Bytes, with the Bytes themselves being packed Strings.
This is the method used for packing the String (works fine when just sending Bytes instead of a Pair)
const packer = new MichelCodecPacker()
const packString = async stringData => {
const packedString = await packer.packData({
data: {
string: stringData,
},
type: {
prim: 'string',
}
})
return packedString
}
used in the call
const leftByteData = await packString('Left String')
const rightByteData = await packString('Right String')
contract.methods.run_test(
{ 0: leftByteData.packed, 1: rightByteData.packed }
).send()
Which is accepting the type
TPair(TBytes, TBytes)
The error I receive is
BytesValidationError: [4] Invalid bytes: [object Object] at BytesToken.isValid
// ... verbose stack trace info snipped ...
at Array.map (<anonymous>) {
value: {
'0': '05010000000b4c65667420537472696e67',
'1': '05010000000c526967687420537472696e67'
},
token: BytesToken {
val: { prim: 'bytes' },
idx: 4,
fac: [Function: createToken],
createToken: [Function: createToken]
}
}
Is it possible to send a Pair as a value in a contract call with Taquito, and if so how do you do it?