Skip to content

Commit 777b32a

Browse files
committed
configure hardhat and smart contract
1 parent 3f02d19 commit 777b32a

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

.gitignore

+40
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,43 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37+
38+
config.json
39+
40+
node_modules
41+
.env
42+
43+
# Hardhat files
44+
/cache
45+
/artifacts
46+
47+
# TypeChain files
48+
/typechain
49+
/typechain-types
50+
51+
# solidity-coverage files
52+
/coverage
53+
/coverage.json
54+
55+
# Hardhat Ignition default folder for deployments against a local node
56+
ignition/deployments/chain-31337
57+
58+
node_modules
59+
.env
60+
61+
# Hardhat files
62+
/cache
63+
/artifacts
64+
65+
# TypeChain files
66+
/typechain
67+
/typechain-types
68+
69+
# solidity-coverage files
70+
/coverage
71+
/coverage.json
72+
73+
# Hardhat Ignition default folder for deployments against a local node
74+
ignition/deployments/chain-31337
75+
76+
client

contracts/Upload.sol

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
pragma solidity >=0.7.0 <0.9.0;
3+
4+
contract Upload {
5+
6+
struct Access{
7+
address user;
8+
bool access; //true or false
9+
}
10+
mapping(address=>string[]) value;
11+
mapping(address=>mapping(address=>bool)) ownership;
12+
mapping(address=>Access[]) accessList;
13+
mapping(address=>mapping(address=>bool)) previousData;
14+
15+
function add(address _user,string memory url) external {
16+
value[_user].push(url);
17+
}
18+
function allow(address user) external {//def
19+
ownership[msg.sender][user]=true;
20+
if(previousData[msg.sender][user]){
21+
for(uint i=0;i<accessList[msg.sender].length;i++){
22+
if(accessList[msg.sender][i].user==user){
23+
accessList[msg.sender][i].access=true;
24+
}
25+
}
26+
}else{
27+
accessList[msg.sender].push(Access(user,true));
28+
previousData[msg.sender][user]=true;
29+
}
30+
31+
}
32+
function disallow(address user) public{
33+
ownership[msg.sender][user]=false;
34+
for(uint i=0;i<accessList[msg.sender].length;i++){
35+
if(accessList[msg.sender][i].user==user){
36+
accessList[msg.sender][i].access=false;
37+
}
38+
}
39+
}
40+
41+
function display(address _user) external view returns(string[] memory){
42+
require(_user==msg.sender || ownership[_user][msg.sender],"You don't have access");
43+
return value[_user];
44+
}
45+
46+
function shareAccess() public view returns(Access[] memory){
47+
return accessList[msg.sender];
48+
}
49+
}

hardhat.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// require("@nomiclabs/hardhat-waffle");
2+
3+
// module.exports = {
4+
// solidity: "0.8.19",
5+
// networks: {
6+
// hardhat: {
7+
// chainId: 1337
8+
// },
9+
// localhost: {
10+
// url: "http://127.0.0.1:8545"
11+
// }
12+
// },
13+
// paths: {
14+
// artifacts: "./client/src/artifacts",
15+
// },
16+
// };
17+
18+
require("@nomicfoundation/hardhat-toolbox");
19+
20+
/** @type import('hardhat/config').HardhatUserConfig */
21+
module.exports = {
22+
solidity: "0.8.9",
23+
networks: {
24+
hardhat: {
25+
chainId: 1337,
26+
},
27+
},
28+
paths: {
29+
artifacts: "./client/src/artifacts",
30+
},
31+
};

0 commit comments

Comments
 (0)