Skip to content

Commit

Permalink
Making Manager with solidity
Browse files Browse the repository at this point in the history
  • Loading branch information
Henriqueiru committed Apr 30, 2022
1 parent e7835bb commit 8b58ff9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 35 deletions.
3 changes: 3 additions & 0 deletions Front-end.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
first: Go app.js

The new ethers contract in app.js contain the contrat of the command hardhat node
31 changes: 31 additions & 0 deletions Resources for study about dapp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
first: create a react app
second: npm install ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers
thirth: npx hardhat //to create an app hardhat, but delete the readme because it'll cause a conflict
fourth: add to file hardhat.config.js:
paths: {
artifacts: './src/artifacts'
},
networks: {
hardhat: {
chainId: 1337
}
}

fifth: npx hardhat compile

sixth:in another terminal uses npx hardhat node show wallets with eth to test

seventh: Use private key to import one test wallet

eighth: npx hardhat run scripts/deploy.js --network localhost to pick up one address of the newly deployed contract
then we can see in another terminal that the wallets works

nineth: npx hardhat test
tenth: npm run start

for main net uses: rinkeby: {
url: 'Infura Key',
accounts: [`Replace Private Key`]
}


22 changes: 0 additions & 22 deletions contracts/Greeter.sol

This file was deleted.

27 changes: 27 additions & 0 deletions contracts/Manager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Manager {
struct Ticket {
uint8 status;
string name;
}

Ticket[] public tickets;

function createTicket(string memory _name) external {
tickets.push(Ticket(0, _name));
}

function updateTicketName(uint256 _index, string memory _name) external {
tickets[_index].name = _name;
}

function updateTicketStatus(uint256 _index, uint8 _status) external {
tickets[_index].status = _status;
}

function getTickets() external view returns (Ticket[] memory) {
return tickets;
}
}
4 changes: 0 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ module.exports = {
networks: {
hardhat: {
chainId: 1337
},
rinkeby: {
url: 'Infura Key',
accounts: [`Replace Private Key`]
}
//For main net uses rikeby
}
Expand Down
18 changes: 9 additions & 9 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
const hre = require('hardhat')

async function main() {
// Hardhat always runs the compile task when running scripts with its command
Expand All @@ -14,19 +14,19 @@ async function main() {
// await hre.run('compile');

// We get the contract to deploy
const Greeter = await hre.ethers.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, Hardhat!");
const Manager = await hre.ethers.getContractFactory('Manager')
const manager = await Manager.deploy()

await greeter.deployed();
await manager.deployed()

console.log("Greeter deployed to:", greeter.address);
console.log('Greeter deployed to:', manager.address)
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
.catch(error => {
console.error(error)
process.exit(1)
})

0 comments on commit 8b58ff9

Please sign in to comment.