Smart Contract Project: Javascript Implementation of Token Management

Verified

Added on  2023/06/13

|8
|671
|314
Project
AI Summary
This project provides a basic smart contract written in Javascript, focusing on token management. The contract includes three primary functions: depositToken, withdrawToken, and getToken. The depositToken function adds tokens to a specified address, while the withdrawToken function allows for the withdrawal of tokens from an address. The getToken function retrieves the token balance for a given address. The contract maintains an associative array linking addresses to integer token values, determining a client's authorization to utilize specific services based on their token balance. Instructions are provided for running the smart contract using the online Remix IDE or locally with Truffle, requiring an Ethereum client like Mist. The project concludes by detailing the functionality of each function and referencing relevant literature on smart contracts and online identity management. Desklib offers a range of similar solved assignments and past papers for students.
Document Page
Running Head: SMART CONTRACT 1
Smart Contract
Institution
Date
Name
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
SMART CONTRACT 2
This is a Smart contract that is simple. It is mainly designed using Javascript. It contains
three main functions which are: withdraw Token, depositToken, and get Token. The
depositToken function is able to add tokens to a given address. The withdrawToken function on
the other hand allows for the withdrawal of money from a specific address (Buterin, 2014). The
getTokens function will retrieve the token numbers that can be found for new addresses. This
simple contract keeps an associative array of addresses and integers. This smart contract will
keep an associative array of addresses and integers. Each address will be related with various
tokens that communicates if the client is recognized by this address can utilize a particular
service (tokens > 0) or not (tokens == 0).
For you to easily run the Smart Contract, just go to the online IDE which is on the link
below: https://remix.ethereum.org. If you prefer the dependencies and stuff, please do this;
Step one: $ npm install -g truffle (this installs truffle)
Step 2: Create a folder and go to the folder
Step 3: Inside your folder, Paste the Source code which I provided.
Step4: to compile, do run (truffle compile) on the terminal opened in the project folder
To View, the Smart Contract, you will require the Etherium client. The etherium client
can be accessed from the link here: https://www.ethereum.org/ (Yasin & Liu, 2016).
You should also download the most recent variant of Mist for your framework from this
connection https://github.com/ethereum/mist/releases/. Mist is an extraordinary sort of program,
a conveyed application program, with an implicit Ethereum wallet framework that can interface
with any system.
Document Page
SMART CONTRACT 3
Begin Mist. As it recognizes that an IPC record in the default area is being utilized, it
associates with your private system/network. Once the UI shows up, tap the Ethereum Wallet tab
on the left, and tap the CONTRACTS catch in the upper right corner:
NOTE: Before using MIST, you must retrieve two elements from our deployed contract.
Its Address and the Application Binary Interface. This is achieved by going into the truffle
console as shown below:
Document Page
SMART CONTRACT 4
Choose “WATCH CONTRACT” then type into the forms.
Give a self-assertive name for the agreement, as "SmartToken"
Enter the agreement address recovered from the Truffle support (SmartToken.address)
Enter the ABI (without encasing the quotes) recovered from the Truffle.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
SMART CONTRACT 5
The contract is now visible on Mist:
Document Page
SMART CONTRACT 6
Testing our Contract
Finally, we can watch events triggered:
Document Page
SMART CONTRACT 7
Conclusion
The constract we have created is mainly sourced at the ‘smarttoken.sol’ file. It consists of
three functions. Namely, WithdrawToken, DepositToken and GetToken functions.
The depositToken function: This function is able to add tokens to a given address. For this case, I
am using the address “”
The withdrawToken function has the role of withdrawing tokens from a specific or given
address.
The getTokens function is now able to retrieve all the available tokens for a given address
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
SMART CONTRACT 8
References
Buterin, V. (2014). A next-generation smart contract and decentralized application
platform. white paper.
Yasin, A., & Liu, L. (2016, June). An online identity and smart contract management system.
In Computer Software and Applications Conference (COMPSAC), 2016 IEEE 40th
Annual (Vol. 2, pp. 192-198). IEEE.
chevron_up_icon
1 out of 8
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]