This is the third post in a series of tutorials on how to create a crypto exchange on the Ethereum blockchain. I'll leave links to previous posts at the end of this post. This series was inspired by a similar series by [Dapp University](https://www.youtube.com/channel/UCY0xL8V6NzzFcwzHCgB8orQ). The crypto exchange will contain a `buy/sell` feature and will have Ethereum and ERC20 token pairs. In the last post we started creating the smart contracts for our exchange, first we created the exchange smart contract and deployed it to the blockchain, though we have not done much in that respect. Also we created the smart contract for the token we will be trading against Ethereum and also deployed it to the blockchain. In this post we are going to continue with the smart contracts we created, we'll fine tune them till we get them to our desired states. #### More on the token smart contract After creating the token smart contract and deploying it to the blockchain, we need to run the command `truffle console` in our project terminal in order to retrieve certain information about the token we just created. Once the truffle development prompt comes on in the terminal, type following code to initialize the token as a variable. ``` token = await Token.deployed() ``` In order to view the full scope of the token in the console, type in the following code in your terminal and press `Enter` ``` token ``` You should get something identical to this image in the console.  Naturally, when creating the token smart contract all available tokens will be assigned to the account of the user who created and deployed the smart contract to the blockchain. We don't want that, so we are going to transfer the token from the previous user to the `Exchange` account which is where the tokens will be bought from. In the file `migrations/2_deploy_contracts.js`, replace the contents of the file with the following ``` const Token = artifacts.require("Token"); const Exchange = artifacts.require("Exchange"); module.exports = async function(deployer) { await deployer.deploy(Token); const token = Token.deployed() await deployer.deploy(Exchange); const exchange = Exchange.deployed() // transfer tokens to exchange account await token.transfer(exchange.address, '1000000000000000000000000') }; ``` Save the file and in the terminal, run the command ``` truffle migrate --reset ``` Once the migration is complete you should see a result like this in your console  We can confirm that our token has been truly transferred, in the terminal run the command ``` truffle console ``` In the resulting prompt type in the following code ``` exchange = await Exchange.deployed() ``` then, type in ``` exchange.address ``` You should get a result that displays the address of the Exchange smart contract in the terminal Next, type in ``` token = await Token.deployed() ``` In order to get the token balance of the exchange address, first type in the following code ``` balance = await token.balanceOf(exchange.address) ``` You can now check the balance by running the following code ``` balance.toString() ``` In your terminal you should see something like this  We have finally been able to transfer the tokens to the exchange account so that people can buy the tokens from the exchange when they create buy orders. Basically, our coins are ready to be purchased. In the next post we are going to be diving more into the inner working s of our exchange. #### Links to previous posts in this series - [Part 1](https://hive.blog/hive-175254/@gotgame/how-to-create-a-crypto-exchange-on-the-ethereum-blockchain-using-node-js-react-js-solidity-part-1) - [Part 2](https://hive.blog/hive-175254/@gotgame/how-to-create-a-crypto-exchange-on-the-ethereum-blockchain-using-node-js-react-js-solidity-part-2)
author | gotgame | ||||||
---|---|---|---|---|---|---|---|
permlink | how-to-create-a-crypto-exchange-on-the-ethereum-blockchain-using-node-js-react-js-solidity-part-3 | ||||||
category | hive-175254 | ||||||
json_metadata | {"tags":["neoxian","palnet","qurator","ocd","gems","gitplait","dblog"],"image":["https://i.ibb.co/F3QLxHc/new.png","https://i.ibb.co/mN3558V/new.png","https://i.ibb.co/477yPmm/new.png"],"links":["https://www.youtube.com/channel/UCY0xL8V6NzzFcwzHCgB8orQ","https://hive.blog/hive-175254/@gotgame/how-to-create-a-crypto-exchange-on-the-ethereum-blockchain-using-node-js-react-js-solidity-part-1","https://hive.blog/hive-175254/@gotgame/how-to-create-a-crypto-exchange-on-the-ethereum-blockchain-using-node-js-react-js-solidity-part-2"],"app":"hiveblog/0.1","format":"markdown"} | ||||||
created | 2020-08-06 13:36:27 | ||||||
last_update | 2020-08-06 13:36:27 | ||||||
depth | 0 | ||||||
children | 2 | ||||||
last_payout | 2020-08-13 13:36:27 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.214 HBD | ||||||
curator_payout_value | 0.274 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 4,052 | ||||||
author_reputation | 23,969,707,386,372 | ||||||
root_title | "How to create a crypto exchange on the Ethereum blockchain using Node.js/React.js/Solidity - Part 3" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 98,925,847 | ||||||
net_rshares | 1,973,422,361,167 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
chris4210 | 0 | 229,021,348,241 | 26.5% | ||
justtryme90 | 0 | 1,021,022,767 | 26.5% | ||
mammasitta | 0 | 147,626,988,564 | 26.5% | ||
nascimentoab | 0 | 1,226,587,905 | 26.5% | ||
sc-steemit | 0 | 53,283,468,311 | 26.5% | ||
dashfit | 0 | 5,799,139,905 | 26.5% | ||
hoboway | 0 | 612,672,687 | 26.5% | ||
sixexgames | 0 | 2,569,258,783 | 26.5% | ||
more4less | 0 | 7,484,451,787 | 53% | ||
freedomcoin | 0 | 5,096,668,165 | 51% | ||
friesennerz | 0 | 1,277,272,305 | 26.5% | ||
firstamendment | 0 | 11,205,655,674 | 10% | ||
gunthertopp | 0 | 229,164,228,536 | 5.3% | ||
makrotheblack | 0 | 2,055,032,472 | 26.5% | ||
blessedman939 | 0 | 10,888,165,459 | 26.5% | ||
blackmagic | 0 | 1,925,069,793 | 53% | ||
minnowbooster | 0 | 813,451,402,945 | 9% | ||
pixelfan | 0 | 11,696,465,187 | 2% | ||
colmedwardsphoto | 0 | 2,794,097,716 | 53% | ||
jasonshick | 0 | 56,427,964,394 | 10% | ||
pearlumie | 0 | 4,206,438,711 | 26.5% | ||
yajirang | 0 | 807,172,007 | 26.5% | ||
ogejoy | 0 | 581,427,080 | 50% | ||
tezzmax | 0 | 1,891,296,172 | 15.9% | ||
tolarnee | 0 | 574,547,143 | 26.5% | ||
bcrafts | 0 | 1,221,149,720 | 10.6% | ||
airhawk-project | 0 | 1,176,338,657 | 53% | ||
marvel1206 | 0 | 8,209,304,372 | 26.5% | ||
hrhmikelength | 0 | 612,322,664 | 26.5% | ||
berkaytekinsen | 0 | 1,099,140,315 | 53% | ||
stephennevets | 0 | 3,086,402,706 | 26.5% | ||
akumar | 0 | 1,308,810,919 | 53% | ||
azmielbanjary | 0 | 1,523,063,375 | 26.5% | ||
benie111 | 0 | 2,032,475,481 | 21.2% | ||
eprolific | 0 | 1,112,891,115 | 53% | ||
irisworld | 0 | 1,641,756,953 | 26.5% | ||
airhawk-exchange | 0 | 1,052,447,389 | 53% | ||
iamowomizz | 0 | 859,450,113 | 100% | ||
preciousimo | 0 | 817,635,513 | 53% | ||
sportsconnect | 0 | 2,794,182,919 | 53% | ||
sunshinebear | 0 | 716,939,061 | 26.5% | ||
josevas217 | 0 | 44,196,405,595 | 20% | ||
botefarm | 0 | 1,286,738,868 | 50% | ||
payroll | 0 | 126,635,524,669 | 2% | ||
jacksondavies | 0 | 1,254,113,206 | 26.5% | ||
thomaskatan | 0 | 754,955,670 | 37.09% | ||
dawizy | 0 | 827,638,933 | 42.4% | ||
montanacellist | 0 | 1,678,881,882 | 26.5% | ||
yestermorrow | 0 | 3,082,038,631 | 7.95% | ||
cynicalcake | 0 | 670,998,088 | 26.5% | ||
laissez-faire | 0 | 33,254,439 | 100% | ||
babysavage | 0 | 53,511,398,687 | 100% | ||
jenniferjulius | 0 | 957,146,746 | 26.5% | ||
paololuffy91 | 0 | 919,196,753 | 21.2% | ||
predict-crypto | 0 | 1,887,795,535 | 1.06% | ||
topworlds | 0 | 1,282,238,837 | 39.75% | ||
pushpedal | 0 | 2,157,570,626 | 26.5% | ||
sirpee6 | 0 | 1,171,757,168 | 26.5% | ||
starbooks | 0 | 1,369,512,181 | 26.5% | ||
steemegg | 0 | 5,142,768,619 | 13.25% | ||
jtm.support | 0 | 1,879,605,194 | 26.5% | ||
hungryanu | 0 | 853,281,929 | 15.9% | ||
dwinf | 0 | 845,684,002 | 100% | ||
swirly | 0 | 2,979,318,431 | 26.5% | ||
dec-collector | 0 | 732,693,040 | 53% | ||
hyborian-strain | 0 | 603,004,398 | 7.95% | ||
contestcoin | 0 | 1,348,825,596 | 100% | ||
coinlogic.online | 0 | 813,991,625 | 26.5% | ||
tonimontana.neo | 0 | 12,628,250 | 1.59% | ||
vikas612 | 0 | 563,177,899 | 26.5% | ||
passthestixxx | 0 | 673,982,895 | 53% | ||
mengene | 0 | 1,351,457,233 | 26.5% | ||
senithegrapher | 0 | 894,195,639 | 26.5% | ||
maxwellelisha19 | 0 | 1,063,426,327 | 26.5% | ||
hf19 | 0 | 55,171,931,358 | 100% | ||
hivebootcamphub | 0 | 22,249,519,349 | 100% | ||
ayoyemi1 | 0 | 613,548,888 | 26.5% |
<div class="text-justify"> This is a very useful post for developers on the platform. We are sure it would go a long way to help them learn. Thanks for sharing. <center></center> [**The HiveBootcampHub Community**]( https://peakd.com/c/hive-109221) just selected and supported your article!!! **To get a stronger support from us, you can post your articles in [**our Community**]( https://peakd.com/c/hive-109221)** Feel free to [**Subscribe to our Community**](https://peakd.com/c/hive-109221/created) and [**Join our Discord Server**](https://discord.gg/t5YzPNg) as we’d be happy to have you with us! Cheers! <sub><center></sub></center> </div>
author | hivebootcamphub |
---|---|
permlink | re-gotgame-qepimo |
category | hive-175254 |
json_metadata | {"tags":["hive-175254"],"app":"peakd/2020.08.1"} |
created | 2020-08-07 18:42:27 |
last_update | 2020-08-07 18:42:27 |
depth | 1 |
children | 0 |
last_payout | 2020-08-14 18:42:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 936 |
author_reputation | 9,144,995,094,149 |
root_title | "How to create a crypto exchange on the Ethereum blockchain using Node.js/React.js/Solidity - Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,948,800 |
net_rshares | 0 |
Congratulations @gotgame! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) : <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@gotgame/upvotes.png?202008121902"></td><td>You distributed more than 61000 upvotes. Your next target is to reach 62000 upvotes.</td></tr> </table> <sub>_You can view [your badges on your board](https://hivebuzz.me/@gotgame) And compare to others on the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>
author | hivebuzz |
---|---|
permlink | hivebuzz-notify-gotgame-20200812t192105000z |
category | hive-175254 |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2020-08-12 19:21:06 |
last_update | 2020-08-12 19:21:06 |
depth | 1 |
children | 0 |
last_payout | 2020-08-19 19:21:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 619 |
author_reputation | 370,793,562,899,017 |
root_title | "How to create a crypto exchange on the Ethereum blockchain using Node.js/React.js/Solidity - Part 3" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 99,036,603 |
net_rshares | 0 |