I am using 0x protocol V2 forwarder contract. And it's fine to exchange ERC721 token through function marketBuyOrdersWithEth, yet when I tried to exchange ERC1155 tokens, it keeps showing the [error][1] COMPLETE_FILL_FAILED.
I think the params should be correct. So I was wondering if V2 is able to exchange ERC1155 token.
const handleSign = async () => {
const { orderHashUtils, assetDataUtils, signatureUtils } = await import(
"@0x/order-utils"
)
const { ecSignOrderAsync } = signatureUtils
const erc1155Data = assetDataUtils.encodeERC1155AssetData(
"0xA8009103f9a4f297BBC313B74b6A8f46d9323E8E",
[BigNumber.from(1)],
[BigNumber.from(1)],
"0x0000000000000000000000000000000000000000000000000000000000000000",
)
const erc20Data = assetDataUtils.encodeERC20AssetData("0xc778417e063141139fce010982780140aa0cd5ab")
const ts = Date.now()
const salt = ts.toString()
const expirationTimeSeconds = Math.floor((ts + 60 * 60 * 1e3) / 1e3).toString()
const order = {
makerAssetAmount: "1",
makerAssetData: erc1155Data,
takerAssetAmount: "1",
takerAssetData: erc20Data,
makerAddress: account,
exchangeAddress: process.env.EXCHANGE,
salt,
expirationTimeSeconds,
feeRecipientAddress: AddressZero,
takerAddress: AddressZero,
senderAddress: AddressZero,
makerFee: "0",
takerFee: "0",
}
const zeroXProvider = await import("@0x/subproviders").then(
({ MetamaskSubprovider }) => new MetamaskSubprovider(provider))
const { signature } = await ecSignOrderAsync(
zeroXProvider,
order,
account,
)
setSign(signature)
setOrder(order)}
}
const fillOrder = () => {
const fContract = new web3.eth.Contract(fABI, process.env.FORWARDER)
const args = [
[order],
1,
[sign],
[],
[],
0,
AddressZero,
]
// marketBuyExactAmountWithWeth
fContract.methods
.marketBuyOrdersWithEth(...args)
.send({ from: account, value: web3.utils.toWei("1", "ether") })
.on("transactionHash", (hash) => {
console.log(hash)
})
.on("receipt", (receipt) => {
console.log(receipt)
})
.on("error", (error) => {
console.log(error)
})
.catch(error => {
console.log(error)
})
}
Thanks for your answering! [1]: https://rinkeby.etherscan.io/tx/0x810ef051ebae1a18e0887410c1a273cb6072b04ea262bfd9953065d932a620ca