Categories
Cryptocurrency Ethereum Mastering Development

Deploy pre compiled bytecode using truffle migrations deployer api

I want to deploy pre-compiled Smart Contract bytecode using Truffle migrations. Specifically, it is the Uniswap V2 Factory contract.

In the Uniswap V2 documentation there is a cliffhanger, where they mention to use:

const UniswapV2FactoryBytecode = require('@uniswap/v2-core/build/UniswapV2Factory.json').bytecode

And then deploy it using Truffle (but do not include an example). However, I cannot get the deployment to work. Here is my migration script:

const UniswapV2FactoryBytecode = require('@uniswap/v2-core/build/UniswapV2Factory.json').bytecode
module.exports = function(_deployer, network, accounts) {
   _deployer.deploy(UniswapV2FactoryBytecode, accounts[0])
};

Note the UniswapV2Factory constructor requires a _feeToSetter address which is why I pass accounts[0] as a parameter.

When I run using truffle migrate --reset the following error is returned:

TypeError: contract.detectNetwork is not a function

Can anyone help point to a solution get this to work?

Leave a Reply

Your email address will not be published. Required fields are marked *