0

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

1 Answer 1

0

I don't believe ERC1155 is supported in 0xV2 forwarder contract. The good news is that we've recently shipped ERC721, ERC1155 and ETH buying support in 0x v4.

A developer friendly, community developed package called Trader SwapSDK can be found here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.