Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Cookbook.dev's AI Web3 Technical Documentation Bot & Tutorial on Deploying to Manta Pacific using Cookbook.dev #233

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions docs/zkShuffle/Deploy/05-Cookbook.dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Cookbook.dev

## What is Cookbook.dev?

Cookbook.dev is an open-source smart contract registry where developers can find solidity primitives, libraries, and smart contracts for protocols across dozens of blockchains, including Manta Pacific.

In this tutorial, we'll walk through searching for or importing a protocol or smart contract on Cookbook.dev and deploying it to Manta Pacific using Cookbook.dev's no-code deploy and using Cookbook with Remix, Hardhat and Foundry.

## Getting Started with Cookbook.dev

Navigate to [cookbook.dev/chains/Manta-Pacific](https://www.cookbook.dev/chains/Manta-Pacific?utm=mantadocs) and explore **Protocols** on Manta Pacific, or search for specific smart contracts or keywords in the search bar or **Contracts** menu tab.

To learn about a smart contract on Cookbook.dev, select the protocol, and select `Expand`. This opens the code alongside ChefGPT, Cookbook.dev's AI Solidity assistant.

Highlight selections of the code and press **Analyze Snippet** to get more information about the smart contract code you're looking at, or ask ChefGPT questions about Manta Pacific, Solidity, or your smart contract.

### Import any Smart Contract Code into Cookbook.dev

Import verified smart contract code into Cookbook to fork, learn about, or build with by inputting any smart contract address that's verified on an EVM-based block explorer into the Cookbook.dev search bar.

## Deploy your Smart Code code to Manta Pacific using Cookbook.dev and Remix

### Method #1 - Using the Cookbook.dev website with open in Remix

On a smart contract or protocol page in Cookbook, select the **Open in Remix** option. Your smart contract will automatically be opened in a new Remix workspace.

**Compile** your smart contract within Remix. Most contracts opened with Cookbook will automatically compile within Remix.

Once compiled, **deploy** the smart contract in Remix.

To deploy the smart contract to Manta Pacific Network, make sure your wallet is set to the Manta Pacific mainnnet or testnet and then connect to Remix by selecting injected provider - Metamask Wallet in the **environments** tab within the **deploy** screen.

Once deployed, we can interact with our smart contract within Remix.

### Method #2 - Using the Cookbook Remix Plug-in within the Remix IDE

Go to [Remix.Ethereum.org](https://remix.ethereum.org)

Add The Cookbook Plugin to Remix by clicking the Chef Hat Logo under **Featured Plugins** on the Remix Homepage.

Alternatively, search Cookbook and select **Activate** in the Remix Plugin Manager.

Search for any protocol or smart contract and click the search result to import the smart contract code into Remix.

Cookbook's AI solidity co-pilot, ChefGPT, is available within the Remix plugin to answer questions about Manta Pacific, Solidity, or the smart contract you're working with.

Compile and deploy the smart contract as described in **Method 1** above.

## Deploy your Smart Code code to Manta Pacific using Cookbook.dev and Hardhat

After finding the smart contract or protocol you want to work with in [Cookbook](https://www.cookbook.dev/?utm=mantadocs), select the **Download Source** option and select **Hardhat** to download the contract boilerplate. For this guide, we'll use [Cookbook's Simple ERC-20 Token Smart Contract](https://www.cookbook.dev/contracts/simple-token?utm=mantadocs).

To install the required packages and dependencies, run
```sh
npm install
```
To compile your smart contract, run
```sh
npx hardhat compile
```
Add arguments to the `constructorArgs` array in the `deploy.js` file in the `scripts` folder and save. If you do not need any arguments please leave the array empty.

In your .env.example file, add your Manta Pacifc RPC API key and add your wallet private key. Afterward change the name of the file to .env and create a gitignore to ignore your .env file.

Add the following code to your hardhat.config.js file. Be sure to change your RPC URL and the ChainID to match either mainnet or testnet

```javascript
module.exports = {
solidity: "0.8.1",
defaultNetwork: "rinkeby",
networks: {
rinkeby: {
url: "https://eth-rinkeby.alchemyapi.io/v2/123abc123abc123abc123abc123abcde",
accounts: [privateKey]
},
manta: {
url: "RPC URL", // Insert your RPC URL Here
chainId: CHAINID, //Insert your ChainID Here
}
},
}
```

To deploy your smart contract to the Manta Pacific Network, run

```sh
npx hardhat run --network (manta) scripts/deploy.js

```

## Deploy your Smart Code code to Manta Pacific using Cookbook.dev and Foundry

After finding the smart contract or protocol you want to work with in [Cookbook](https://www.cookbook.dev/chains/Manta-Pacific?utm=mantadocs), select the **Download Source** option and select **Foundry** to download the contract boilerplate.For this guide, we'll use [Cookbook's Simple ERC-20 Token Smart Contract](https://www.cookbook.dev/contracts/simple-token?utm=mantadocs).

Before you can use Foundry, you need to install Rust, a programming language required to run Foundry. Follow the installation instructions provided [here](https://doc.rust-lang.org/book/ch01-01-installation.html).

Once Rust is installed, you can install Foundry. Follow the installation instructions provided [here](https://book.getfoundry.sh/getting-started/installation#using-foundryup).


To build your contracts, Run
```sh
forge build
```

If you encounter a "stack too deep" error, try running the following command instead

```sh
forge build --via
```

In the scripts folder, uncomment all the code in the `contract.s.sol` file. Replace `"ARG1"`, `"ARG2"`, `2000` with your `Token Name`, `Token Symbol` and desired `Token Quantity` where you see the code below
```
FixedToken _contract = new FixedToken("ARG1", "ARG2", 2000);
```

Before deploying your contracts, populate the `.env` file with your Manta Pacific Network RPC URL, followed by your Wallet private key and your [Etherscan API key token values](https://etherscan.io/apis). Then, run the following command to define your environment variables globally

```sh
source .env
```

Deploy your contracts with the following command

```sh
forge script script/contract.s.sol:ContractScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
```

Your contract will be verified on the Manta Pacific block explorer automatically upon deployment.

**Further Guidance**

For more information on using Cookbook to find, learn about or build with smart contracts, check out the following resources:

- [Documentation](https://docs.cookbook.dev/)
- [Blog](https://medium.com/@cookbookdev)
- [Twitter](https://twitter.com/cookbook_dev)
- [Community](https://discord.gg/cookbook)
39 changes: 39 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,44 @@ module.exports = {
organizationName: 'Manta-Network', // github org name.
projectName: 'docs', // repo name.
themeConfig: {
prism: {
additionalLanguages: ['solidity'],
},
cookbookDocsBot: {
features: {
enableExplainSnippet: true,
},
dataSources: [
{
name: "Manta",
hostname: "https://docs.manta.network",
}
],
greetingMessage:
"Hi! Ask me anything about Manta. Here are some questions to get started.",
explainPromptTemplate: "Could you please elaborate on the content within the specified section? The section I'm referring to is:\n```\n$1\n```\n\nI'm seeking a comprehensive explanation to better understand the nuances, procedures, or concepts outlined in this particular segment. Your clarification will greatly assist in grasping the intricacies of the topic at hand.",
dialogTitle: "Ask Cookbook",
suggestions: [
"What's Manta?",
"How are Manta Pacific and Atlantic different?",
"How do I deploy to Manta Pacific?",
],
messageInputPlaceholder:
"Ask anything about Manta!",
ui: {
modalContainer: {
width: "1000px",
height: "800px",
background: "var(--ifm-background-surface-color)",
className: "chefgpt-modal-container",
},
},
avatars: {
ChefGPT: "https://docs.manta.network/img/manta2.png",
User: "https://cookbook.dev/img/Richard.png",
},
apiBaseUrl: "https://simple-web3-api.herokuapp.com",
},
colorMode: {
respectPrefersColorScheme: true,
},
Expand Down Expand Up @@ -116,6 +154,7 @@ module.exports = {
},
],
plugins: [
"@cookbookdev/docusaurus-jsx-runtime-fallback-plugin",
[
require.resolve('@cmfcmf/docusaurus-search-local'),
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"dependencies": {
"@aldridged/docusaurus-plugin-lunr": "^1.0.0-alpha.10",
"@cmfcmf/docusaurus-search-local": "^0.11.0",
"@cookbookdev/docusaurus-chefgpt": "^1.1.12",
"@cookbookdev/docusaurus-jsx-runtime-fallback-plugin": "^1.0.1",
"@docusaurus/core": "^2.3.1",
"@docusaurus/plugin-client-redirects": "^2.3.1",
"@docusaurus/preset-classic": "^2.3.1",
Expand Down
2 changes: 2 additions & 0 deletions src/theme/Navbar/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import NavbarLayout from '@theme/Navbar/Layout';
import NavbarContent from '@theme/Navbar/Content';
import ChefGPT from "@cookbookdev/docusaurus-chefgpt/theme/SearchBar";
export default function Navbar() {
return (
<NavbarLayout>
<NavbarContent />
<ChefGPT />
</NavbarLayout>
);
}
Loading
Loading