A reward contract platform between manager and employee

In this project, we succeeded in creating a contract in which there is a manager and an array of employees. Addresses of the employees get stored in an array. Employees can enter into a contract by giving some ether (Minimum amount of ether is 0.01). (Ether is a cryptocurrency that is used as a transactional token that facilitates operations on the Ethereum network). 
The manager will reward the employee which has the maximum amount of ether (This has been set to random for now). The manager will reward some of his ether to an employee randomly, which will get added to the particular employee's account.

Our Contribution & Output

Back-end work

  1. Reward.sol

code-image
  • Here, “manager” is a variable that stores the address

  • Employee - an array that stores addresses of an employee

  • msg.sender - displays the address of the manager

  • Enter is a payable function. Here, payable means one can do a transaction. So, the person who pays more than .01 ether can get inside the contract.

code-image
  • Random will return the random value.

  • The winner transfers some amount of ether from the manager to the employee as a reward.

code-image
  • Modifier restricted() will get executed only when the address matches the manager’s account address. To be precise, it is the manager who can execute this.

  • Here, getEmployee() will return the addresses of the employee.

  1. inbox.test.js(test file)

code-image
  • We installed web3 and ganache packages.

  • Here, “abi” - gives the JSON code of a particular contract.

  • “evm” is - Ethereum Virtual Manager.

  • Also, we ran some Mocha tests to check whether the contract was running or not.

Output of Test file (inbox.test.js) in command prompt

code-image

Here, the green tick means all the mocha tests are running successfully. And if the tests are running, that means the contract is running successfully.

  1. deploy.js

code-imagecode-image

Output of deploy.js file (Contract gets deployed)

code-image

Front-end work

  1. web3.js(connects to MetaMask account)

code-image
  • Detects the Ethereum provider.

  • Detects the Ethereum network in which the user is connected to.

  • Get the user’s Ethereum account.

2. App.js

code-imagecode-imagecode-image
  1. Reward.js

code-imagecode-image

Technology Used

  1. Front-end - Reward-react

  • Reward.js (contains Ethereum account address and contract in JSON format)

  • app.js (executed contract)

  • web3.js (connected contract to MetaMask account)

  1. Back-end - Reward

  • Reward.sol (Contract)

  • compile.js (Solidity compiler (Solc) compiles the contract)

  • inbox.test.js (Mocha test js file)

  • deploy.js (deploys the contract from MetaMask account)

A reward contract platform between manager and employee

In this project, we succeeded in creating a contract in which there is a manager and an array of employees. Addresses of the employees get stored in an array. Employees can enter into a contract by giving some ether (Minimum amount of ether is 0.01). (Ether is a cryptocurrency that is used as a transactional token that facilitates operations on the Ethereum network). 
The manager will reward the employee which has the maximum amount of ether (This has been set to random for now). The manager will reward some of his ether to an employee randomly, which will get added to the particular employee's account.

Our Contribution & Output

Back-end work

  1. Reward.sol

code-image
  • Here, “manager” is a variable that stores the address

  • Employee - an array that stores addresses of an employee

  • msg.sender - displays the address of the manager

  • Enter is a payable function. Here, payable means one can do a transaction. So, the person who pays more than .01 ether can get inside the contract.

code-image
  • Random will return the random value.

  • The winner transfers some amount of ether from the manager to the employee as a reward.

code-image
  • Modifier restricted() will get executed only when the address matches the manager’s account address. To be precise, it is the manager who can execute this.

  • Here, getEmployee() will return the addresses of the employee.

  1. inbox.test.js(test file)

code-image
  • We installed web3 and ganache packages.

  • Here, “abi” - gives the JSON code of a particular contract.

  • “evm” is - Ethereum Virtual Manager.

  • Also, we ran some Mocha tests to check whether the contract was running or not.

Output of Test file (inbox.test.js) in command prompt

code-image

Here, the green tick means all the mocha tests are running successfully. And if the tests are running, that means the contract is running successfully.

  1. deploy.js

code-imagecode-image

Output of deploy.js file (Contract gets deployed)

code-image

Front-end work

  1. web3.js(connects to MetaMask account)

code-image
  • Detects the Ethereum provider.

  • Detects the Ethereum network in which the user is connected to.

  • Get the user’s Ethereum account.

2. App.js

code-imagecode-imagecode-image
  1. Reward.js

code-imagecode-image

Technology Used

  1. Front-end - Reward-react

  • Reward.js (contains Ethereum account address and contract in JSON format)

  • app.js (executed contract)

  • web3.js (connected contract to MetaMask account)

  1. Back-end - Reward

  • Reward.sol (Contract)

  • compile.js (Solidity compiler (Solc) compiles the contract)

  • inbox.test.js (Mocha test js file)

  • deploy.js (deploys the contract from MetaMask account)

A reward contract platform between manager and employee

In this project, we succeeded in creating a contract in which there is a manager and an array of employees. Addresses of the employees get stored in an array. Employees can enter into a contract by giving some ether (Minimum amount of ether is 0.01). (Ether is a cryptocurrency that is used as a transactional token that facilitates operations on the Ethereum network). 
The manager will reward the employee which has the maximum amount of ether (This has been set to random for now). The manager will reward some of his ether to an employee randomly, which will get added to the particular employee's account.

Our Contribution & Output

Back-end work

  1. Reward.sol

code-image
  • Here, “manager” is a variable that stores the address

  • Employee - an array that stores addresses of an employee

  • msg.sender - displays the address of the manager

  • Enter is a payable function. Here, payable means one can do a transaction. So, the person who pays more than .01 ether can get inside the contract.

code-image
  • Random will return the random value.

  • The winner transfers some amount of ether from the manager to the employee as a reward.

code-image
  • Modifier restricted() will get executed only when the address matches the manager’s account address. To be precise, it is the manager who can execute this.

  • Here, getEmployee() will return the addresses of the employee.

  1. inbox.test.js(test file)

code-image
  • We installed web3 and ganache packages.

  • Here, “abi” - gives the JSON code of a particular contract.

  • “evm” is - Ethereum Virtual Manager.

  • Also, we ran some Mocha tests to check whether the contract was running or not.

Output of Test file (inbox.test.js) in command prompt

code-image

Here, the green tick means all the mocha tests are running successfully. And if the tests are running, that means the contract is running successfully.

  1. deploy.js

code-imagecode-image

Output of deploy.js file (Contract gets deployed)

code-image

Front-end work

  1. web3.js(connects to MetaMask account)

code-image
  • Detects the Ethereum provider.

  • Detects the Ethereum network in which the user is connected to.

  • Get the user’s Ethereum account.

2. App.js

code-imagecode-imagecode-image
  1. Reward.js

code-imagecode-image

Technology Used

  1. Front-end - Reward-react

  • Reward.js (contains Ethereum account address and contract in JSON format)

  • app.js (executed contract)

  • web3.js (connected contract to MetaMask account)

  1. Back-end - Reward

  • Reward.sol (Contract)

  • compile.js (Solidity compiler (Solc) compiles the contract)

  • inbox.test.js (Mocha test js file)

  • deploy.js (deploys the contract from MetaMask account)

Author

Admin

Follow us on

Send us a message

Related Glossary

Backend

Backend

Backend

Business Process Management

Business Process Management

Business Process Management

© 2024 Laitkor. All rights reserved.