Create Your Own Bitcoin (BTC) Exchange in 1 Hour! - YouTube

Channel: unknown

[3]
Hey guys! this is Karolis! I am a software engineer at n.exchange
[9]
For those who are not familiar with us, we are a fairly new (we've launched on September 2017)
[14]
cryptocurrency exchange. we hold zero balance and we have really strong values
[20]
of transparency and openness. As a result, as you might already know, we decided to
[28]
make our front end open source and our back-end open for anybody to use. You
[35]
can find our front end on GitHub. Just copy this URL I will also
[42]
put it in my description (of the video). as you can see it's written in react but if you don't know react don't worry.
[48]
For the basic changes for your own exchange, you don't really have to know react
[54]
you can just change it's like changing at HTML
[62]
but if you want to do any more complicated modifications you might want to take a course in react
[65]
or learn how Redux and react work in general.
[74]
we also have an open back-end API which you can find if you go to our website and click on API Docs
[80]
it will get you to our documentation
[84]
it's in 'apiary'. You can see all the endpoints here so let's see this one
[90]
it allows it to get all the currencies which we exchange or they get the latest ticker,
[96]
which shows you the latest price of a given pair. So let's say if you trade
[101]
Bitcoin for Litecoin it will show you what each Bitcoin is worth in Litecoin.
[108]
Probably, the most interesting endpoint for you is the referrals endpoint -
[113]
which allows you to set your own referral fee and get your own referral code.
[120]
I will show you how it works later but now that we have our front-end open-sourced and ready,
[128]
and we have a back-end where you can set your own referrals
[133]
you can set up your own exchange in less than one hour(I hope)
[139]
and I will show you how to do it in this tutorial. So let's get started -
[145]
So, we will start setting up the exchange by cloning our front-end repository
[151]
you can find the link for our GitHub repository in the description
[156]
I also assume that you know what 'git' and what cloning means - and
[162]
If you do let's copy the URL and clone the project. Just like that!
[168]
So, While it downloads let me quickly show you what is the basic structure of our project.
[176]
We have the 'config' directory, it contains the basic configuration files for 'webpack.js'
[183]
and for testing - just basic configuration. The 'public' folder contains all the publicly accessible assets
[189]
like favicons, index.html file in the scripts.
[195]
We just have three files 'test', 'build' and I forgot - and 'start' so we suggest NPM
[204]
scripts which you type in your terminal like 'npm start' and it will start the
[209]
project, so you are not going to have to change that at all and then we have this
[215]
source (src) directory which is where you're gonna spend the most of your time - most
[219]
likely - we have these 'actions' and 'reducers' folders which the logic for the
[226]
redux stuff then we have this 'components' directory for the react components. We
[233]
have a 'css' - which has a lot of files split based on the component and it's
[241]
written in 'scss' but you can always change that - and then we have a 'fonts'
[247]
images(img) and we have this JavaScript (js) folder which contains the libraries - on
[252]
which- some of the libraries - on which the project depends - which are not installed
[257]
as 'npm modules'. So that's kind of it let's see if the project has been -
[264]
downloaded - yes it has so the next step is to download
[269]
- now the next step is to go into our 'repository' and install all the
[276]
dependencies on which the project depends on(npm install changed to yarn install) It doesn't have that many - it's
[281]
just basically 'babel.js' for transpilation. 'axios' for HTTP transmission - like
[289]
making HTTP requests 'jQuery', 'lodash' 'moment.js ' for dealing with dates just the
[297]
basic stuff and the 'Redux' off course. So it will take some time to install. So let
[303]
me get back to you once that's done. Okay so all the 'npm modules' have been
[309]
installed - and here we can see this 'node- modules' directory - so now what we can do
[316]
is actually start our project and see how it works. So it's still loading - why
[330]
is it still loading? Okay here we are so it's basically what you should see is almost
[340]
the same as on what you can see if you go to nexchange.io (n.exchange) because it's
[346]
basically - it's the same so you probably want to delete all these and
[355]
change 'About us'. You might want to change the background picture, change the
[359]
description, the logo you might want to change your FAQ. So let me show you how
[367]
to do that. So, In order to change the content like the 'About' section or images
[374]
and stuff like that - We need to open the code for our Repository. So let's
[382]
navigate there. Okay, here we go and as I mentioned previously all the
[395]
React components are located at the 'source' and then at the 'components' folder
[401]
and as you can see there are a lot of them and I try to name them as
[405]
descriptive as possible - so let's say 'About' for the 'About Us' section the
[412]
component is called 'About' and you can see right here the content for - we don't
[418]
have any sophisticated CMS at the moment (content management system) - we just hard
[425]
code our content like that and this is what you can do as well. So let's say
[430]
instead of nexchange (n.exchange) you can put funchange or something like that, and then
[437]
you can obviously delete all these team members because we are not going to be a
[443]
part of your team - but you can always change the name like the title, the
[448]
country and add with social links. But for now I am just going to delete them
[455]
and that's it. Let's see how that looks - Yeah - so the same for the FAQ section
[466]
let's see here we go - there's a lot of questions and answers here. You can delete
[474]
any of them, which you don't need and you can add any of them, which you think
[479]
would be useful. So this is how it goes for a background picture you can go to
[486]
'hero.js' - which is the component that contains this entire section and
[494]
the hero image - let's see you can inspect - you can inspect where the image is set
[500]
it's set in the #hero and that's gonna be contained in the 'hero.scss'
[510]
file and then you can change the background picture here - which is located
[514]
in the images directory. So obviously you're gonna need some CSS some HTML
[520]
skills - but this is nothing extraordinary and nothing that you cannot figure out
[526]
especially if you have some background in programming. So I think this is all
[533]
I'm going to show you in terms of the Front End. Now let's get
[538]
started with the Back End. So in regards the Back End - the main thing we want to
[545]
discuss is how to obtain your own 'Referral token' and how to use that in
[550]
your own Exchange! - so the way we have done it for now is that you have to make
[555]
an order of any size so I'm buying some Ether with Bitcoin. I execute that order
[561]
and then if you scroll down you can see this referral link you can send this
[568]
link to your friends and if they use it and make a 'order' later you will get a
[574]
commission fee - But you can also copy this part, so basically anything after
[580]
ref equals '=' and then if you search for 'fileconfig.js' you will see this
[587]
'referral' code key and at the moment it's null but you can set it to your own
[594]
'Referral Code'. So now any time Back End makes a call like if you if the Front
[600]
End makes a call to the Back End - yeah it will also always add this referral
[606]
code and then our Back End can check if the referral code is set and if it is it
[612]
can accumulate your Commission. To see how that works - let's go to 'Referrals.js'
[619]
and here in this part we are checking if 'config.REFERRAL_CODE ' is set and if
[627]
it is, we use it we set the header to 'x-referral-token' and then we execute our
[635]
Ajax request. You don't have to understand how it works - but to put it
[641]
short - if you set the referral code in your configuration file anytime the
[648]
front-end makes an HTTP request - it will attach this referral token header.
[654]
Now let's discuss shortly how the Commissions work. For September (2017) since we
[662]
are newly opened. Any time a new user makes a transaction you're gonna
[667]
get a commission of $5! - but after that you will be able to set
[673]
your own fees on top of our base fees - and the planned base fees at the moment
[679]
are 0.5%. So you can add anything on top of that and then you will get paid and
[687]
you will get paid to whatever wallet you set as a withdraw address in your
[694]
transaction. So let's say if our transaction was this and you set and you
[703]
got the 'referral token' from here and you set the destination address as this
[708]
then any time we want to pay out the Commission we will send it to this
[713]
address in Ether. So if you want to get paid in Bitcoin you should buy some
[720]
Bitcoin from us so that the receive address is Bitcoin address. I hope that's
[728]
clear and if you have any questions let me know in the comments. If this tutorial
[736]
gets more popular - we will make a new version perhaps more more like advanced
[742]
more comprehensive. We will go through perhaps more detail in how everything
[748]
works. Now the only step left for you to have your own exchange is to set it up -
[755]
to set up a domain. So all you need to do is set up this entire repository
[763]
somewhere on the server. What you will have to do is run 'npm run build' and copy
[771]
paste the files and that's it. It's really really simple so I hope you liked
[775]
it and I'll see you next time!