Search code examples
blockchainethereum

0x Protocol Error: No default contract addresses found for the given network id


I got these errors while I was running 0x Protocol backend launch kit.

WARNING: Multiple definitions for safeTransferFrom
Error: No default contract addresses found for the given network id (137). If you want to use ContractWrappers on this network, you must manually pass in the contract address(es) to the constructor.
    at Object._getDefaultContractAddresses (/home/ubuntu/smartdex-backend/node_modules/@0x/contract-wrappers/src/utils/contract_addresses.ts:10:15)
    at new ContractWrappers (/home/ubuntu/smartdex-backend/node_modules/@0x/contract-wrappers/src/contract_wrappers.ts:118:19)
    at new OrderBook (/home/ubuntu/smartdex-backend/ts/lib/orderbook.js:96:34)
    at new Handlers (/home/ubuntu/smartdex-backend/ts/lib/handlers.js:64:27)
    at /home/ubuntu/smartdex-backend/ts/lib/index.js:19:22

I forked this repository: github.com/0xProject/0x-launch-kit-backend


Solution

  • This error is caused because of the dependency problem. The 0x Protocol launch kits are using "@0x/contract-addresses" package for contract wrapper.

    This is a very tricky solution.

    Clone the 0x-launch-kit-backend (v2) in the same parent directory with 0x-monorepo. Don’t install the dependencies yet!

    Open yarn.lock file and replace all line "@0x/contract-addresses" "^3.0.1" with "@0x/contract-addresses" "file:../0x-monorepo/packages/contract-addresses".

    Now install the dependencies with –-frozen-lockfile flag

    $ yarn install --frozen-lockfile

    Then it will fix the issue.