Fork a Uniswap DEX

Jeff P
5 min readJan 15, 2023

--

First we’ll download CRANQ to our desktop—

next we’ll create a blank project:

you should see this:

The two circles are nodes. CRANQ nodes have either outputs..

Or they have inputs…

CRANQ has nodes for all sorts of things, but for the purpose of the Uniswap Fork, let’s look for Uniswap nodes. Click on the plus sign to add nodes…

search for uniswap…

We are going to need both the “Factory Compiler” and the “Router Compiler” — drag both of these to the main window….

Next, drag the “Factory deployer” and the “Router deployer” onto the window….

I recommend you re-arrange your nodes like the following image as it will be easier…

now click on the output port name of “compiled factory contract” on the Factory Compiler, and then drag the line to connect it to the input port name of “Factory contract” on the Factory Deployer node….

Do the exact same thing for the Router Compiler….

Drag start to the Factory compiler…

Now search for a “Store” node, and add it to the main window..

Next click on the config input of the factory deployer node, and show the JSON config….

Highlight the config data, then press CTRL+C to copy it…

Now click on the “data” input port of the store node, and then paste the JSON code you just copied by pressing CTRL+V

This JSON object currently has three key:value pairs. We need a fourth one for Network, so let’s add in the following line, so that the entire JSON code should read as follows:

{
"providerUrl": "",
"privateKey": "",
"accountAddress": "",
"network": "goerli"
}

Next go to the CRANG menu, and go into “help” -> “Open CRANQ folder” which will open the folder for your project on your desktop

create an empty .env file in this folder. The simplest way to do this is to right-click in the window, and go to new -> text document

then rename this the .env

If it worked, the .env file icon will have changed…

Now connect the data output of store, to the config input of factory deployer…

Let’s now grab a couple more nodes… Grab a “multiplexed events logger node”….

Also grab a “logger with message” node…

Place them both to the right of the factory deployer node…

We want to connect the “events output” of factory deployer to the input of the “multiplexed event logger” node, and we want to connect the “error” output of factory deployer to the “data” input of the “logger with message” node.

Now click on the “message” input port of the “logger with message” node, and then give this a string value (in quotes) of “factory compilation error”

Next connect the “confirmation” output of factory deployer, to the input of your original log node…

Let’s also connect the start node to the “read” input of store node…

to be continued

--

--

Jeff P
Jeff P

Written by Jeff P

I tend to write about anything I find interesting. There’s not much more to it than that really :-)

Responses (1)