Skip to content

Instantly share code, notes, and snippets.

@FoobarProtocol
Last active October 16, 2023 22:40
Show Gist options
  • Save FoobarProtocol/6e5d4acc387080350472c2bc8ead8d46 to your computer and use it in GitHub Desktop.
Save FoobarProtocol/6e5d4acc387080350472c2bc8ead8d46 to your computer and use it in GitHub Desktop.
Bunch of additional options for gradio related to smart contracts ; basically porting the functionality of the OpenZeppelin Wizard directly to the API ecosystem
import gr
def smart_contract_prompt_builder(
contract_type,
state_variables,
functions,
visibility,
modifiers,
features,
access_control,
upgradeability,
symbol,
license,
token_standard,
oracles,
decimals,
supply,
owner,
whitelist,
blacklist,
governance,
fee_structure
):
return {
'contract_type': contract_type,
'state_variables': state_variables,
'functions': functions,
'visibility': visibility,
'modifiers': modifiers,
'features': features,
'access_control': access_control,
'upgradeability': upgradeability,
'symbol': symbol,
'license': license,
'token_standard': token_standard,
'oracles': oracles,
'decimals': decimals,
'supply': supply,
'owner': owner,
'whitelist': whitelist,
'blacklist': blacklist,
'governance': governance,
'fee_structure': fee_structure
}
demo = gr.Interface(
smart_contract_prompt_builder,
[
gr.Textbox(default="MyContract", label="Contract Name"),
gr.Textbox(default="uint256 public count", placeholder="State Variables (comma separated)", label="State Variables"),
gr.Textbox(default="function1, function2, function3", placeholder="Functions (comma separated)", label="Functions"),
gr.Textbox(default="public", placeholder="Visibility", label="Visibility"),
gr.Textbox(default="payable, view, pure", placeholder="Modifiers (comma separated)", label="Modifiers"),
gr.Textbox(default="Mintable, Burnable, Pausable, Permit, Votes, Flash Minting", placeholder="Features (comma separated)", label="Features"),
gr.Textbox(default="Ownable, Roles", placeholder="Access Control", label="Access Control"),
gr.Textbox(default="Transparent, UUPS", placeholder="Upgradeability (comma separated)", label="Upgradeability"),
gr.Textbox(default="SYMB", label="Symbol"),
gr.Textbox(default="MIT", label="License"),
gr.Textbox(default="ERC1155, ERC721, ERC165, ERC20", placeholder="Token Standards (comma separated)", label="Token Standard"),
gr.Textbox(default="", placeholder="Oracles (comma separated)", label="Oracles"),
gr.Textbox(default="", placeholder="Decimals", label="Decimals"),
gr.Textbox(default="", placeholder="Supply", label="Supply"),
gr.Textbox(default="", placeholder="Owner", label="Owner"),
gr.Textbox(default="", placeholder="Whitelisted Addresses (comma separated)", label="Whitelist"),
gr.Textbox(default="", placeholder="Blacklisted Addresses (comma separated)", label="Blacklist"),
gr.Textbox(default="", placeholder="Governance", label="Governance"),
gr.Textbox(default="", placeholder="Fee Structure", label="Fee Structure")
],
"json"
)
if __name__ == "__main__":
demo.launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment