├── .DS_Store
├── .gitignore
├── EthFlask
├── .gitignore
├── README.md
├── app.py
├── requirements.txt
├── script.sh
└── static
│ └── HelloWorld.sol
├── README.md
├── assets
└── architecture.png
├── backend
└── app.js
├── frontend
├── .env
├── .eslintrc.cjs
├── .gitignore
├── README.md
├── index.html
├── package-lock.json
├── package.json
├── public
│ ├── arrow.svg
│ ├── creditIcon.svg
│ ├── cube.svg
│ ├── docDia.svg
│ ├── home.svg
│ ├── logo.svg
│ └── vite.svg
├── src
│ ├── App.css
│ ├── App.jsx
│ ├── components
│ │ ├── AuthWrapper
│ │ │ └── index.jsx
│ │ ├── BottomCard
│ │ │ ├── index.jsx
│ │ │ └── style.module.css
│ │ ├── GradientButton
│ │ │ └── index.jsx
│ │ ├── LegacyDialog
│ │ │ └── index.jsx
│ │ ├── LightButton
│ │ │ └── index.jsx
│ │ ├── LinkInput
│ │ │ └── index.jsx
│ │ ├── Lottie
│ │ │ ├── MeraLottie.jsx
│ │ │ └── SuccessTick.jsx
│ │ ├── Modal
│ │ │ └── index.jsx
│ │ ├── Navbar
│ │ │ └── index.jsx
│ │ └── YellowButton
│ │ │ └── index.jsx
│ ├── config
│ │ ├── axios.js
│ │ ├── firebase.js
│ │ └── router.jsx
│ ├── context
│ │ ├── AppContext.jsx
│ │ └── TestContext.jsx
│ ├── helpers
│ │ └── id_generator.js
│ ├── index.css
│ ├── main.jsx
│ ├── pages
│ │ ├── Doc
│ │ │ └── index.jsx
│ │ ├── Editor
│ │ │ └── index.jsx
│ │ ├── GoogleLogin
│ │ │ └── index.jsx
│ │ ├── Home
│ │ │ └── index.jsx
│ │ ├── Login.jsx
│ │ ├── MagicOptions
│ │ │ └── index.jsx
│ │ └── NotFound
│ │ │ └── index.jsx
│ └── theme
│ │ └── ThemeProvider.jsx
├── vite.config.js
└── yarn.lock
├── hardhat
├── .gitignore
├── README.md
├── contracts
│ └── Coins.sol
├── hardhat.config.js
├── package-lock.json
├── package.json
└── scripts
│ └── deploy.js
├── magic-deploy
├── frontend
│ ├── .eslintrc.cjs
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── vite.svg
│ ├── src
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ └── vite.config.js
├── hardhat
│ ├── .gitignore
│ ├── README.md
│ ├── contracts
│ │ └── Greeter.sol
│ ├── hardhat.config.js
│ ├── package-lock.json
│ ├── package.json
│ ├── scripts
│ │ └── deploy.js
│ └── test
│ │ └── Greeter.js
├── node-working
│ ├── .gitignore
│ ├── artifacts
│ │ ├── build-info
│ │ │ └── 719ac2fc07c1fc7ab215d06fea5d23fd.json
│ │ └── contracts
│ │ │ └── VotingSystem.sol
│ │ │ ├── VotingSystem.dbg.json
│ │ │ └── VotingSystem.json
│ ├── package-lock.json
│ ├── package.json
│ └── script.js
└── test-hardhat
│ ├── .gitignore
│ ├── README.md
│ ├── contracts
│ └── VotingSystem.sol
│ ├── hardhat.config.js
│ ├── package-lock.json
│ ├── package.json
│ └── scripts
│ └── deploy.js
└── project-builder
├── app.js
├── app.py
├── artifacts.zip
├── arya.zip
├── deployscript.sh
├── hardhat-base
├── .gitignore
├── README.md
├── contracts
│ └── .gitkeep
├── hardhat.config.js
├── package-lock.json
├── package.json
├── scripts
│ └── deploy.js
└── test
│ └── .gitkeep
├── script.sh
├── script2.sh
├── static
└── hmmm.txt
└── test.py
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/team-somehow/three-transform/b43ca8294bc89e339f045b86a421687d4ba63396/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | __pycache__
4 | .env
--------------------------------------------------------------------------------
/EthFlask/.gitignore:
--------------------------------------------------------------------------------
1 | virt
2 | .env
3 | venv
4 | temp
5 | node_modules
6 | .env
7 |
8 | # Hardhat files
9 | /cache
10 | /artifacts
11 |
12 | # TypeChain files
13 | /typechain
14 | /typechain-types
15 |
16 | # solidity-coverage files
17 | /coverage
18 | /coverage.json
19 |
--------------------------------------------------------------------------------
/EthFlask/README.md:
--------------------------------------------------------------------------------
1 | Hello
2 |
--------------------------------------------------------------------------------
/EthFlask/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, jsonify, request
2 | from flask_cors import CORS
3 | from openai import OpenAI
4 | import json
5 | import os
6 | from subprocess import run
7 |
8 | from subprocess import Popen, PIPE
9 | import subprocess
10 |
11 | gpt_api_key=os.environ.get("OPENAI_API_KEY")
12 |
13 | app = Flask(__name__, static_url_path='/static/', static_folder='static/')
14 | CORS(app)
15 |
16 | client=OpenAI(api_key=gpt_api_key)
17 |
18 | @app.route('/generate/code',methods=['GET',"POST"])
19 | def generate_code():
20 | is_test = request.get_json().get('is_test', None)
21 | if is_test == True:
22 | response = generate_code_test_response
23 | return jsonify(response)
24 |
25 | # return jsonify({"response":request.get_json()})
26 | approach_heading=request.get_json()['approach_heading']
27 | approach_content=request.get_json()['approach_content']
28 | user_approach=request.get_json()['user_approach']
29 |
30 | smart_contract_prompt = """
31 | Develop a Solidity smart contract to implement the following approach for the web application:
32 |
33 | Approach Heading: "{}"
34 |
35 | Approach Content:
36 | {}
37 |
38 | Additional Details:
39 | {}
40 |
41 | Your task is to provide the Solidity code for the smart contract that will effectively integrate this approach into the web application.
42 | Include relevant functions, variables, and any necessary logic to ensure the successful implementation of the specified feature.
43 |
44 | Ensure that the generated Solidity code:
45 | 1. Compiles without errors.
46 | 2. Is complete and ready for deployment.
47 | 3. The version of Solidity used is "0.8.0" and SPDX-License-Identifier should be "MIT".
48 | 4. Create a 'transferTo' function in a smart contract that allows the owner to transfer ownership to a specified address. Only the current owner should have the privilege to invoke this function.
49 |
50 | Note: Consider best practices and security considerations for smart contracts during the development.
51 | """
52 |
53 | smart_contract_prompt = smart_contract_prompt.format(approach_heading,approach_content,user_approach)
54 |
55 |
56 | schema = {
57 | "type": "object",
58 | "properties": {
59 | "solidity_code": {
60 | "type": "string",
61 | "description": "Generated Solidity code for the specified approach.",
62 | },
63 | "contract_name": {
64 | "type": "string",
65 | "description": "Name of the smart contract generated for the specified approach.",
66 | },
67 | "details": {
68 | "type": "object",
69 | "properties": {
70 | "compilation_status_confidence": {
71 | "type": "integer",
72 | "description": "Confidence level (between 1 and 100 - 1 being least confident that it will compile successfully and 100 being completely sure that it will compile successfully) for the compilation status of the generated Solidity code.",
73 | },
74 | "completeness_confidence": {
75 | "type": "integer",
76 | "description": "Confidence level (between 1 and 100 - 1 being least confident that it will compile successfully and 100 being completely sure that it will compile successfully) for the completeness of the generated Solidity code.",
77 | },
78 | "additional_notes": {
79 | "type": "string",
80 | "description": "Describe all the functions of the smart contract except the 'transferTo' function. Provide a brief description of the contract's functionality and any other relevant details",
81 | },
82 | },
83 | "required": ["compilation_status_confidence", "completeness_confidence"],
84 | "description": "Details about the generated Solidity code.",
85 | },
86 | },
87 | "required": ["solidity_code", "contract_name", "details"],
88 | "description": "Schema for representing the generated Solidity code and related details.",
89 | }
90 |
91 | response=client.chat.completions.create(
92 | model="gpt-4",
93 | messages=[
94 | {"role": "system", "content": smart_contract_prompt},
95 | ],
96 | functions=[{"name": "print", "parameters": schema}],
97 | function_call={"name": "print"},
98 | )
99 | print(response.choices[0].message.function_call.arguments)
100 | return jsonify({"response":json.loads(response.choices[0].message.function_call.arguments, strict=False)})
101 |
102 | @app.route('/scrape',methods=['GET',"POST"])
103 | def web_scrape():
104 | website_url = request.args.get('url')
105 |
106 | ############################################
107 | is_test = request.args.get('is_test', None)
108 | if is_test == "true":
109 | if website_url == "https://flipkart.com/" or "flipkart" in website_url:
110 | response = web_scrape_flipkart_website_response
111 | return jsonify(response)
112 |
113 | if website_url == "https://www.reddit.com/" or "reddit" in website_url:
114 | response = web_scrape_reddit_website_respose
115 | return jsonify(response)
116 |
117 | else:
118 | response = web_scrape_reddit_website_respose
119 | return jsonify(response)
120 | ############################################
121 |
122 | # actual code
123 | prompt = """
124 | Assume I am from the tech team of a web2 app hosted at "{}"
125 | (now onwards whenever I use the following words "web app" or "app" or "web application" or alike I am referring to the web2 app hosted at "{}")
126 | and I want to update my technology by integrating a smart contract in my web application.
127 | Give me "approaches" to integrate smart contract in the app.
128 |
129 | How you should behave :-
130 | 1) figure out what the "web app" does by looking it up on the internet. Then figure out features that can be better served on web3 for that particular app
131 | 2) If it is a well-known app DO NOT answer as it is not possible. Understand that the developer is building a similar version on web3.
132 |
133 | For example :-
134 | (1) If the app's core functionality is to sell properties online so an "approach" would be :-
135 | 1) use escrow smart contract to transfer property
136 | 2) use NFT to represent property
137 | (2) If the app is reddit so an "approach" would be :-
138 | 1) Reddit's upvote/downvote system can be made even more transparent and tamper-proof using blockchain smart contracts.
139 | """
140 | prompt = prompt.format(website_url, website_url)
141 |
142 | schema = {
143 | "type": "object",
144 | "properties": {
145 | "summary": {
146 | "type": "string",
147 | "description": "A concise summary of the \"web application\".",
148 | },
149 | "approaches": {
150 | "type": "array",
151 | "items": {
152 | "type": "object",
153 | "properties": {
154 | "heading": {
155 | "type": "string",
156 | "description": "A concise heading describing the key idea of the approach.",
157 | },
158 | "content": {
159 | "type": "string",
160 | "description": "Detailed content outlining the steps and implementation details of the approach.",
161 | },
162 | "relevence": {
163 | "type": "string",
164 | "description": "How is the approach relevant to the given \"web application\".",
165 | },
166 | },
167 | "required": ["heading", "content"],
168 | },
169 | "description": "An array of approaches for integrating a smart contract into the \"web application\".",
170 | },
171 | },
172 | "required": ["approaches"],
173 | "description": "Schema for representing various approaches to integrate a smart contract into the \"web application\".",
174 | }
175 | response=client.chat.completions.create(
176 | model="gpt-4",
177 | messages=[
178 | {"role": "system", "content": prompt},
179 | ],
180 | functions=[{"name": "print", "parameters": schema}],
181 | function_call={"name": "print"},
182 | )
183 | print(response.choices[0].message.function_call.arguments)
184 | return jsonify({"response":json.loads(response.choices[0].message.function_call.arguments)})
185 |
186 |
187 | @app.route('/rest-api',methods=['GET','POST'])
188 | def RESTAPI():
189 | abi=request.get_json()['abi']
190 | print(abi)
191 | response=[]
192 | for i in abi:
193 | temp={}
194 | if i['type']=='constructor':
195 | continue
196 | temp['name']=i['name']
197 | temp['inputs']=[]
198 | for j in i['inputs']:
199 | if j['name']=="":
200 | temp["inputs"].append({
201 | "address":"string"
202 | })
203 | continue
204 | temp['inputs'].append({
205 | j['name']:j['type']
206 | })
207 | temp['outputs']=[]
208 | if "outputs" in i:
209 | print(i['outputs'])
210 | for j in i['outputs']:
211 | temp['outputs'].append({
212 | "type":j['type']
213 | })
214 |
215 | response.append(temp)
216 | return jsonify(response)
217 |
218 | @app.route("/generateabi",methods=['GET','POST'])
219 | def generateOBI():
220 | return jsonify(test_reponse)
221 |
222 |
223 |
224 | return jsonify(response)
225 |
226 |
227 | if __name__ == "__main__":
228 | app.run(debug=True)
229 |
230 | web_scrape_reddit_website_respose = {
231 | "response": {
232 | "approaches": [
233 | {
234 | "content": "Smart contracts can make Reddit's upvoting and downvoting system more transparent and tamper-proof. Users can vote on posts and comments, and these votes can be recorded on the blockchain. This ensures that the voting process is clear, transparent, and cannot be tampered with. Manipulated votes are a concern that can be tackled using smart contracts.",
235 | "heading": "Decentralized Voting System",
236 | "relevence": "Reddit heavily relies on its upvote and downvote system to rank content and decide what gets seen by more people. Ensuring this system's legitimacy adds value to the platform."
237 | },
238 | {
239 | "content": "Reddit currently has a karma system where users gain points for their comments and posts, which are upvoted by other users. This concept can be implemented via smart contracts to create Karma Tokens. Users can earn or lose tokens based on their contributions. The tokens can hold real value, and users could trade them for goods, services, or even sell them for cryptocurrency.",
240 | "heading": "Tokenization of Karma Points",
241 | "relevence": "The ability to earn karma is a key engagement factor in Reddit. Tokenizing karma points may drive stronger user engagement and facilitate an economy within Reddit itself."
242 | },
243 | {
244 | "content": "Content posted on Reddit can be stored on the blockchain, ensuring it is immutable and persistent. This use of a smart contract can mean that once a post is made, it cannot be altered or deleted. This ensures the authenticity of the content.",
245 | "heading": "Decentralized & Immutable Content",
246 | "relevence": "Amid increasingly common concerns about censorship and content manipulation on social platforms, this feature can give Reddit a competitive edge."
247 | },
248 | {
249 | "content": "Smart contracts can enhance Reddit's advertising system. Advertisers can directly enter into contracts with the platform using smart contracts. They can pay using digital tokens, and the display of ads can be automatically controlled by the contract. This would make the transaction process more efficient and trustable.",
250 | "heading": "Smart Contract-based Ads",
251 | "relevence": "Advertising is a significant source of revenue for Reddit. Using smart contracts to automate and make the process more transparent could improve advertiser trust and satisfaction."
252 | }
253 | ],
254 | "summary": "Reddit is a network of communities where people can dive into their interests, hobbies and passions. It's a platform for users to post, comment, and vote on content. Reddit has many subreddits for various topics, and users can subscribe to these subreddits to receive updates on their front page. Users can also upvote and downvote posts and comment on them."
255 | }
256 | }
257 |
258 | web_scrape_flipkart_website_response = {
259 | "response": {
260 | "approaches": [
261 | {
262 | "content": "One immediate approach would be integrating a smart contract for secure and reliable payment. In addition to the current payment gateways, a smart contract will enable direct transfers of cryptocurrency between buyers and sellers. This will increase transparency and may reduce possible transaction costs.",
263 | "heading": "Smart Contract for Secure Payments",
264 | "relevence": "In e-commerce, trust and security during transactions is a critical component. Using smart contracts could enhance this by offering a transparent and secure system for both customers and sellers."
265 | },
266 | {
267 | "content": "Another approach could involve using non-fungible tokens (NFTs) to ensure the authenticity of products, particularly high-value items. Each product could be minted as an NFT representing a unique digital certificate of authenticity. Upon purchasing, this NFT could be sent to the buyer's digital wallet, guaranteeing the authenticity of the product.",
268 | "heading": "Product Authenticity Verification using NFTs",
269 | "relevence": "Counterfeiting is a significant challenge in e-commerce. By integrating NFTs for high-value items, customers are assured of the authenticity of their purchases."
270 | },
271 | {
272 | "content": "Integrate smart contracts for dispute resolutions. The contract could have conditions that govern refunds and return policies. In case of a dispute, the smart contract can be enacted based upon the laid out conditions, ensuring fairness and transparency.",
273 | "heading": "Smart Contract for Dispute Resolution",
274 | "relevence": "Dealing with disputes is often a complex and time-consuming process in e-commerce. A smart contract automatically executing based on pre-determined conditions can expedite this process."
275 | }
276 | ],
277 | "summary": "Flipkart is an Indian e-commerce company that deals with selling goods online. Its core business proposition includes products from numerous categories, such as fashion, home essentials, electronics, etc. It offers secure digital payment options and follows a business model of inventory-led direct sales as well as a hybrid model where it provides a platform for other sellers to sell their products."
278 | }
279 | }
280 |
281 | generate_code_test_response = {
282 | "response": {
283 | "contract_name": "RedditVoting",
284 | "details": {
285 | "additional_notes": "This smart contract enables upvoting and downvoting of posts in a Reddit-like platform. All votes are stored on the Ethereum blockchain to ensure transparency. A post's unique hash is used as the key to record votes. The constructor sets the contract deployer as the initial owner. The contract includes an 'onlyOwner' modifier to restrict certain operations to the owner address. A 'transferTo' function allows the owner to transfer ownership to another Ethereum address. Note: the contract does not include any logic to authenticate users beyond their Ethereum address. Therefore, any Ethereum account can interact with the contract and cast votes.",
286 | "compilation_status_confidence": 1,
287 | "completeness_confidence": 1
288 | },
289 | "solidity_code": "--SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ncontract RedditVoting {\n\n address public owner;\n mapping(address => mapping(bytes32 => bool)) public upvotes;\n mapping(address => mapping(bytes32 => bool)) public downvotes;\n mapping(bytes32 => uint256) public score;\n\n constructor() {\n owner = msg.sender;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Only owner can call this function.\");\n _;\n }\n\n function upvote(bytes32 _hash) public {\n require(!downvotes[msg.sender][_hash], \"Cannot upvote a downvoted post.\");\n upvotes[msg.sender][_hash] = true;\n score[_hash]++;\n }\n\n function downvote(bytes32 _hash) public {\n require(!upvotes[msg.sender][_hash], \"Cannot downvote an upvoted post.\");\n downvotes[msg.sender][_hash] = true;\n score[_hash]--;\n }\n\n function getPostScore(bytes32 _hash) public view returns (uint256) {\n return score[_hash];\n }\n\n function transferTo(address newOwner) public onlyOwner {\n owner = newOwner;\n }\n}"
290 | }
291 | }
292 |
293 |
294 | test_reponse={
295 | "ABI": {
296 | "_format": "hh-sol-artifact-1",
297 | "abi": [
298 | {
299 | "inputs": [],
300 | "stateMutability": "nonpayable",
301 | "type": "constructor"
302 | },
303 | {
304 | "inputs": [
305 | {
306 | "internalType": "bytes32",
307 | "name": "_hash",
308 | "type": "bytes32"
309 | }
310 | ],
311 | "name": "downvote",
312 | "outputs": [],
313 | "stateMutability": "nonpayable",
314 | "type": "function"
315 | },
316 | {
317 | "inputs": [
318 | {
319 | "internalType": "address",
320 | "name": "",
321 | "type": "address"
322 | },
323 | {
324 | "internalType": "bytes32",
325 | "name": "",
326 | "type": "bytes32"
327 | }
328 | ],
329 | "name": "downvotes",
330 | "outputs": [
331 | {
332 | "internalType": "bool",
333 | "name": "",
334 | "type": "bool"
335 | }
336 | ],
337 | "stateMutability": "view",
338 | "type": "function"
339 | },
340 | {
341 | "inputs": [
342 | {
343 | "internalType": "bytes32",
344 | "name": "_hash",
345 | "type": "bytes32"
346 | }
347 | ],
348 | "name": "getPostScore",
349 | "outputs": [
350 | {
351 | "internalType": "uint256",
352 | "name": "",
353 | "type": "uint256"
354 | }
355 | ],
356 | "stateMutability": "view",
357 | "type": "function"
358 | },
359 | {
360 | "inputs": [],
361 | "name": "owner",
362 | "outputs": [
363 | {
364 | "internalType": "address",
365 | "name": "",
366 | "type": "address"
367 | }
368 | ],
369 | "stateMutability": "view",
370 | "type": "function"
371 | },
372 | {
373 | "inputs": [
374 | {
375 | "internalType": "bytes32",
376 | "name": "",
377 | "type": "bytes32"
378 | }
379 | ],
380 | "name": "score",
381 | "outputs": [
382 | {
383 | "internalType": "uint256",
384 | "name": "",
385 | "type": "uint256"
386 | }
387 | ],
388 | "stateMutability": "view",
389 | "type": "function"
390 | },
391 | {
392 | "inputs": [
393 | {
394 | "internalType": "address",
395 | "name": "newOwner",
396 | "type": "address"
397 | }
398 | ],
399 | "name": "transferTo",
400 | "outputs": [],
401 | "stateMutability": "nonpayable",
402 | "type": "function"
403 | },
404 | {
405 | "inputs": [
406 | {
407 | "internalType": "bytes32",
408 | "name": "_hash",
409 | "type": "bytes32"
410 | }
411 | ],
412 | "name": "upvote",
413 | "outputs": [],
414 | "stateMutability": "nonpayable",
415 | "type": "function"
416 | },
417 | {
418 | "inputs": [
419 | {
420 | "internalType": "address",
421 | "name": "",
422 | "type": "address"
423 | },
424 | {
425 | "internalType": "bytes32",
426 | "name": "",
427 | "type": "bytes32"
428 | }
429 | ],
430 | "name": "upvotes",
431 | "outputs": [
432 | {
433 | "internalType": "bool",
434 | "name": "",
435 | "type": "bool"
436 | }
437 | ],
438 | "stateMutability": "view",
439 | "type": "function"
440 | }
441 | ],
442 | "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506109c4806100606000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063a5b1f44d1161005b578063a5b1f44d14610127578063e5af18c514610143578063f1c1921514610173578063faa5fd03146101a357610088565b80633faab61e1461008d57806365231328146100bd5780638da5cb5b146100ed578063a03fa7e31461010b575b600080fd5b6100a760048036038101906100a291906105e7565b6101bf565b6040516100b4919061062d565b60405180910390f35b6100d760048036038101906100d291906106a6565b6101dc565b6040516100e49190610701565b60405180910390f35b6100f561020b565b604051610102919061072b565b60405180910390f35b61012560048036038101906101209190610746565b61022f565b005b610141600480360381019061013c91906105e7565b610300565b005b61015d600480360381019061015891906105e7565b610432565b60405161016a919061062d565b60405180910390f35b61018d600480360381019061018891906106a6565b61044a565b60405161019a9190610701565b60405180910390f35b6101bd60048036038101906101b891906105e7565b610479565b005b600060036000838152602001908152602001600020549050919050565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b4906107f6565b60405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082815260200190815260200160002060009054906101000a900460ff161561039e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039590610862565b60405180910390fd5b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060006101000a81548160ff02191690831515021790555060036000828152602001908152602001600020600081548092919061042a906108b1565b919050555050565b60036020528060005260406000206000915090505481565b60026020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082815260200190815260200160002060009054906101000a900460ff1615610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050e90610945565b60405180910390fd5b6001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060006101000a81548160ff0219169083151502179055506003600082815260200190815260200160002060008154809291906105a490610965565b919050555050565b600080fd5b6000819050919050565b6105c4816105b1565b81146105cf57600080fd5b50565b6000813590506105e1816105bb565b92915050565b6000602082840312156105fd576105fc6105ac565b5b600061060b848285016105d2565b91505092915050565b6000819050919050565b61062781610614565b82525050565b6000602082019050610642600083018461061e565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061067382610648565b9050919050565b61068381610668565b811461068e57600080fd5b50565b6000813590506106a08161067a565b92915050565b600080604083850312156106bd576106bc6105ac565b5b60006106cb85828601610691565b92505060206106dc858286016105d2565b9150509250929050565b60008115159050919050565b6106fb816106e6565b82525050565b600060208201905061071660008301846106f2565b92915050565b61072581610668565b82525050565b6000602082019050610740600083018461071c565b92915050565b60006020828403121561075c5761075b6105ac565b5b600061076a84828501610691565b91505092915050565b600082825260208201905092915050565b7f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60008201527f6e2e000000000000000000000000000000000000000000000000000000000000602082015250565b60006107e0602283610773565b91506107eb82610784565b604082019050919050565b6000602082019050818103600083015261080f816107d3565b9050919050565b7f43616e6e6f74207570766f7465206120646f776e766f74656420706f73742e00600082015250565b600061084c601f83610773565b915061085782610816565b602082019050919050565b6000602082019050818103600083015261087b8161083f565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108bc82610614565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036108ee576108ed610882565b5b600182019050919050565b7f43616e6e6f7420646f776e766f746520616e207570766f74656420706f73742e600082015250565b600061092f602083610773565b915061093a826108f9565b602082019050919050565b6000602082019050818103600083015261095e81610922565b9050919050565b600061097082610614565b91506000820361098357610982610882565b5b60018203905091905056fea264697066735822122077b1bf02ba306160f8480adfce6cf4ced37f10e44b6ceae4a3117e2fb454b21d64736f6c63430008110033",
443 | "contractName": "RedditVoting",
444 | "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063a5b1f44d1161005b578063a5b1f44d14610127578063e5af18c514610143578063f1c1921514610173578063faa5fd03146101a357610088565b80633faab61e1461008d57806365231328146100bd5780638da5cb5b146100ed578063a03fa7e31461010b575b600080fd5b6100a760048036038101906100a291906105e7565b6101bf565b6040516100b4919061062d565b60405180910390f35b6100d760048036038101906100d291906106a6565b6101dc565b6040516100e49190610701565b60405180910390f35b6100f561020b565b604051610102919061072b565b60405180910390f35b61012560048036038101906101209190610746565b61022f565b005b610141600480360381019061013c91906105e7565b610300565b005b61015d600480360381019061015891906105e7565b610432565b60405161016a919061062d565b60405180910390f35b61018d600480360381019061018891906106a6565b61044a565b60405161019a9190610701565b60405180910390f35b6101bd60048036038101906101b891906105e7565b610479565b005b600060036000838152602001908152602001600020549050919050565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b4906107f6565b60405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082815260200190815260200160002060009054906101000a900460ff161561039e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039590610862565b60405180910390fd5b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060006101000a81548160ff02191690831515021790555060036000828152602001908152602001600020600081548092919061042a906108b1565b919050555050565b60036020528060005260406000206000915090505481565b60026020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082815260200190815260200160002060009054906101000a900460ff1615610517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050e90610945565b60405180910390fd5b6001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060006101000a81548160ff0219169083151502179055506003600082815260200190815260200160002060008154809291906105a490610965565b919050555050565b600080fd5b6000819050919050565b6105c4816105b1565b81146105cf57600080fd5b50565b6000813590506105e1816105bb565b92915050565b6000602082840312156105fd576105fc6105ac565b5b600061060b848285016105d2565b91505092915050565b6000819050919050565b61062781610614565b82525050565b6000602082019050610642600083018461061e565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061067382610648565b9050919050565b61068381610668565b811461068e57600080fd5b50565b6000813590506106a08161067a565b92915050565b600080604083850312156106bd576106bc6105ac565b5b60006106cb85828601610691565b92505060206106dc858286016105d2565b9150509250929050565b60008115159050919050565b6106fb816106e6565b82525050565b600060208201905061071660008301846106f2565b92915050565b61072581610668565b82525050565b6000602082019050610740600083018461071c565b92915050565b60006020828403121561075c5761075b6105ac565b5b600061076a84828501610691565b91505092915050565b600082825260208201905092915050565b7f4f6e6c79206f776e65722063616e2063616c6c20746869732066756e6374696f60008201527f6e2e000000000000000000000000000000000000000000000000000000000000602082015250565b60006107e0602283610773565b91506107eb82610784565b604082019050919050565b6000602082019050818103600083015261080f816107d3565b9050919050565b7f43616e6e6f74207570766f7465206120646f776e766f74656420706f73742e00600082015250565b600061084c601f83610773565b915061085782610816565b602082019050919050565b6000602082019050818103600083015261087b8161083f565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108bc82610614565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036108ee576108ed610882565b5b600182019050919050565b7f43616e6e6f7420646f776e766f746520616e207570766f74656420706f73742e600082015250565b600061092f602083610773565b915061093a826108f9565b602082019050919050565b6000602082019050818103600083015261095e81610922565b9050919050565b600061097082610614565b91506000820361098357610982610882565b5b60018203905091905056fea264697066735822122077b1bf02ba306160f8480adfce6cf4ced37f10e44b6ceae4a3117e2fb454b21d64736f6c63430008110033",
445 | "deployedLinkReferences": {},
446 | "linkReferences": {},
447 | "sourceName": "contracts/RedditVoting.sol"
448 | },
449 | "ABI_URI": "https://gateway.lighthouse.storage/ipfs/QmaF7jTr2DzqRxF85PdhTHZN6wFYXJhcAo2BpkYpRnH47Q",
450 | "HardHat": "https://gateway.lighthouse.storage/ipfs/QmWZsdB6x927g5SR8fR6kWXeuo4rUBoGMKtPURfHZfUwz8"
451 | }
--------------------------------------------------------------------------------
/EthFlask/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/team-somehow/three-transform/b43ca8294bc89e339f045b86a421687d4ba63396/EthFlask/requirements.txt
--------------------------------------------------------------------------------
/EthFlask/script.sh:
--------------------------------------------------------------------------------
1 | cd hardFiles
2 | npx hardhat init
3 | printf "\n"
4 |
--------------------------------------------------------------------------------
/EthFlask/static/HelloWorld.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 | contract HelloWorld {
4 | function sayHelloWorld() public pure returns (string memory) {
5 | return "Hello World";
6 | }
7 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Three Transform By Team Somehow
2 |
3 | ## Getting Started
4 |
5 | ### Start EthFlask
6 |
7 | create .env
8 |
9 | ```zsh
10 | cd EthFlask
11 | pip install -r requirements.txt
12 | flask run -p 5001
13 | ```
14 |
15 | ### Start Magic Deploy
16 |
17 | ```zsh
18 | cd magic-deploy/node-working
19 | npm i
20 | ```
21 |
22 | Create .env in that folder
23 |
24 | ```
25 | SECRET_KEY=wallet-secret-key
26 | ```
27 |
28 | ```zsh
29 | node script.js
30 | ```
31 |
32 | ### Project Builder
33 |
34 | ```zsh
35 | cd project-builder
36 | pip install flask openai lighthouseweb3
37 | flask run -p 5002
38 | ```
39 |
40 | ### Start Frontend
41 |
42 | ```zsh
43 | cd frontend
44 | npm i
45 | npm run dev
46 | ```
47 |
48 | ## Architecture Diagram
49 |
50 | 
51 |
--------------------------------------------------------------------------------
/assets/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/team-somehow/three-transform/b43ca8294bc89e339f045b86a421687d4ba63396/assets/architecture.png
--------------------------------------------------------------------------------
/backend/app.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/team-somehow/three-transform/b43ca8294bc89e339f045b86a421687d4ba63396/backend/app.js
--------------------------------------------------------------------------------
/frontend/.env:
--------------------------------------------------------------------------------
1 | # REACT_APP_BASE_URL=http://127.0.0.1:5000
--------------------------------------------------------------------------------
/frontend/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: { browser: true, es2020: true },
4 | extends: [
5 | "eslint:recommended",
6 | "plugin:react/recommended",
7 | "plugin:react/jsx-runtime",
8 | "plugin:react-hooks/recommended",
9 | ],
10 | ignorePatterns: ["dist", ".eslintrc.cjs"],
11 | parserOptions: { ecmaVersion: "latest", sourceType: "module" },
12 | settings: { react: { version: "18.2" } },
13 | plugins: ["react-refresh"],
14 | rules: {
15 | "react/prop-types": "off",
16 | "react-refresh/only-export-components": [
17 | "warn",
18 | { allowConstantExport: true },
19 | ],
20 | },
21 | };
22 |
--------------------------------------------------------------------------------
/frontend/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
26 | .vscode/
27 |
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | # React + Vite
2 |
3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4 |
5 | Currently, two official plugins are available:
6 |
7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9 |
--------------------------------------------------------------------------------
/frontend/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 3-Transform
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ethindia2023",
3 | "private": true,
4 | "version": "0.0.0",
5 | "type": "module",
6 | "scripts": {
7 | "local": "vite",
8 | "dev": "vite --host",
9 | "build": "vite build",
10 | "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
11 | "preview": "vite preview"
12 | },
13 | "dependencies": {
14 | "@emotion/react": "^11.11.1",
15 | "@emotion/styled": "^11.11.0",
16 | "@lighthouse-web3/sdk": "^0.3.0",
17 | "@monaco-editor/react": "^4.6.0",
18 | "@mui/material": "^5.14.20",
19 | "axios": "^1.6.2",
20 | "base-64": "^1.0.0",
21 | "firebase": "^10.7.1",
22 | "lottie-web": "^5.12.2",
23 | "monaco-editor": "^0.45.0",
24 | "notistack": "^3.0.1",
25 | "react": "^18.2.0",
26 | "react-code-blocks": "^0.1.5",
27 | "react-dom": "^18.2.0",
28 | "react-firebase-hooks": "^5.1.1",
29 | "react-icons": "^4.12.0",
30 | "react-router-dom": "^6.20.1",
31 | "react-router-hash-link": "^2.4.3"
32 | },
33 | "devDependencies": {
34 | "@types/react": "^18.2.37",
35 | "@types/react-dom": "^18.2.15",
36 | "@vitejs/plugin-react": "^4.2.0",
37 | "eslint": "^8.53.0",
38 | "eslint-plugin-react": "^7.33.2",
39 | "eslint-plugin-react-hooks": "^4.6.0",
40 | "eslint-plugin-react-refresh": "^0.4.4",
41 | "vite": "^5.0.0"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/frontend/public/arrow.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/frontend/public/creditIcon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/cube.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/frontend/public/home.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/frontend/public/logo.svg:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/frontend/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/src/App.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/team-somehow/three-transform/b43ca8294bc89e339f045b86a421687d4ba63396/frontend/src/App.css
--------------------------------------------------------------------------------
/frontend/src/App.jsx:
--------------------------------------------------------------------------------
1 | import { RouterProvider } from 'react-router-dom';
2 | import router from './config/router';
3 | import StyleThemeProvider from './theme/ThemeProvider';
4 | import { SnackbarProvider } from 'notistack';
5 | import { AppContext } from './context/AppContext';
6 | import { TestContext } from './context/TestContext';
7 |
8 | const appID = 'xar_test_fe9df73ff0f3ca7b5300b27720265695728c1d82';
9 |
10 | // export const arcanaProvider = new AuthProvider(appID, {
11 | // network: "testnet", //defaults to 'testnet'
12 | // position: "right", //defaults to right
13 | // theme: "light", //defaults to dark
14 | // alwaysVisible: true, //defaults to true which is Full UI mode
15 | // chainConfig: {
16 | // chainId: 80001, //defaults to CHAIN.ETHEREUM_MAINNET
17 | // rpcUrl: "https://polygon-rpc.com", //defaults to 'https://rpc.ankr.com/eth'
18 | // },
19 | // });
20 |
21 | function App() {
22 | return (
23 | <>
24 | {/* */}
25 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | {/* */}
47 | >
48 | );
49 | }
50 |
51 | export default App;
52 |
--------------------------------------------------------------------------------
/frontend/src/components/AuthWrapper/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import { useNavigate } from 'react-router-dom';
3 | import { db } from '../../config/firebase';
4 | import { LinearProgress, Box, Typography } from '@mui/material';
5 |
6 | import {
7 | collection,
8 | doc,
9 | getDocs,
10 | query,
11 | setDoc,
12 | where,
13 | } from 'firebase/firestore';
14 | import { AppContext } from '../../context/AppContext';
15 |
16 | function AuthWrapper({ children }) {
17 | const auth = useContext(AppContext);
18 | const navigate = useNavigate();
19 |
20 | const [loading, setLoading] = React.useState(true);
21 | React.useEffect(() => {
22 | const login = async () => {
23 | if (auth.loading) return;
24 | const timeOut = setTimeout(async () => {
25 | if (auth.isLoggedIn && auth?.user) {
26 | setLoading(false);
27 |
28 | const { user } = auth || {};
29 | const q = query(
30 | collection(db, "users"),
31 | where("uid", "==", user.address)
32 | );
33 | const docs = await getDocs(q);
34 | if (docs.docs.length === 0) {
35 | await setDoc(doc(db, 'users', user?.address), {
36 | uid: user.address,
37 | name: user.name,
38 | authProvider: user?.authProvider,
39 | email: user.email,
40 | publicKey: user.publicKey,
41 | });
42 | }
43 | }
44 | }, 1000);
45 | };
46 | login();
47 | }, [auth, navigate]);
48 |
49 | if (loading)
50 | return (
51 |
61 |
62 | Preparing magic dust...
63 |
64 |
65 |
66 | );
67 | return <>{children}>;
68 | }
69 |
70 | export default AuthWrapper;
71 |
--------------------------------------------------------------------------------
/frontend/src/components/BottomCard/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box } from '@mui/material';
2 | import styles from './style.module.css';
3 |
4 | function BottomCard({ children, ...rest }) {
5 | return (
6 |
7 |
8 | {children}
9 |
10 |
11 | );
12 | }
13 |
14 | export default BottomCard;
15 |
--------------------------------------------------------------------------------
/frontend/src/components/BottomCard/style.module.css:
--------------------------------------------------------------------------------
1 | .CardBorder {
2 | background: linear-gradient(180deg, #EEEEF0 0%, #eeeef000 100%);
3 | padding: 1px;
4 | }
5 |
6 | .Card {
7 | background: linear-gradient(180deg, #2B243C 0%, #0B031E 100%);
8 | height: 100%;
9 | width: 100%;
10 | }
--------------------------------------------------------------------------------
/frontend/src/components/GradientButton/index.jsx:
--------------------------------------------------------------------------------
1 | import { Button } from '@mui/material';
2 |
3 | function GradientButton({ icon, text, styles, isDisabled, ...rest }) {
4 | return (
5 |
45 | );
46 | }
47 |
48 | export default GradientButton;
49 |
--------------------------------------------------------------------------------
/frontend/src/components/LegacyDialog/index.jsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import PropTypes from 'prop-types';
3 | import Button from '@mui/material/Button';
4 | import { styled } from '@mui/material/styles';
5 | import Dialog from '@mui/material/Dialog';
6 | import DialogTitle from '@mui/material/DialogTitle';
7 | import DialogContent from '@mui/material/DialogContent';
8 | import DialogActions from '@mui/material/DialogActions';
9 | import Typography from '@mui/material/Typography';
10 |
11 | import Stepper from '@mui/material/Stepper';
12 | import { Box, LinearProgress, Step, StepLabel } from '@mui/material';
13 | import SuccessTick from '../Lottie/SuccessTick';
14 |
15 | const BootstrapDialog = styled(Dialog)(({ theme }) => ({
16 | '& .MuiDialogContent-root': {
17 | padding: theme.spacing(2),
18 | color: 'white',
19 | },
20 | '& .MuiDialogActions-root': {
21 | padding: theme.spacing(1),
22 | color: 'white',
23 | },
24 | }));
25 |
26 | function BootstrapDialogTitle(props) {
27 | const { children, onClose, ...other } = props;
28 |
29 | return (
30 |
34 | {children}
35 |
36 | );
37 | }
38 |
39 | BootstrapDialogTitle.propTypes = {
40 | children: PropTypes.node,
41 | onClose: PropTypes.func.isRequired,
42 | };
43 |
44 | export default function CustomizedDialogs(props) {
45 | // const [open, setOpen] = React.useState(props.open);
46 |
47 | const steps = props.steps;
48 |
49 | const handleClose = (_event, reason) => {
50 | if (reason && reason === 'backdropClick') return;
51 | props.setOpen(false);
52 | };
53 |
54 | return (
55 |
56 |
68 |
72 |
73 | {props.text}
74 |
75 |
76 |
77 | {!props.error ? (
78 | <>
79 |
80 | {steps.map((label) => (
81 |
82 |
83 | {label}
84 |
85 |
86 | ))}
87 |
88 | {props.stepCount !== steps.length - 1 ? (
89 |
90 |
91 |
92 | ) : (
93 |
99 |
100 |
101 | )}
102 | >
103 | ) : (
104 | {props.error}
105 | )}
106 |
107 |
108 |
109 |
110 |
111 | );
112 | }
113 |
--------------------------------------------------------------------------------
/frontend/src/components/LightButton/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box, Button } from "@mui/material";
2 |
3 | function LightButton({ text, icon, ...rest }) {
4 | return (
5 |
35 | );
36 | }
37 |
38 | export default LightButton;
39 |
--------------------------------------------------------------------------------
/frontend/src/components/LinkInput/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box, FormControl, InputAdornment, TextField } from '@mui/material';
2 |
3 | import { FaMagic } from 'react-icons/fa';
4 |
5 | function LinkInput({ isDisabled, defaultValue, ...rest }) {
6 | return (
7 |
8 |
16 |
28 |
29 |
30 |
31 | ),
32 | sx: {
33 | borderRadius: 0.6,
34 | background: 'rgba(43, 36, 60, 0.90)',
35 | boxShadow: '0px 0px 60px 0px rgba(236, 39, 182, 0.25)',
36 | '& .MuiInputBase-input.Mui-disabled': {
37 | WebkitTextFillColor: 'rgba(255, 208, 242, 0.60)',
38 | },
39 | },
40 | }}
41 | />
42 |
43 | );
44 | }
45 |
46 | export default LinkInput;
47 |
--------------------------------------------------------------------------------
/frontend/src/components/Lottie/MeraLottie.jsx:
--------------------------------------------------------------------------------
1 | import lottie from "lottie-web";
2 | import React, { useEffect, useRef } from "react";
3 |
4 | const MeraLottie = ({ path }) => {
5 | const animationRef = useRef(null);
6 |
7 | useEffect(() => {
8 | if (animationRef.current) {
9 | lottie.loadAnimation({
10 | container: animationRef.current,
11 | loop: false,
12 | autoplay: true,
13 | path: path,
14 | });
15 | }
16 | }, [path]);
17 |
18 | return ;
19 | };
20 |
21 | export default MeraLottie;
22 |
--------------------------------------------------------------------------------
/frontend/src/components/Lottie/SuccessTick.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import MeraLottie from "./MeraLottie";
3 |
4 | const SuccessTick = ({ text }) => {
5 | return (
6 |
7 |
8 |
9 | );
10 | };
11 |
12 | export default SuccessTick;
13 |
--------------------------------------------------------------------------------
/frontend/src/components/Modal/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import BottomCard from '../BottomCard';
3 | import {
4 | Box,
5 | CardActions,
6 | CardContent,
7 | List,
8 | ListItem,
9 | Stepper,
10 | Step,
11 | StepLabel,
12 | Divider,
13 | Typography,
14 | } from '@mui/material';
15 |
16 | function Modal() {
17 | return (
18 |
30 |
40 |
52 | jnvdwjnrqwkj
53 |
54 |
55 |
56 | );
57 | }
58 |
59 | export default Modal;
60 |
--------------------------------------------------------------------------------
/frontend/src/components/Navbar/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box, Typography } from '@mui/material';
2 | import { Link } from 'react-router-dom';
3 |
4 | function Navbar() {
5 | return (
6 |
17 |
24 |
32 |
33 |
34 |
35 |
36 | 3 Credits
37 |
38 |
39 |
40 | );
41 | }
42 |
43 | export default Navbar;
44 |
--------------------------------------------------------------------------------
/frontend/src/components/YellowButton/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box, Button } from '@mui/material';
2 |
3 | function YellowButton({ text, isDisabled, icon, ...rest }) {
4 | return (
5 |
30 | );
31 | }
32 |
33 | export default YellowButton;
34 |
--------------------------------------------------------------------------------
/frontend/src/config/axios.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 | export const instance = axios.create({
3 | baseURL: import.meta.env.REACT_APP_BASE_URL || "https://ethflask-fea7.onrender.com",
4 | });
5 |
--------------------------------------------------------------------------------
/frontend/src/config/firebase.js:
--------------------------------------------------------------------------------
1 | // Import the functions you need from the SDKs you need
2 | import { initializeApp } from 'firebase/app';
3 | import { getAnalytics } from 'firebase/analytics';
4 | import { getFirestore } from 'firebase/firestore';
5 | import { getAuth } from 'firebase/auth';
6 |
7 | const firebaseConfig = {
8 | apiKey: 'AIzaSyAvO8NPH9TL8WXVWvRadN-LT0YGfHE_80U',
9 | authDomain: 'ethindia2023.firebaseapp.com',
10 | projectId: 'ethindia2023',
11 | storageBucket: 'ethindia2023.appspot.com',
12 | messagingSenderId: '1002231812923',
13 | appId: '1:1002231812923:web:af36dbe1be42914b421d1e',
14 | measurementId: 'G-HLGK2RB2NE',
15 | };
16 |
17 | // Initialize Firebase
18 | const app = initializeApp(firebaseConfig);
19 | export const analytics = getAnalytics(app);
20 | const auth = getAuth(app);
21 |
22 | export const db = getFirestore(app);
23 | export { auth };
24 |
--------------------------------------------------------------------------------
/frontend/src/config/router.jsx:
--------------------------------------------------------------------------------
1 | import { Outlet, createBrowserRouter } from 'react-router-dom';
2 | import { Box } from '@mui/material';
3 | import NotFound from '../pages/NotFound';
4 | import Home from '../pages/Home';
5 | import Navbar from '../components/Navbar';
6 | import Editor from '../pages/Editor';
7 | import Doc from '../pages/Doc';
8 | import MagicOptions from '../pages/MagicOptions';
9 | import Login from '../pages/Login';
10 | import AuthWrapper from '../components/AuthWrapper';
11 | import GoogleLogin from '../pages/GoogleLogin';
12 | import Modal from '../components/Modal';
13 |
14 | const router = createBrowserRouter([
15 | {
16 | path: '/',
17 | element: (
18 |
19 |
25 |
26 |
27 |
28 |
29 | ),
30 | children: [
31 | {
32 | path: '/',
33 | element: ,
34 | },
35 | {
36 | path: 'editor',
37 | element: ,
38 | },
39 | {
40 | path: 'doc',
41 | element: ,
42 | },
43 | {
44 | path: 'options',
45 | element: ,
46 | },
47 | ],
48 | },
49 | {
50 | path: '/login',
51 | element: ,
52 | },
53 | {
54 | path: '/google-login',
55 | element: ,
56 | },
57 | {
58 | path: '/modal',
59 | element: ,
60 | },
61 | {
62 | path: '*',
63 | element: ,
64 | },
65 | ]);
66 |
67 | export default router;
68 |
--------------------------------------------------------------------------------
/frontend/src/context/AppContext.jsx:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | export const AppContext = createContext({
4 | loading: false,
5 | isLoggedIn: true,
6 | user: {
7 | address:
8 | localStorage?.getItem("address") ||
9 | "0x0Dd7D7Ad21d15A999dcc7218E7Df3F25700e69",
10 | name: "Vinay Kanse",
11 | authProvider: "email",
12 | email: "vinay@gmail.com",
13 | publicKey:
14 | localStorage?.getItem("address") ||
15 | "0x0Dd7D7Ad21d15A999dcc7218E7Df3F25700e69",
16 | },
17 | });
18 |
--------------------------------------------------------------------------------
/frontend/src/context/TestContext.jsx:
--------------------------------------------------------------------------------
1 | import { createContext } from 'react';
2 |
3 | export const TestContext = createContext();
4 |
--------------------------------------------------------------------------------
/frontend/src/helpers/id_generator.js:
--------------------------------------------------------------------------------
1 | export default function uuidv4() {
2 | return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
3 | (
4 | c ^
5 | (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
6 | ).toString(16)
7 | );
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/src/index.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
2 |
3 | *,
4 | *::before,
5 | *::after {
6 | padding: 0;
7 | margin: 0;
8 | box-sizing: border-box;
9 | z-index: 3;
10 | }
11 |
12 | body {
13 | font-family: 'Poppins', sans-serif;
14 | position: relative;
15 | min-width: 100vw;
16 | min-height: 100vh;
17 | }
18 |
19 | body::after {
20 | content: "";
21 | position: absolute;
22 | top: 50%;
23 | left: 50%;
24 | transform: translate(-50%, -50%);
25 | transform-origin: center center;
26 | background: #c00dc8;
27 | width: 504px;
28 | height: 504px;
29 | filter: blur(250px);
30 | animation: motion 10s alternate infinite ease-in-out;
31 | z-index: 1;
32 | }
33 |
34 | @keyframes motion {
35 | 0% {
36 | transform: translate(-50%, -50%) scale(0.8);
37 | }
38 |
39 | 100% {
40 | transform: translate(-50%, -50%) scale(1);
41 | }
42 | }
--------------------------------------------------------------------------------
/frontend/src/main.jsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom/client";
3 | import App from "./App.jsx";
4 | import "./index.css";
5 |
6 | ReactDOM.createRoot(document.getElementById("root")).render();
7 |
--------------------------------------------------------------------------------
/frontend/src/pages/Doc/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react';
2 | import { Box, ListItem, Typography, Divider, Button } from '@mui/material';
3 | import { Code, shadesOfPurple, CopyBlock } from 'react-code-blocks';
4 | import { HashLink } from 'react-router-hash-link';
5 | import { FaDownload, FaClipboardList } from 'react-icons/fa';
6 | import ToggleButton from '@mui/material/ToggleButton';
7 | import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
8 | import { IoLogoJavascript } from 'react-icons/io5';
9 | import { FaReact } from 'react-icons/fa';
10 |
11 | import { FaPython } from 'react-icons/fa';
12 | import { useState } from 'react';
13 | import axios from 'axios';
14 |
15 | import { collection, doc, getDoc, query, where } from 'firebase/firestore';
16 | import { db } from '../../config/firebase';
17 | import { AppContext } from '../../context/AppContext';
18 | import { instance } from '../../config/axios';
19 |
20 | const data = [
21 | {
22 | id: 1,
23 | text: 'Initial setup',
24 | description:
25 | 'Download the ABI from above and paste the files in the frontend folder.',
26 | },
27 | {
28 | id: 2,
29 | text: 'Download dependencies',
30 | },
31 | {
32 | id: 3,
33 | text: 'Custom functions',
34 | },
35 | ];
36 |
37 | const snippets = [
38 | {
39 | id: 1,
40 | type: 'react',
41 | text: 'Import',
42 | code: `import { Contract, ethers, providers } from "ethers";`,
43 | },
44 | {
45 | id: 2,
46 | type: 'react',
47 | text: 'Get signature and smart contract',
48 | code: `const provider = new providers.Web3Provider(window.ethereum);
49 | const signer = provider.getSigner();
50 | const contract = new Contract([deployed_contract_address], [contract_name].abi, signer);`,
51 | },
52 | {
53 | id: 3,
54 | type: 'react',
55 | text: 'Integrate the system',
56 | code: `if (window.ethereum) {
57 | await window.ethereum.enable();
58 |
59 | const result = await contract.[function_name](
60 | param_1],
61 | param_2]
62 | );
63 |
64 | result.wait();
65 | }`,
66 | },
67 | ];
68 |
69 | const snippets2 = [
70 | {
71 | id: 1,
72 | type: 'react',
73 | text: 'Import',
74 | code: `import { Contract, ethers, providers } from "ethers";`,
75 | },
76 | {
77 | id: 2,
78 | type: 'react',
79 | text: 'Get signature and smart contract',
80 | code: `const provider = new providers.Web3Provider(window.ethereum);
81 | const signer = provider.getSigner();
82 | const contract = new Contract([deployed_contract_address], [contract_name].abi, signer);`,
83 | },
84 | {
85 | id: 3,
86 | type: 'react',
87 | text: 'Integrate the system',
88 | code: `if (window.ethereum) {
89 | const contract = new Contract([depployed_contract_address], [contract_name].abi, signer);`,
90 | },
91 | {
92 | id: 3,
93 | type: 'react',
94 | text: 'Integrate the system',
95 | code: `if (window.ethereum) {
96 | await window.ethereum.enable();
97 |
98 | const result = await contract.[function_name](
99 | param_1],
100 | param_2]
101 | );
102 |
103 | result.wait();
104 | }`,
105 | },
106 | ];
107 |
108 | const abi = [
109 | {
110 | inputs: [],
111 | stateMutability: 'nonpayable',
112 | type: 'constructor',
113 | },
114 | {
115 | anonymous: false,
116 | inputs: [
117 | {
118 | indexed: true,
119 | internalType: 'address',
120 | name: 'user',
121 | type: 'address',
122 | },
123 | {
124 | indexed: false,
125 | internalType: 'string',
126 | name: 'name',
127 | type: 'string',
128 | },
129 | ],
130 | name: 'NameSet',
131 | type: 'event',
132 | },
133 | {
134 | inputs: [
135 | {
136 | internalType: 'address',
137 | name: '_user',
138 | type: 'address',
139 | },
140 | ],
141 | name: 'getUserName',
142 | outputs: [
143 | {
144 | internalType: 'string',
145 | name: '',
146 | type: 'string',
147 | },
148 | ],
149 | stateMutability: 'view',
150 | type: 'function',
151 | },
152 | {
153 | inputs: [],
154 | name: 'owner',
155 | outputs: [
156 | {
157 | internalType: 'address',
158 | name: '',
159 | type: 'address',
160 | },
161 | ],
162 | stateMutability: 'view',
163 | type: 'function',
164 | },
165 | {
166 | inputs: [
167 | {
168 | internalType: 'string',
169 | name: '_name',
170 | type: 'string',
171 | },
172 | ],
173 | name: 'setUserName',
174 | outputs: [],
175 | stateMutability: 'nonpayable',
176 | type: 'function',
177 | },
178 | {
179 | inputs: [
180 | {
181 | internalType: 'address',
182 | name: '',
183 | type: 'address',
184 | },
185 | ],
186 | name: 'userNames',
187 | outputs: [
188 | {
189 | internalType: 'string',
190 | name: '',
191 | type: 'string',
192 | },
193 | ],
194 | stateMutability: 'view',
195 | type: 'function',
196 | },
197 | ];
198 |
199 | function Doc() {
200 | const [toggle, setToggle] = useState('react');
201 | const [selectedFunction, setSelectedFunction] = useState();
202 | const [functionList, setFunctionList] = useState([]);
203 | const [contractAddress, setContractAddress] = useState('0x23762183687');
204 | const [contractName, setContractName] = useState('MyContract');
205 | const [snippets, setSnippets] = useState(snippets2);
206 | const [response, setResponse] = useState(null);
207 | const { user } = useContext(AppContext);
208 |
209 | React.useEffect(() => {
210 | console.log(selectedFunction);
211 | // if(selectedFunction){
212 | let stringOfID3 = `if (window.ethereum) {
213 | await window.ethereum.enable();
214 |
215 | const result = await contract.${selectedFunction?.name}(`;
216 | for (let i = 0; i < selectedFunction?.inputs.length; i++) {
217 | const keys = Object.keys(selectedFunction?.inputs[i]);
218 | for (let j = 0; j < keys.length; j++) {
219 | stringOfID3 += `${keys[j]}: ${selectedFunction?.inputs[i][keys[j]]}`;
220 | }
221 |
222 | if (i !== selectedFunction.inputs.length - 1) {
223 | stringOfID3 += `,`;
224 | }
225 |
226 | }
227 | stringOfID3 += `);`;
228 | stringOfID3 += `
229 | result.wait();
230 | }`;
231 |
232 | let temp = [
233 | {
234 | id: 1,
235 | type: 'react',
236 | text: 'Import',
237 | code: `import { Contract, ethers, providers } from "ethers";`,
238 | },
239 | {
240 | id: 2,
241 | type: 'react',
242 | text: 'Get signature and smart contract',
243 | code: `const provider = new providers.Web3Provider(window.ethereum);
244 | const signer = provider.getSigner();
245 | const contract = new Contract(${contractAddress}, ${contractName}.abi, signer);`,
246 | },
247 | {
248 | id: 3,
249 | type: 'react',
250 | text: 'Integrate the system',
251 | code: stringOfID3,
252 | },
253 | ];
254 | setSnippets(temp);
255 | }, [contractAddress, contractName, selectedFunction]);
256 |
257 | React.useEffect(() => {
258 | const getData = async () => {
259 | console.log(response.abi.abi);
260 | const res = await instance.post('/rest-api', {
261 | abi: response.abi.abi,
262 | });
263 | setFunctionList(res.data);
264 | };
265 | getData();
266 | }, [response]);
267 |
268 | const handleArtifactDownload = async () => {
269 | setTimeout(() => {
270 | window.open(response?.abiUrl, '_blank', 'noopener,noreferrer');
271 | }, 5000);
272 | return;
273 | axios
274 | .post('http://127.0.0.1:5002/getABI', {
275 | code: code,
276 | contractName: contractName,
277 | })
278 | .then((res) => {
279 | console.log('CID', res.data.CID);
280 | console.log(
281 | 'IPFS URL',
282 | `https://gateway.lighthouse.storage/ipfs/${res.data.CID}`
283 | );
284 | window.open(
285 | `https://gateway.lighthouse.storage/ipfs/QmbPWxcRnKq2bQqNPuzq9cTqKCiVAFky6xRN4ZZuD7VRNE`,
286 | '_blank',
287 | 'noopener,noreferrer'
288 | );
289 | })
290 | .catch((err) => {
291 | console.log(err);
292 | });
293 | };
294 |
295 | React.useEffect(() => {
296 | const fetchData = async () => {
297 | const response = await getDoc(doc(db, 'users', user?.address));
298 | console.log(response.data());
299 | const { urls } = response.data();
300 | setResponse(urls);
301 | setContractName(urls?.contractName);
302 | setContractAddress(response.data().contractAddress);
303 | };
304 | fetchData();
305 | }, [user]);
306 |
307 | return (
308 |
315 |
328 |
337 | {data.map(({ id, text }) => (
338 |
339 |
347 | {text}
348 |
349 |
350 | ))}
351 |
352 |
358 |
371 | {data.map(({ id, text, description }) => (
372 |
373 |
374 | {text}
375 |
376 |
377 |
378 | {description}
379 |
380 | {id === 1 && (
381 |
388 | }
391 | onClick={() => handleArtifactDownload()}
392 | >
393 | Download Artifacts
394 |
395 |
396 | }>
397 | Copy files to frontend
398 |
399 |
400 | )}
401 | {id === 2 && (
402 |
409 |
418 |
419 | {`Note: make sure that `}
420 |
426 | {` exists in the enviournment variable `}
427 |
428 |
429 | )}
430 | {id === 3 && (
431 |
444 |
454 |
455 | Function Names
456 |
457 |
458 | {functionList?.map((funcName, index) => (
459 | setSelectedFunction(funcName)}
471 | >
472 | {`${funcName?.name}()`}
473 |
474 | ))}
475 |
476 |
486 | {
490 | setToggle(e.target.value);
491 | }}
492 | size="small"
493 | sx={{
494 | color: 'white',
495 | }}
496 | >
497 |
498 |
499 | Javascript
500 |
501 |
502 |
503 | React
504 |
505 |
506 |
507 | Python
508 |
509 |
510 |
511 |
518 | {snippets.map(({ id, text, code }) => (
519 |
520 |
521 | {text}
522 |
523 |
534 |
535 | ))}
536 |
537 |
538 |
539 | )}
540 |
541 | ))}
542 |
543 |
544 |
545 | );
546 | }
547 |
548 | export default Doc;
549 |
--------------------------------------------------------------------------------
/frontend/src/pages/Editor/index.jsx:
--------------------------------------------------------------------------------
1 | import {
2 | Box,
3 | Button,
4 | Step,
5 | StepLabel,
6 | Stepper,
7 | TextField,
8 | Typography,
9 | Divider,
10 | } from "@mui/material";
11 | import GradientButton from "../../components/GradientButton";
12 | import Editor from "@monaco-editor/react";
13 | import { GrDeploy } from "react-icons/gr";
14 | import { FaMagic } from "react-icons/fa";
15 | import { LuHardHat } from "react-icons/lu";
16 | import LightButton from "../../components/LightButton";
17 | import YellowButton from "../../components/YellowButton";
18 | import { FaCode, FaDownload } from "react-icons/fa";
19 | import { MdArrowForwardIos } from "react-icons/md";
20 | import React, { useContext, useEffect, useState } from "react";
21 | import { Link, useLocation } from "react-router-dom";
22 | import { instance } from "../../config/axios";
23 | import { encode } from "base-64";
24 | import axios from "axios";
25 | import { db } from "../../config/firebase";
26 | import { AppContext } from "../../context/AppContext";
27 | import { TestContext } from "../../context/TestContext";
28 | import { doc, updateDoc } from "firebase/firestore";
29 | import Modal from "@mui/material/Modal";
30 | import CustomizedDialogs from "../../components/LegacyDialog";
31 |
32 | const tempSteps = [
33 | {
34 | id: "01",
35 | text: "Open Remix IDE",
36 | },
37 | {
38 | id: "02",
39 | text: 'Click "+" in the file explorer, name the file according to contract name(e.g., Contract.sol).',
40 | },
41 | {
42 | id: "03",
43 | text: "Copy contract code, paste into the new file.",
44 | },
45 | {
46 | id: "04",
47 | text: 'Go to "Solidity" tab, select compiler version, click "Compile".',
48 | },
49 | {
50 | id: "05",
51 | text: 'Switch to "Deploy & Run Transactions" tab, click "Deploy".',
52 | },
53 | {
54 | id: "06",
55 | text: "Find deployed contract, expand, interact with functions",
56 | },
57 | {
58 | id: "07",
59 | text: 'Deploy contract, set value using a setter function in "Deployed Contracts" with entered parameter',
60 | },
61 | {
62 | id: "08",
63 | text: "Get value using a getter function in 'Deployed Contracts'",
64 | },
65 | {
66 | id: "09",
67 | text: 'In "Events" section, observe emitted events.',
68 | },
69 | {
70 | id: "10",
71 | text: "If present, test modifiers like onlyOwner.",
72 | },
73 | ];
74 |
75 | function EditorPage() {
76 | const { user } = useContext(AppContext);
77 | const { state } = useLocation();
78 | const [inputQuestions, setInputQuestions] = useState("");
79 | const [code, setCode] = useState("");
80 | const [summary, setSummary] = useState("");
81 | const [tabsLayout, setTabsLayout] = useState([25, 45, 30]);
82 | const [isDisabled, setIsDisabled] = useState(true);
83 | const [contractName, setContractName] = useState("");
84 | const isTest = React.useContext(TestContext);
85 | const [ABI, setABI] = useState();
86 | const [loading, setLoading] = useState(false);
87 | const [isModalOpen, setIsModalOpen] = useState(false);
88 | const [contractAdd, setContractAdd] = useState();
89 | const [currentStep, setCurrentStep] = useState(0);
90 | const handleDownloadHardhat = async () => {
91 | setCurrentStep(0);
92 | try {
93 | setLoading(true);
94 | await new Promise((resolve) => setTimeout(resolve, 4000));
95 | setCurrentStep(1);
96 | const response = await axios.post(
97 | !isTest
98 | ? "https://49c4-2409-40f2-18-f350-f485-a4b8-b5b3-ae50.ngrok-free.app"
99 | : "https://ethflask-fea7.onrender.com" + "/generateabi",
100 | {
101 | code: code,
102 | testing: "",
103 | contractName: contractName,
104 | is_test: isTest,
105 | }
106 | );
107 | setCurrentStep(2);
108 | await new Promise((resolve) => setTimeout(resolve, 3000));
109 | setCurrentStep(3);
110 | setABI(response?.data?.ABI);
111 | await updateDoc(doc(db, "users", user?.address), {
112 | urls: {
113 | url: state?.url,
114 | abi: response?.data?.ABI,
115 | abiUrl: response?.data?.ABI_URI,
116 | hardhatUrl: response?.data?.HardHat,
117 | contractName: response.data.ABI.contractName,
118 | },
119 | });
120 |
121 | await new Promise((resolve) => setTimeout(resolve, 6000));
122 | setCurrentStep(4);
123 | await new Promise((resolve) => setTimeout(resolve, 1000));
124 | window.open(response?.data?.HardHat, "_blank", "noopener,noreferrer");
125 | setLoading(false);
126 | } catch (error) {
127 | console.log(error);
128 | }
129 | };
130 |
131 | const onTabClick = async () => {
132 | try {
133 | const response = await instance.post("generate/code", {
134 | approach_heading: state?.selectedOption?.heading,
135 | approach_content: state?.selectedOption?.content,
136 | user_approach: inputQuestions,
137 | is_test: isTest,
138 | });
139 | console.log(response?.data?.response);
140 | setContractName(response?.data?.response?.contract_name);
141 | setCode("//" + response?.data?.response?.solidity_code);
142 | setSummary(response?.data?.response?.details?.additional_notes);
143 | updateDoc(doc(db, "users", user.address), {
144 | snippet: {
145 | approach_heading: state?.selectedOption?.heading,
146 | approach_content: state?.selectedOption?.content,
147 | user_approach: inputQuestions,
148 | solidity_code: response?.data?.response?.solidity_code,
149 | details: response?.data?.response?.details?.additional_notes,
150 | },
151 | });
152 | if (tabsLayout[0] === 25) {
153 | setTabsLayout([5, 65, 30]);
154 | setIsDisabled(false);
155 | } else if (tabsLayout[0] === 5) {
156 | setTabsLayout([25, 45, 30]);
157 | setIsDisabled(true);
158 | }
159 | } catch (error) {
160 | console.log(error);
161 | }
162 | };
163 |
164 | const deployContract = async () => {
165 | try {
166 | const response = await axios.post(
167 | "https://magic-deploy.onrender.com/deploy-contract",
168 | {
169 | rpc: "https://rpc.public.zkevm-test.net",
170 | bytecode: ABI?.bytecode,
171 | abi: ABI?.abi,
172 | is_test: isTest,
173 | },
174 | {
175 | headers: {
176 | "Content-Type": "application/json",
177 | },
178 | }
179 | );
180 | console.log("deploy", response?.data);
181 | setContractAdd(response?.data?.contractAddress);
182 | await updateDoc(doc(db, "users", user?.address), {
183 | contractAddress: response?.data?.contractAddress,
184 | });
185 | setIsModalOpen(true);
186 | } catch (error) {
187 | console.error(error);
188 | }
189 | };
190 |
191 | useEffect(() => {
192 | localStorage.setItem("code", code);
193 | localStorage.setItem("contractName", contractName);
194 | }, [code, contractName]);
195 |
196 | const handleModalClose = () => {
197 | setIsModalOpen(false);
198 | window.location.href = "/doc";
199 | };
200 |
201 | return (
202 | <>
203 |
212 |
225 |
236 |
245 | {tabsLayout[0] === 25 && (
246 | <>
247 |
248 | Approach Selected
249 |
250 |
251 | {state?.selectedOption?.content}
252 |
253 | >
254 | )}
255 |
256 |
266 | {tabsLayout[0] === 25 && (
267 |
268 |
269 | What features do you want your smart contract to implement?
270 |
271 |
272 | setInputQuestions(e.target.value)}
278 | value={inputQuestions}
279 | sx={{
280 | height: "100%",
281 | overflow: "auto",
282 | background: "rgba(255, 255, 255, 0.10)",
283 | borderRadius: 1,
284 | }}
285 | />
286 |
287 |
288 | )}
289 |
290 | {tabsLayout[0] === 25 ? (
291 |
292 | }
296 | fullWidth
297 | styles={{
298 | borderRadius: 1,
299 | }}
300 | />
301 |
302 | ) : (
303 |
304 |
339 |
340 | )}
341 |
342 |
349 |
361 |
372 | setCode(value)}
378 | />
379 |
380 |
388 | }
393 | onClick={() => handleDownloadHardhat()}
394 | />
395 |
396 |
397 |
405 |
417 |
418 | Steps to test it on RemixIDE
419 |
420 |
428 |
436 | {tempSteps.map(({ id, text }) => {
437 | return (
438 |
439 |
440 | {text}
441 |
442 |
443 | );
444 | })}
445 |
446 | }
454 | fullWidth
455 | />
456 |
457 |
458 |
469 |
470 | Contract Summary
471 |
472 | {summary}
473 |
474 | .MuiBackdrop-root": {
481 | backdropFilter: "blur(2px)",
482 | },
483 | "& > .MuiBox-root": {
484 | bgcolor: "black", // Set the background color of the modal content
485 | color: "white", // Set the text color if needed
486 | boxShadow: "0px 0px 60px 0px rgba(236, 39, 182, 0.60)",
487 | },
488 | }}
489 | >
490 |
501 |
502 | Successfully deployed your contract!
503 |
504 |
505 | This is your contract address:
506 |
507 |
508 | {contractAdd}
509 |
510 |
513 |
514 |
515 | }
517 | onClick={deployContract}
518 | text="Magic Deploy"
519 | fullWidth
520 | isDisabled={isDisabled}
521 | styles={{
522 | borderRadius: 1,
523 | height: "2.5rem",
524 | }}
525 | />
526 |
527 |
528 |
529 |
542 | >
543 | );
544 | }
545 |
546 | export default EditorPage;
547 |
--------------------------------------------------------------------------------
/frontend/src/pages/GoogleLogin/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import { Box, Typography, Button, Divider } from '@mui/material';
3 | import { FaGoogle } from 'react-icons/fa';
4 | import { useSignInWithGoogle, useAuthState } from 'react-firebase-hooks/auth';
5 | import { auth } from '../../config/firebase';
6 | import { Link } from 'react-router-dom';
7 | import Modal from '@mui/material/Modal';
8 | import axios from 'axios';
9 |
10 | function GoogleLogin() {
11 | const [signInWithGoogle, user, loading, error] = useSignInWithGoogle(auth);
12 | const [isModalOpen, setIsModalOpen] = useState(false);
13 | const [walletAddress, setWalletAddress] = useState('');
14 |
15 | useEffect(() => {
16 | const fetchData = async () => {
17 | try {
18 | const response = await axios.post(
19 | 'https://3p-bff.oktostage.com/api/v1/wallet',
20 | {
21 | // Add any required data for the request body
22 | },
23 | {
24 | headers: {
25 | Authorization:
26 | 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2luZGN4X2lkIjoiZTZlZGZmNTEtNWJkZS00NDMyLWFiMDktZWNlODZlNzQ3Y2JmIiwidXNlcl9pZCI6ImU2ZWRmZjUxLTViZGUtNDQzMi1hYjA5LWVjZTg2ZTc0N2NiZiIsInNoYXJlZF9pZCI6bnVsbCwicG9ydGZvbGlvRmFjdG9yIjoiMSIsInNlc3Npb25JZCI6IjNiZWJlYzAxLWI5MjAtNDY2NC1iMDAwLTM5OWUyZjg1NzI1OSIsInVzZXJfbG9naW5fdmVuZG9yX2lkIjoiYmMzOTM3YTktYWQ3OS00NTMwLTg3ZGYtNTg5YjRiYzY3MjI1IiwicyI6Im9rdG9fYW5kcm9pZCIsInNpcCI6Ijo6ZmZmZjoxMjcuMC4wLjYiLCJvdiI6Im9rdG9fcGx1cyIsImxvZ2luX21lZGl1bSI6IkdfQVVUSCIsImlhdCI6MTcwMjEzODMxOSwiZXhwIjoxNzAzMDAyMzE5fQ.y_TcsP7wPl1U6wCltD40DAdwNUlxqoZNG6wd-iGvGoU', // Replace with your actual access token
27 | 'x-api-key': '55d4c32e-2139-4690-8ef4-abfd75c73bdd',
28 | },
29 | }
30 | );
31 |
32 | console.log(response.data?.data);
33 | setWalletAddress(response.data?.data?.wallets[0]?.address);
34 |
35 | setIsModalOpen(true);
36 | } catch (error) {
37 | console.error(error);
38 | }
39 | };
40 |
41 | if (user) {
42 | fetchData();
43 | }
44 | }, [user]);
45 |
46 | const handleModalClose = () => {
47 | setIsModalOpen(false);
48 | window.location.href = '/';
49 | };
50 |
51 | return (
52 |
63 |
73 |
82 |
83 | Sign in to
84 |
85 |
86 | 3-Tranform
87 |
88 |
89 | Use your Google Account
90 |
91 | }
94 | sx={{
95 | p: '0.5rem 3rem',
96 | borderRadius: 0.5,
97 | }}
98 | onClick={() => signInWithGoogle()}
99 | >
100 | Sign in with Google
101 |
102 |
111 |
114 |
115 | OR
116 |
117 |
120 |
121 |
132 |
133 | .MuiBackdrop-root': {
140 | backdropFilter: 'blur(2px)',
141 | },
142 | '& > .MuiBox-root': {
143 | bgcolor: 'black', // Set the background color of the modal content
144 | color: 'white', // Set the text color if needed
145 | boxShadow: '0px 0px 60px 0px rgba(236, 39, 182, 0.60)',
146 | },
147 | }}
148 | >
149 | {/* Modal content */}
150 |
161 |
162 | Successfully logged in to your account!
163 |
164 |
165 | This is your wallet address:
166 |
167 |
168 | {walletAddress}
169 |
170 |
173 |
174 |
175 |
176 | );
177 | }
178 |
179 | export default GoogleLogin;
180 |
--------------------------------------------------------------------------------
/frontend/src/pages/Home/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useEffect, useState } from 'react';
2 | import {
3 | Box,
4 | CardActions,
5 | CardContent,
6 | List,
7 | ListItem,
8 | Stepper,
9 | Step,
10 | StepLabel,
11 | Divider,
12 | Typography,
13 | } from '@mui/material';
14 | import LinearProgress from '@mui/material/LinearProgress';
15 | import { FaCode, FaMagic } from 'react-icons/fa';
16 | import BottomCard from '../../components/BottomCard';
17 | import GradientButton from '../../components/GradientButton';
18 | import LinkInput from '../../components/LinkInput';
19 | import { instance } from '../../config/axios';
20 | import { keyframes } from '@emotion/react';
21 | import { Link } from 'react-router-dom';
22 | import { useNavigate } from 'react-router-dom';
23 | import LightButton from '../../components/LightButton';
24 | import { TestContext } from '../../context/TestContext';
25 | import Alert from '@mui/material/Alert';
26 | import AlertTitle from '@mui/material/AlertTitle';
27 |
28 | const steps = [
29 | {
30 | id: 1,
31 | text: 'Share your website URL.',
32 | },
33 | {
34 | id: 2,
35 | text: 'Receive tailored suggestions on integrating web3 seamlessly.',
36 | },
37 | {
38 | id: 3,
39 | text: 'Get a one-click deploy contract for swift implementation.',
40 | },
41 | ];
42 | const gradientAnimation = keyframes`
43 | 0% {
44 | background-position: 0% 50%;
45 | }
46 | 100% {
47 | background-position: 100% 50%;
48 | }
49 | `;
50 |
51 | function Home() {
52 | const navigate = useNavigate();
53 | const [inputLink, setInputLink] = useState('https://www.reddit.com/');
54 | const isTest = React.useContext(TestContext);
55 | console.log('isTest', isTest);
56 |
57 | const [loading, setLoading] = useState(false);
58 |
59 | const handleMagicButtonClick = async () => {
60 | setLoading(true);
61 | try {
62 | if (isTest) {
63 | // Simulate a 3-second loading delay if isTest is true
64 | await new Promise((resolve) => setTimeout(resolve, 7000));
65 | }
66 | const { data } = await instance.post(
67 | '/scrape?url=' + inputLink + `&is_test=${isTest}`
68 | );
69 | if (data?.response?.approaches && data.response.summary) {
70 | navigate('/options', {
71 | state: {
72 | options: data.response.approaches,
73 | summary: data.response.summary,
74 | url: inputLink,
75 | },
76 | });
77 | }
78 | setLoading(false);
79 | } catch (error) {
80 | console.log(error);
81 | console.log(error);
82 | }
83 | };
84 |
85 | return (
86 |
95 |
96 |
105 | setInputLink(e.target.value)}
109 | />
110 |
111 | Streamlined web3 integration made simple!
112 |
113 |
114 |
124 |
136 | {loading ? (
137 | <>
138 |
139 | Generating ideas!
140 |
141 |
144 | >
145 | ) : (
146 | <>
147 |
155 | {steps.map(({ id, text }) => {
156 | return (
157 |
158 |
159 |
160 | {text}
161 |
162 |
163 |
164 | );
165 | })}
166 |
167 |
176 | }
178 | text="Start the Magic!"
179 | onClick={handleMagicButtonClick}
180 | disabled={loading}
181 | />
182 |
183 |
191 |
192 | 1 Credit
193 |
194 |
195 |
204 |
214 |
217 |
218 | or
219 |
220 |
223 |
224 | }
229 | fullWidth
230 | />
231 |
232 |
233 | >
234 | )}
235 |
236 | {isTest && (
237 |
238 |
251 |
252 | Hey, you will only recieve cached responses from a previous
253 | query.
254 |
255 | If you want to get complete access just hit me up on Telegram -
256 | https://t.me/pettiboy and I will give you full access
257 |
258 |
259 | )}
260 |
261 |
262 | );
263 | }
264 |
265 | export default Home;
266 |
--------------------------------------------------------------------------------
/frontend/src/pages/Login.jsx:
--------------------------------------------------------------------------------
1 | import { Box } from "@mui/material";
2 | import { useNavigate } from "react-router-dom";
3 | import React, { useContext } from "react";
4 | import { AppContext } from "../context/AppContext";
5 |
6 | const Login = () => {
7 | const navigate = useNavigate();
8 | const auth = useContext(AppContext);
9 |
10 | React.useEffect(() => {
11 | if (auth.isLoggedIn && auth.user != null) {
12 | navigate("/");
13 | }
14 | }, [auth.isLoggedIn, auth.user, navigate]);
15 |
16 | return (
17 |
24 | {/* {
28 | navigate("/");
29 | console.log("Hello");
30 | }}
31 | > */}
32 |
33 | );
34 | };
35 |
36 | export default Login;
37 |
--------------------------------------------------------------------------------
/frontend/src/pages/MagicOptions/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import {
3 | Avatar,
4 | Box,
5 | CardActions,
6 | CardContent,
7 | List,
8 | ListItem,
9 | ListItemAvatar,
10 | ListItemButton,
11 | ListItemIcon,
12 | ListItemText,
13 | Typography,
14 | } from '@mui/material';
15 |
16 | import BottomCard from '../../components/BottomCard';
17 | import LinkInput from '../../components/LinkInput';
18 | import { Link, useLocation, useNavigate } from 'react-router-dom';
19 |
20 | function MagicOptions() {
21 | const navigate = useNavigate();
22 | const { state } = useLocation();
23 | console.log(state);
24 | const handleOptionOnClick = (data) => {
25 | console.log(data);
26 | navigate('/editor', {
27 | state: {
28 | selectedOption: data,
29 | url: state?.url,
30 | },
31 | });
32 | };
33 |
34 | return (
35 |
44 |
45 |
54 |
55 |
72 | Lets start again?
73 |
74 |
75 |
85 |
97 |
98 | Current approach
99 |
100 |
109 |
115 | {state?.summary}
116 |
117 |
118 |
119 |
120 | Generated ideas
121 |
122 |
128 | {state?.options?.map((option, i) => {
129 | return (
130 | handleOptionOnClick(option)}
140 | >
141 |
155 |
156 |
172 | {i < 9 && '0'}
173 | {i + 1}
174 |
175 |
176 |
180 |
181 | {option?.heading}:
182 |
183 |
184 | {option?.content}
185 |
186 |
187 | Relevence:
188 |
189 |
190 | {option?.relevence}
191 |
192 | >
193 | }
194 | fontWeight={400}
195 | />
196 |
197 |
198 | );
199 | })}
200 |
201 |
202 |
203 |
204 |
205 | );
206 | }
207 |
208 | export default MagicOptions;
209 |
--------------------------------------------------------------------------------
/frontend/src/pages/NotFound/index.jsx:
--------------------------------------------------------------------------------
1 | import { Box, Typography } from "@mui/material";
2 |
3 | export default function NotFound() {
4 | return (
5 |
6 |
7 | 404 Not found
8 |
9 |
10 | );
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/src/theme/ThemeProvider.jsx:
--------------------------------------------------------------------------------
1 | import { createTheme, CssBaseline, ThemeProvider } from "@mui/material";
2 |
3 | const StyleThemeProvider = (props) => {
4 | const useTheme = createTheme({
5 | palette: {
6 | type: "dark",
7 | primary: {
8 | main: "#EC27B6",
9 | },
10 | secondary: {
11 | main: "#FFFFFF",
12 | },
13 | background: {
14 | default: "#0B031E",
15 | paper: "rgba(255, 255, 255, 0.10)",
16 | },
17 | text: {
18 | primary: "#EEEEF0",
19 | },
20 | },
21 | shape: {
22 | borderRadius: 10,
23 | },
24 | typography: {
25 | fontFamily: "Poppins, sans-serif",
26 | fontWeightLight: 400,
27 | fontWeightRegular: 500,
28 | fontWeightMedium: 600,
29 | fontWeightBold: 900,
30 | },
31 | overrides: {
32 | MuiSwitch: {
33 | root: {
34 | width: 42,
35 | height: 26,
36 | padding: 0,
37 | margin: 8,
38 | },
39 | switchBase: {
40 | padding: 1,
41 | "&$checked, &$colorPrimary$checked, &$colorSecondary$checked": {
42 | transform: "translateX(16px)",
43 | color: "#fff",
44 | "& + $track": {
45 | opacity: 1,
46 | border: "none",
47 | },
48 | },
49 | },
50 | thumb: {
51 | width: 24,
52 | height: 24,
53 | },
54 | track: {
55 | borderRadius: 13,
56 | border: "1px solid #bdbdbd",
57 | backgroundColor: "#fafafa",
58 | opacity: 1,
59 | transition:
60 | "background-color 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
61 | },
62 | },
63 | MuiButton: {
64 | root: {
65 | border: 0,
66 | color: "white",
67 | height: 48,
68 | padding: "0.75rem 2rem",
69 | borderRadius: "6rem",
70 | background:
71 | "conic-gradient(from 180deg at 50% 50%, #B52BBA 4.666563235223293deg, #A12CBC 23.647727966308594deg, #8C2EBE 44.85525995492935deg, #792FBF 72.45651304721832deg, #6C30C0 82.50000178813934deg, #4B32C3 127.99007892608643deg, #5831C2 160.968976020813deg, #6330C1 178.45529437065125deg, #742FC0 189.47770357131958deg, #8D2DBE 202.95226335525513deg, #A62CBC 230.65982580184937deg, #B92ABA 251.35178089141846deg, #D029B8 276.4414644241333deg, #EC27B6 306.45145654678345deg, #C729B9 331.67617321014404deg)",
72 | boxShadow: "0px 0px 60px 0px rgba(236, 39, 182, 0.60)",
73 | },
74 | },
75 | MuiAppBar: {
76 | colorInherit: {
77 | backgroundColor: "rgba(11, 3, 30, 0.95)",
78 | color: "#EEEEF0",
79 | },
80 | },
81 | },
82 | MuiTextField: {
83 | styleOverrides: {
84 | root: {
85 | borderRadius: 2,
86 | background: "rgba(43, 36, 60, 0.90)",
87 | boxShadow: "0px 0px 60px 0px rgba(236, 39, 182, 0.25)",
88 | },
89 | "&:focus": {
90 | border: "none",
91 | outline: "none",
92 | },
93 | },
94 | },
95 | MuiInputLabel: {
96 | styleOverrides: {
97 | root: {
98 | backgroundColor: "rgba(43, 36, 60, 0.90)",
99 | },
100 | },
101 | },
102 |
103 | MuiOutlinedInput: {
104 | styleOverrides: {
105 | root: {
106 | "& .MuiOutlinedInput-root.Mui-disabled .MuiOutlinedInput-notchedOutline":
107 | {
108 | outline: "none",
109 | border: "none",
110 | },
111 | "& fieldset": {
112 | transition: "border 0.1s ease-in-out",
113 | borderWidth: "0px",
114 | border: "none",
115 | outline: "none",
116 | },
117 | "&:hover fieldset": {
118 | borderWidth: "0",
119 | },
120 | "&:focus fieldset": {
121 | borderWidth: "0",
122 | },
123 | },
124 | },
125 | },
126 | });
127 |
128 | return (
129 |
130 |
131 | {props.children}
132 |
133 | );
134 | };
135 |
136 | export default StyleThemeProvider;
137 |
--------------------------------------------------------------------------------
/frontend/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vite";
2 | import react from "@vitejs/plugin-react";
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()],
7 | server: {
8 | port: 8080,
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/hardhat/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .env
3 |
4 | # Hardhat files
5 | /cache
6 | /artifacts
7 |
8 | # TypeChain files
9 | /typechain
10 | /typechain-types
11 |
12 | # solidity-coverage files
13 | /coverage
14 | /coverage.json
15 |
--------------------------------------------------------------------------------
/hardhat/README.md:
--------------------------------------------------------------------------------
1 | # Sample Hardhat Project
2 |
3 | This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.
4 |
5 | Try running some of the following tasks:
6 |
7 | ```shell
8 | npx hardhat help
9 | npx hardhat test
10 | REPORT_GAS=true npx hardhat test
11 | npx hardhat node
12 | npx hardhat run scripts/deploy.js
13 | ```
14 |
--------------------------------------------------------------------------------
/hardhat/contracts/Coins.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.0;
3 |
4 | contract CoinTracker {
5 | address public owner;
6 | mapping(address => uint256) public userTokens;
7 |
8 | modifier onlyOwner() {
9 | require(msg.sender == owner, "Only the owner can call this function");
10 | _;
11 | }
12 |
13 | constructor() {
14 | owner = msg.sender;
15 | }
16 |
17 | function addCoins(address user, uint256 amount) external onlyOwner {
18 | require(user != address(0), "Invalid user address");
19 | userTokens[user] += amount;
20 | }
21 |
22 | function reduceTokens(uint256 amount) external {
23 | require(userTokens[msg.sender] >= amount, "Insufficient tokens");
24 | userTokens[msg.sender] -= amount;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/hardhat/hardhat.config.js:
--------------------------------------------------------------------------------
1 | require("@nomicfoundation/hardhat-toolbox");
2 |
3 | /** @type import('hardhat/config').HardhatUserConfig */
4 | module.exports = {
5 | solidity: "0.8.19",
6 | };
7 |
--------------------------------------------------------------------------------
/hardhat/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hardhat-project",
3 | "devDependencies": {
4 | "@nomicfoundation/hardhat-toolbox": "^4.0.0",
5 | "hardhat": "^2.19.2"
6 | },
7 | "dependencies": {
8 | "dotenv": "^16.3.1"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/hardhat/scripts/deploy.js:
--------------------------------------------------------------------------------
1 | // We require the Hardhat Runtime Environment explicitly here. This is optional
2 | // but useful for running the script in a standalone fashion through `node
12 |