Tool that summarizes smart contracts using OpenAI GPT3, generate README.md files and allow you to ask question to chatGPT when running into errors.
Installations
npm install hardhat-contract-clarity
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.13.0
NPM Version
8.19.3
Score
31.7
Supply Chain
85.6
Quality
69.5
Maintenance
25
Vulnerability
93.7
License
Contributors
Unable to fetch Contributors
Languages
TypeScript (57.76%)
JavaScript (42.24%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
marc-aurele-besner
Download Statistics
Total Downloads
11,168
Last Day
1
Last Week
10
Last Month
123
Last Year
1,422
GitHub Statistics
MIT License
2 Stars
104 Commits
2 Watchers
8 Branches
1 Contributors
Updated on Nov 16, 2024
Package Meta Information
Latest Version
0.1.2
Package Id
hardhat-contract-clarity@0.1.2
Unpacked Size
85.12 kB
Size
16.42 kB
File Count
49
NPM Version
8.19.3
Node Version
18.13.0
Published on
Mar 03, 2023
Total Downloads
Cumulative downloads
Total Downloads
11,168
Last Day
-75%
1
Compared to previous day
Last Week
-63%
10
Compared to previous week
Last Month
57.7%
123
Compared to previous month
Last Year
-84.5%
1,422
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
hardhat-contract-clarity
db db .d8b. d8888b. d8888b. db db .d8b. d888888b .o88b. .d88b. d8b db d888888b d8888b. .d8b. .o88b. d888888b .o88b. db .d8b. d8888b. d888888b d888888b db db
88 88 d8' `8b 88 `8D 88 `8D 88 88 d8' `8b `~~88~~' d8P Y8 .8P Y8. 888o 88 `~~88~~' 88 `8D d8' `8b d8P Y8 `~~88~~' d8P Y8 88 d8' `8b 88 `8D `88' `~~88~~' `8b d8'
88ooo88 88ooo88 88oobY' 88 88 88ooo88 88ooo88 88 8P 88 88 88V8o 88 88 88oobY' 88ooo88 8P 88 8P 88 88ooo88 88oobY' 88 88 `8bd8'
88~~~88 88~~~88 88`8b 88 88 88~~~88 88~~~88 88 C8888D 8b 88 88 88 V8o88 88 88`8b 88~~~88 8b 88 C8888D 8b 88 88~~~88 88`8b 88 88 88
88 88 88 88 88 `88. 88 .8D 88 88 88 88 88 Y8b d8 `8b d8' 88 V888 88 88 `88. 88 88 Y8b d8 88 Y8b d8 88booo. 88 88 88 `88. .88. 88 88
YP YP YP YP 88 YD Y8888D' YP YP YP YP YP `Y88P' `Y88P' VP V8P YP 88 YD YP YP `Y88P' YP `Y88P' Y88888P YP YP 88 YD Y888888P YP YP
This Hardhat plugin add 3 tasks to the Hardhat, to summarize a smart contract in human readable format using OpenAI GPT-3, to create a readme looking at your package.json and a task to ask question to chatGPT when running into errors.
Install Hardhat-contract-clarity
To install the Hardhat Contract Clarity Plugin, run the following command:
1. Install this package
With NPM
1npm install hardhat-contract-clarity --save-dev
Or with Yarn
1yarn add hardhat-contract-clarity --save-dev
2. Import/Require this package in your hardhat.config.js/.ts
Inside inside hardhat.config.js
1require("hardhat-contract-clarity");
or inside hardhat.config.ts (Typescript)
1import 'hardhat-contract-clarity'
Directories
Tasks
The plugin adds one tasks to the Hardhat CLI:
1npx hardhat clarity
Task: clarity
This task is used to summarize a smart contract in human readable format using OpenAI GPT-3.
Usage: hardhat [GLOBAL OPTIONS] clarity --contract
OPTIONS:
--contract What contract you want to summarize? --openai-key What is your OpenAI API Key? (default: "") --output Where to save the summary --flatten Flatten the contract before summarizing? (default: false)
clarity: Summarize a smart contract with ChatGPT
1npx hardhat readme
Task: readme
This task is used to generate a README.md file for your project package.json.
Usage: hardhat [GLOBAL OPTIONS] readme --output
OPTIONS:
--openai-key What is your OpenAI API Key? (default: "") --output Where to save the summary
readme: Generate a README.md file for your project
1npx hardhat aihelp
Task: aihelp
This task is used to ask question to chatGPT when running into errors.
Usage: hardhat [GLOBAL OPTIONS] aihelp --error
OPTIONS:
--openai-key What is your OpenAI API Key? (default: "") --error What is your error message? (default: "")
aihelp: Provide a error message and get help from ChatGPT
Functions
Function allow you to use the clarity tool in your code.
1const { clarity } = require('hardhat'); 2 3clarity.clarity( 4 contract?: string, 5 output?: string, 6 openAIKey?: string 7 flatten?: boolean 8) 9 10clarity.readme( 11 output?: string, 12 openAIKey?: string 13) 14 15clarity.AIhelp( 16 error?: string, 17 openAIKey?: string 18)
Configuration
These configuration are optional. To configure the plugin and control at 100% the request to chatGPT API you can use the following options in your hardhat.config.js/.ts:
1clarity: { 2 openAIKey: string | undefined 3 summary: { 4 contract?: string | undefined 5 output?: string | undefined 6 model?: string | undefined 7 prompt?: string | undefined 8 temperature?: number | undefined 9 max_tokens?: number | undefined 10 top_p?: number | undefined 11 frequency_penalty?: number | undefined 12 presence_penalty?: number | undefined 13 }, 14 readme: { 15 output?: string | undefined 16 model?: string | undefined 17 prompt?: string | undefined 18 temperature?: number | undefined 19 max_tokens?: number | undefined 20 top_p?: number | undefined 21 frequency_penalty?: number | undefined 22 presence_penalty?: number | undefined 23 }, 24 AIhelp: { 25 error?: string | undefined 26 model?: string | undefined 27 prompt?: string | undefined 28 promptEnd?: string | undefined 29 temperature?: number | undefined 30 max_tokens?: number | undefined 31 top_p?: number | undefined 32 frequency_penalty?: number | undefined 33 presence_penalty?: number | undefined 34 } 35}
Here is the default configuration:
1clarity: { 2 openAIKey: OPENAI_API_KEY, 3 summary: { 4 contract: 'contracts/Lock.sol', 5 output: 'clarity.txt', 6 model: 'gpt-3.5-turbo', 7 prompt: 'Summarize the following contract: 8 9', 10 temperature: 0.7, 11 max_tokens: 2000, 12 top_p: 1.0, 13 frequency_penalty: 0.0, 14 presence_penalty: 0.0, 15 }, 16 readme: { 17 output: 'clarity-readme.md', 18 model: 'gpt-3.5-turbo', 19 prompt: 'With the following package.json, can you generate a descriptive readme in markdown? 20 21', 22 temperature: 0.7, 23 max_tokens: 2000, 24 top_p: 1.0, 25 frequency_penalty: 0.0, 26 presence_penalty: 0.0, 27 }, 28 AIhelp: { 29 error: 'How to use hardhat with openAI', 30 model: 'gpt-3.5-turbo', 31 prompt: 'Using hardhat, I have this error message: 32 33', 34 promptEnd: 'Can you explain why and how I can fix the error: 35 36', 37 temperature: 0.7, 38 max_tokens: 2000, 39 top_p: 1.0, 40 frequency_penalty: 0.0, 41 presence_penalty: 0.0, 42 }, 43}
Here is a description of each option:
-
openAIKey: This setting is a string that contains the API key for accessing OpenAI's GPT-3 language model. If this setting is undefined, the plugin will not be able to access the language model.
-
clarity.summary.contract: This setting is a string that contains the name of the Solidity contract that the plugin will generate a summary for. If this setting is undefined, the plugin will not generate a summary.
-
clarity.summary.output: This setting is a string that contains the name of the output file that the plugin will write the summary to. If this setting is undefined, the plugin will write the summary to the console.
-
clarity.summary.model: This setting is a string that contains the name of the GPT-3.5 language model that the plugin will use to generate the summary. If this setting is undefined, the plugin will use the default language model.
-
clarity.summary.prompt: This setting is a string that contains the prompt that the plugin will use to generate the summary. If this setting is undefined, the plugin will use a default prompt.
-
clarity.summary.temperature: This setting is a number that controls the randomness of the language model's output. A higher value will result in more random output. If this setting is undefined, the plugin will use a default value.
-
clarity.summary.max_tokens: This setting is a number that controls the length of the language model's output. If this setting is undefined, the plugin will use a default value.
-
clarity.summary.top_p: This setting is a number that controls the diversity of the language model's output. A lower value will result in more diverse output. If this setting is undefined, the plugin will use a default value.
-
clarity.summary.frequency_penalty: This setting is a number that controls the frequency penalty for the language model's output. A higher value will result in the language model generating fewer repeated phrases. If this setting is undefined, the plugin will use a default value.
-
clarity.summary.presence_penalty: This setting is a number that controls the presence penalty for the language model's output. A higher value will result in the language model generating fewer words that do not appear in the input prompt. If this setting is undefined, the plugin will use a default value.
-
clarity.readme.output: This setting is a string that contains the name of the output file that the plugin will write the generated README to. If this setting is undefined, the plugin will not write a README file.
-
clarity.readme.model: This setting is a string that contains the name of the GPT-3.5 language model that the plugin will use to generate the README. If this setting is undefined, the plugin will use the default language model.
-
clarity.readme.prompt: This setting is a string that contains the prompt that the plugin will use to generate the README. If this setting is undefined, the plugin will use a default prompt.
-
clarity.readme.temperature: This setting is a number that controls the randomness of the language model's output. A higher value will result in more random output. If this setting is undefined, the plugin will use a default value.
-
clarity.readme.max_tokens: This setting is a number that controls the length of the language model's output. If this setting is undefined, the plugin will use a default value.
-
clarity.readme.top_p: This setting is a number that controls the diversity of the language model's output. A lower value will result in more diverse output. If this setting is undefined, the plugin will use a default value.
-
clarity.readme.frequency_penalty: This setting is a number that controls the frequency penalty for the language model's output. A higher value will result in the language model generating fewer repeated phrases. If this setting is undefined, the plugin will use a default value.
-
clarity.readme.presence_penalty: This setting is a number that controls the presence penalty for the language model's output. A higher value will result in the language model generating fewer words that do not appear in the input prompt. If this setting is undefined, the plugin will use a default value.
-
clarity.AIhelp.error: This setting is a string that contains the name of the output file that the plugin will write the generated answer to.
-
clarity.AIhelp.model: This setting is a string that contains the name of the GPT-3.5 language model that the plugin will use to generate the answer. If this setting is undefined, the plugin will use the default language model.
-
clarity.AIhelp.prompt: This setting is a string that contains the prompt that the plugin will use to generate the answer. If this setting is undefined, the plugin will use a default prompt.
-
clarity.AIhelp.promptEnd: This setting is a string that contains the end of the prompt that the plugin will use to generate the answer. If this setting is undefined, the plugin will use a default prompt.
-
clarity.AIhelp.temperature: This setting is a number that controls the randomness of the language model's output. A higher value will result in more random output. If this setting is undefined, the plugin will use a default value.
-
clarity.AIhelp.max_tokens: This setting is a number that controls the length of the language model's output. If this setting is undefined, the plugin will use a default value.
-
clarity.AIhelp.top_p: This setting is a number that controls the diversity of the language model's output. A lower value will result in more diverse output. If this setting is undefined, the plugin will use a default value.
-
clarity.AIhelp.frequency_penalty: This setting is a number that controls the frequency penalty for the language model's output. A higher value will result in the language model generating fewer repeated phrases. If this setting is undefined, the plugin will use a default value.
-
clarity.AIhelp.presence_penalty: This setting is a number that controls the presence penalty for the language model's output. A higher value will result in the language model generating fewer words that do not appear in the input prompt. If this setting is undefined, the plugin will use a default value.
Directory Tree
hardhat-contract-clarity/
│ .eslintrc.js
│ .npmignore
│ .prettierrc
│ CONTRIBUTING.md
│ LICENSE
│ README.md
│ awesome-readme.config.js
│ package-lock.json
│ package.json
│ tsconfig.json
│ tsconfig.prod.json
│ tslint.json
└─── src/
│ Clarity.ts
│ README.md
│ getClarity.ts
│ getHelp.ts
│ getReadme.ts
│ index.ts
│ serveTasks.ts
│ type-extensions.ts
│ types.ts
│ utils.ts
Don't hesitate to contribute to this project.

No vulnerabilities found.

No security vulnerabilities found.