<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Devind Dev</title>
    <description>The latest articles on DEV Community by Devind Dev (@devindxdev).</description>
    <link>https://dev.to/devindxdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F721922%2Fd6410ed4-af6d-4dd0-9d56-45f65ed7a0c9.png</url>
      <title>DEV Community: Devind Dev</title>
      <link>https://dev.to/devindxdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devindxdev"/>
    <language>en</language>
    <item>
      <title>Creating a Simple Discord Bot in Rust with Serenity</title>
      <dc:creator>Devind Dev</dc:creator>
      <pubDate>Tue, 19 Nov 2024 07:36:49 +0000</pubDate>
      <link>https://dev.to/devindxdev/creating-a-simple-discord-bot-in-rust-with-serenity-16nm</link>
      <guid>https://dev.to/devindxdev/creating-a-simple-discord-bot-in-rust-with-serenity-16nm</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@rozetsky?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Ant Rozetsky&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/a-car-with-a-light-on-top-gvs6ViTguyo?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the world of software, simplicity is power. Building something complex like a Discord bot doesn’t have to be overwhelming—it can be clear, incremental, and satisfying. Let’s take a journey into creating a bot in Rust, the language known for precision and performance. By the end, you’ll have a bot that responds to a simple command, and more importantly, you’ll understand every step.&lt;/p&gt;

&lt;p&gt;Like crafting a habit, building a bot starts with a small, achievable step. Here, that step is responding to a single command: &lt;code&gt;!ping&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Rust? Why a Bot?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Rust&lt;/strong&gt; gives you the tools to write clean, safe, and efficient code. It’s not just about coding; it’s about coding &lt;em&gt;right&lt;/em&gt;. Combine that with Discord, where bots transform communities into dynamic hubs, and you’ve got a chance to create something truly impactful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Laying the Foundation
&lt;/h3&gt;

&lt;p&gt;First, set up your environment. Like any good project, we need the tools ready before we build.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Tools You’ll Need:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rust Installed&lt;/strong&gt;: Get it &lt;a href="https://www.rust-lang.org/tools/install" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discord Developer Account&lt;/strong&gt;: Create one at the &lt;a href="https://discord.com/developers/applications" rel="noopener noreferrer"&gt;Discord Developer Portal&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bot Token&lt;/strong&gt;: You’ll generate this while setting up your bot. Keep it safe—it’s your bot’s identity.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, create your project from your terminal at your desired location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo new discord-bot
cd discord-bot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Add Dependencies
&lt;/h3&gt;

&lt;p&gt;In your Cargo.toml file, include the required dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[dependencies]&lt;/span&gt;
&lt;span class="py"&gt;serenity&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.12"&lt;/span&gt;
&lt;span class="py"&gt;tokio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="py"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="py"&gt;features&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"full"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Serenity: A library for building Discord bots.&lt;/li&gt;
&lt;li&gt;Tokio: Provides an asynchronous runtime for handling concurrent tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save the file and run:&lt;br&gt;
&lt;code&gt;cargo build&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Implement the Bot
&lt;/h3&gt;

&lt;p&gt;Open src/main.rs and replace its contents with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;serenity&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;async_trait&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;serenity&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;model&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;serenity&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;model&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Ready&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;serenity&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;prelude&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Define the event handler&lt;/span&gt;
&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Handler&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;#[async_trait]&lt;/span&gt;
&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;EventHandler&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;Handler&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Handle incoming messages&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Ignore messages from bots&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="py"&gt;.author.bot&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Respond to the "!ping" command&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="py"&gt;.content&lt;/span&gt;&lt;span class="nf"&gt;.eq_ignore_ascii_case&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"!ping"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Received !ping command from {}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="py"&gt;.author.name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="c1"&gt;// Send a plain text response&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;why&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="py"&gt;.channel_id&lt;/span&gt;&lt;span class="nf"&gt;.say&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="py"&gt;.http&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Pong!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="k"&gt;.await&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nd"&gt;eprintln!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error sending message: {:?}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;why&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Log when the bot is ready&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{} is connected and ready!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ready&lt;/span&gt;&lt;span class="py"&gt;.user.name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;#[tokio::main]&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Retrieve the bot token from the environment&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DISCORD_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Expected a token in the environment"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Specify the bot's intents&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;intents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;GatewayIntents&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;GUILD_MESSAGES&lt;/span&gt;
        &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;GatewayIntents&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;DIRECT_MESSAGES&lt;/span&gt;
        &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nn"&gt;GatewayIntents&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;MESSAGE_CONTENT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Initialize the bot client&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;intents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;.event_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;.await&lt;/span&gt;
        &lt;span class="nf"&gt;.expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error creating client"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Start the bot&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;why&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="nf"&gt;.start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="k"&gt;.await&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;eprintln!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Client error: {:?}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;why&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Key Features of the Code:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Command Handling: The bot listens for the !ping command and replies with "Pong!".&lt;/li&gt;
&lt;li&gt;Event Logging: Logs activity when the bot is ready or when it processes commands.&lt;/li&gt;
&lt;li&gt;Safety: Ignores messages from other bots, including itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Invite the Bot
&lt;/h3&gt;

&lt;p&gt;To invite the bot to your server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the Discord Developer Portal.&lt;/li&gt;
&lt;li&gt;Under your bot application, navigate to OAuth2 &amp;gt; URL Generator.&lt;/li&gt;
&lt;li&gt;Select the bot scope and appropriate permissions (e.g., Send Messages).&lt;/li&gt;
&lt;li&gt;Copy the generated URL, paste it in your browser, and invite the bot to your server.&lt;/li&gt;
&lt;li&gt;Now keep your bot token ready for the next step.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 5: Run and Test
&lt;/h3&gt;

&lt;p&gt;Add Your Token&lt;br&gt;
Export your bot token as an environment variable:&lt;/p&gt;

&lt;p&gt;In your terminal, &lt;br&gt;
Linux/MacOS:&lt;br&gt;
&lt;code&gt;export DISCORD_TOKEN="your-bot-token-here"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Windows (Command Prompt):&lt;br&gt;
&lt;code&gt;set DISCORD_TOKEN=your-bot-token-here&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Build and Run&lt;br&gt;
Compile and run your bot with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cargo build
cargo run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Testing the Bot
&lt;/h3&gt;

&lt;p&gt;In any text channel where your bot has permissions, type: &lt;code&gt;!ping&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The bot will reply like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61fx9xzg46ene50py5jv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61fx9xzg46ene50py5jv.png" alt="ping response by discord bot developed with rust" width="718" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;You’ve now created a simple Discord bot using Rust and Serenity. This foundational bot responds to a basic command and provides a starting point for more complex functionality. With this setup, you can expand the bot to include custom commands, interactive responses, and integrations with external APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;p&gt;Here are some potential enhancements for your bot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add More Commands: Implement additional features such as &lt;code&gt;!help&lt;/code&gt;, &lt;code&gt;!joke&lt;/code&gt;, or &lt;code&gt;!weather.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use Embeds: Create visually rich responses with Discord embeds.&lt;/li&gt;
&lt;li&gt;Integrate APIs: Fetch live data for commands or connect to other services.&lt;/li&gt;
&lt;li&gt;For more details, refer to the Serenity documentation. With Rust’s power and Serenity’s flexibility, your bot can become an invaluable tool for your Discord community.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Creating an NFT on Solana with Metaplex Candy Machine.</title>
      <dc:creator>Devind Dev</dc:creator>
      <pubDate>Sun, 31 Oct 2021 14:16:53 +0000</pubDate>
      <link>https://dev.to/devindxdev/creating-an-nft-on-solana-with-metaplex-candy-machine-4agp</link>
      <guid>https://dev.to/devindxdev/creating-an-nft-on-solana-with-metaplex-candy-machine-4agp</guid>
      <description>&lt;h2&gt;
  
  
  Guide Overiew
&lt;/h2&gt;

&lt;p&gt;After what felt like walking through a mine field trying to figure out how to create my own &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt; on Solana with the current guides, I decided to put together a guide myself in a very beginner friendly fashion.&lt;/p&gt;

&lt;p&gt;I won't be taking a deeper dive into the specifics of how everything works, but rather help people with zero knowledge of rust obtain a general understanding on how to create their very own &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt; on Solana with the help of Metaplex candy machine and a web starter kit.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I used &lt;strong&gt;Ubuntu 21.10 - Wayland&lt;/strong&gt; for it. Some things may vary depending on the operating system you are running.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a Metaplex Candy Machine?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Metaplex&lt;/code&gt; is a command line tool that interacts with the candy-machine program. In this guide, we will use it to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Upload&lt;/em&gt; your images along with their metadata to &lt;em&gt;arweave&lt;/em&gt;, then register them on the Solana blockchain.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Verify&lt;/em&gt; that the state of your candy machine is valid and complete.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Mint&lt;/em&gt; individual tokens.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Candy Machine&lt;/code&gt; is a system that manages fair mints.&lt;br&gt;
• The minting process starts and finishes at the same time for everyone.&lt;br&gt;
• It won't accept your funds if there are no more &lt;a href="https://dev.to/devindxdeveloper/creating-an-nft-on-solana-with-metaplex-candy-machine-4agp"&gt;NFTs&lt;/a&gt; to sell.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;NodeJS&lt;/a&gt; &lt;em&gt;(version 14.17.6)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.solana.com/cli/install-solana-cli-tools" rel="noopener noreferrer"&gt;SolanaCLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/metaplex-foundation/metaplex.git" rel="noopener noreferrer"&gt;Metaplex CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://phantom.app/" rel="noopener noreferrer"&gt;Phantom Wallet&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have a different version of Node installed on your system, you can use &lt;a href="https://github.com/nvm-sh/nvm" rel="noopener noreferrer"&gt;nvm&lt;/a&gt; which allows you to quickly install and use different versions of node via the command line.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Installing The SolanaCLI
&lt;/h3&gt;

&lt;p&gt;Solana already has really well made guides on installing and using the Solana command line.&lt;br&gt;
• &lt;a href="https://docs.solana.com/cli/install-solana-cli-tools" rel="noopener noreferrer"&gt;Install Solana Command Line Tools&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Using Devnet
&lt;/h4&gt;

&lt;p&gt;Devnet is really useful for developers to test out their programs and applications.&lt;/p&gt;

&lt;p&gt;You can set your default Solana url to devnet using:&lt;br&gt;
&lt;code&gt;$ solana config set --url https://api.devnet.solana.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, let's create a devnet wallet:&lt;br&gt;
&lt;code&gt;$ solana-keygen new --outfile ~/.config/solana/devnet.json&lt;/code&gt;&lt;br&gt;
Remember to store your seed phrase somewhere safe.&lt;/p&gt;

&lt;p&gt;I highly recommend making devnet your default &lt;em&gt;keypair&lt;/em&gt;&lt;br&gt;
&lt;code&gt;$ solana config set --keypair ~/.config/solana/devnet.json&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Funding The Devnet Wallet
&lt;/h4&gt;

&lt;p&gt;Firstly, let’s make sure that we’re on devnet by checking the configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ solana config get
//Output:
Config File: /Users/dev/.config/solana/cli/config.yml
RPC URL: https://api.devnet.solana.com
WebSocket URL: wss://api.devnet.solana.com/ (computed)
Keypair Path: /Users/dev/.config/solana/devnet.json
Commitment: confirmed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s fund that wallet:&lt;br&gt;
Firstly, We check the balance of our current wallet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ solana balance 
//Output:
0 SOL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we airdrop the amount of SOL to our wallet. Remember, the amount is capped to 5 SOL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ solana airdrop 4
//Output
Requesting airdrop of 4

Signature: Transaction Signature

4 SOL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, Let’s check our balance to confirm the airdrop was successful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ solana balance
//Output:
4 SOL //This can vary depending on the balance you initially had.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In case you’re confused by any of the above steps, you can check the manuals to get a better understanding by running:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ solana help config
$ solana help balance
$ solana help airdrop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configuring Phantom Wallet
&lt;/h4&gt;

&lt;p&gt;After setting up your phantom wallet, we can link our newly created devnet wallet above to phantom.&lt;br&gt;
To do so, first we need to open its settings, click on &lt;code&gt;Change Network&lt;/code&gt; and select &lt;code&gt;Devnet&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we need to obtain the devnet wallet private key. To obtain that, open your terminal and &lt;code&gt;cat&lt;/code&gt; to view the contents of the &lt;code&gt;keypair.json&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat .config/solana/devnet.json
//Output:
[12,22,.....]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now copy the output you received and open phantom wallet. Click on the top left navigation menu and click on &lt;code&gt;Add/Connect Wallet&lt;/code&gt; and then click on &lt;code&gt;Import Private Key&lt;/code&gt; and give it a suitable name and paste the contents we copied before in the Private Key field.&lt;/p&gt;

&lt;p&gt;You should be able to see 4 SOL in your wallet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running Candy Machine CLI
&lt;/h3&gt;

&lt;p&gt;Please ensure that you have &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;yarn&lt;/code&gt; installed before proceeding.&lt;/p&gt;

&lt;p&gt;Also install &lt;code&gt;ts-node&lt;/code&gt; by running:&lt;br&gt;
&lt;code&gt;$ npm install -g ts-node&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s clone the metaplex project into the location of your choice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/metaplex-foundation/metaplex.git
$ cd metaplex/js
$ yarn install &amp;amp;&amp;amp; yarn bootstrap &amp;amp;&amp;amp; yarn build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the command line utility,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$  ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts help
Usage: candy-machine-cli [options] [command]

Options:
  -V, --version                          output the version number
  -h, --help                             display help for command

Commands:
  upload [options] &amp;lt;directory&amp;gt;
  verify [options]
  verify_price [options]
  create_candy_machine [options]
  update_candy_machine [options]
  mint_one_token [options]
  sign [options]
  sign_candy_machine_metadata [options]
  help [command]                         display help for command
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Organizing &amp;amp; Uploading Your Assets
&lt;/h3&gt;

&lt;p&gt;For this guide, we will be using pre-made assets which you can download by &lt;a href="https://drive.google.com/drive/folders/1DoV44eED8PrgmMeAL-i-ceJ3NAx1ND5L?usp=sharing" rel="noopener noreferrer"&gt;clicking here.&lt;/a&gt; courtesy of &lt;a href="https://github.com/kevinfaveri/solana-candy-factory" rel="noopener noreferrer"&gt;solana-candy-factory&lt;/a&gt;&lt;br&gt;
Place this &lt;code&gt;assets&lt;/code&gt; folder in a suitable location.&lt;br&gt;
Here is how you should organize your &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt; files to upload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls assets | sort -n
0.json
0.png
1.json
1.png
2.json
2.png
3.json
3.png
....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can notice that these files come in numerical pairs, that is &lt;code&gt;1.png&lt;/code&gt; and &lt;code&gt;1.json&lt;/code&gt; are the two halves of the &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT.&lt;/a&gt; The &lt;code&gt;png&lt;/code&gt; file is the art work and the &lt;code&gt;json&lt;/code&gt; file contains the metadata.&lt;/p&gt;

&lt;p&gt;The directory name &lt;code&gt;assets&lt;/code&gt; does not matter. You can go with anything you like.&lt;/p&gt;

&lt;h4&gt;
  
  
  Validating Your Assets
&lt;/h4&gt;

&lt;p&gt;This may feel tedious but it's just as important. Checkout the the manual on carrying this out at&lt;br&gt;
&lt;a href="https://docs.metaplex.com/nft-standard" rel="noopener noreferrer"&gt;https://docs.metaplex.com/nft-standard&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Uploading Your Project Assets
&lt;/h3&gt;

&lt;p&gt;Now that we have the funds, assets all organized and vaidated, we can proceed with the fun stuff!&lt;/p&gt;

&lt;p&gt;We will proceed with uploading our assets with the CLI. Remember, our assets are located at &lt;code&gt;metaplex\js\packages\cli\example-assets&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts upload assets --env devnet --keypair ~/.config/solana/devnet.json

//Output
Processing file: 0
Processing file: 1
Processing file: 2
Processing file: 3
Done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By uploading, it sends the files to Arweave and also registers those files with your candy machine. Both Arweave and Solana are initialized after a successful run.&lt;/p&gt;

&lt;h4&gt;
  
  
  Validating Your Candy Machine
&lt;/h4&gt;

&lt;p&gt;You can confirm the health and status of your on-chain assets using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts verify --env devnet --keypair ~/.config/solana/devnet.json
//Output:
Looking at key  0
Name {redacted-name} 0 with https://arweave.net/{redacted-tx-id} checked out
Looking at key  1
Name {redacted-name} 1 with https://arweave.net/{redacted-tx-id} checked out
Looking at key  2
Name {redacted-name} 2 with https://arweave.net/{redacted-tx-id} checked out
Looking at key  3
Name {redacted-name} 3 with https://arweave.net/{redacted-tx-id} checked out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Starting Your Candy Machine
&lt;/h4&gt;

&lt;p&gt;After verifying that our assets are good to go, we can finally start the candy machine.&lt;br&gt;
&lt;code&gt;$ ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts create_candy_machine --env devnet --keypair ~/.config/solana/devnet.json&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Updating Your Candy Machine
&lt;/h4&gt;

&lt;p&gt;We can modify our candy machine details to include a start date and/or price etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts update_candy_machine --env devnet --keypair ~/.config/solana/devnet.json --price 1 --date "29 Oct 2021 00:12:00 GMT"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Minting Our NFT
&lt;/h2&gt;

&lt;p&gt;To mint our &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt;, we can use &lt;code&gt;mint_one_token&lt;/code&gt; like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ts-node metaplex/js/packages/cli/src/candy-machine-cli.ts mint_one_token --env devnet --keypair ~/.config/solana/devnet.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If all goes well, you can now open your phantom wallet, open the collectibles page (It's beside the $ symbol on the bottom) and voila! Your newly minted &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt; will be there!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up The Web Starter Kit
&lt;/h2&gt;

&lt;p&gt;Now that we've successfully minted an &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT&lt;/a&gt; into our wallet, let's make a web application to carry out the mint instead! &lt;br&gt;
&lt;strong&gt;Note:&lt;/strong&gt; This project is very new and could cause some issues, if it does then please report it on github.&lt;/p&gt;

&lt;p&gt;The goal of the project is for you to be able to configure it and customize it to your liking.&lt;/p&gt;

&lt;p&gt;Fork the project and then clone it to your desired location.&lt;br&gt;
Link: &lt;a href="https://github.com/exiled-apes/candy-machine-mint" rel="noopener noreferrer"&gt;https://github.com/exiled-apes/candy-machine-mint&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we need to build the project,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd candy-machine-mint
yarn install
yarn build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where things get a little bit complicated. When we uploaded our &lt;a href="https://dev.to/devindxdeveloper/creating-an-nft-on-solana-with-metaplex-candy-machine-4agp"&gt;NFTs&lt;/a&gt;, a cache file was created in the &lt;strong&gt;same&lt;/strong&gt; directory as our assets directory. However, this &lt;code&gt;.cache&lt;/code&gt; folder is hidden! If you're on ubuntu, use &lt;code&gt;ctrl+h&lt;/code&gt; to display hidden files.&lt;/p&gt;

&lt;p&gt;Once you have discovered that folder, open it and you'll find &lt;code&gt;devnet-temp&lt;/code&gt; file. Open it in your IDE and you'll see the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"program"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"uuid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Ch3xxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"config"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Ch3xxx"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"items"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://arweave.net/xxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TEST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"onChain"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"devnet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"cacheName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"temp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"authority"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"9xJxxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"candyMachineAddress"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3Wmxxxx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"startDate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1632615120&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're going to need all this data when we run our web application to mint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Candy-Machine-Mint
&lt;/h3&gt;

&lt;p&gt;Open up the candy-machine-mint folder, where you will find a file called &lt;code&gt;.env.example&lt;/code&gt; &lt;br&gt;
(The file is usually hidden, use &lt;code&gt;ctrl+h&lt;/code&gt; to display hidden files)&lt;br&gt;
Rename it to &lt;code&gt;.env&lt;/code&gt; and then open it to edit the following details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_CANDY_MACHINE_CONFIG=__PLACEHOLDER__
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the &lt;code&gt;program.config&lt;/code&gt; key from our &lt;code&gt;.cache/devnet-temp&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_CANDY_MACHINE_ID=__PLACEHOLDER__
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the &lt;code&gt;candyMachineAddress&lt;/code&gt; from our &lt;code&gt;.cache/devnet-temp&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_TREASURY_ADDRESS=__PLACEHOLDER__
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This the Solana address that receives the funds gathered during the minting process. This is the &lt;code&gt;authority&lt;/code&gt; from our &lt;code&gt;.cache/devnet-temp&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_CANDY_START_DATE=__PLACEHOLDER__
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the &lt;code&gt;startDate&lt;/code&gt; key from our &lt;code&gt;.cache/devnet-temp&lt;/code&gt; file. &lt;br&gt;
Note: If you cannot find it, use &lt;code&gt;update_candy_machine&lt;/code&gt; as mentioned above as you may have missed out on mentioning the date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_SOLANA_NETWORK=devnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This identifies the Solana network you want to connect to. Options are devnet, testnet, and mainnet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_SOLANA_RPC_HOST=https://explorer-api.devnet.solana.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This identifies the RPC server your web app will access the Solana network through.&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting The Web Application
&lt;/h3&gt;

&lt;p&gt;Open your terminal and navigate to the &lt;code&gt;candy-machine-mint&lt;/code&gt; directory and start the react app by using &lt;code&gt;yarn start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once you see &lt;em&gt;Compiled Successfully&lt;/em&gt; in your terminal, Open &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; to view it in the browser.&lt;/p&gt;

&lt;p&gt;You can now proceed with connecting your wallet, and clicking on the &lt;strong&gt;mint&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;After clicking on the &lt;strong&gt;mint&lt;/strong&gt; button, you can check the collectibles page on your phantom wallet and you'll see your newly minted &lt;a href="https://blog.accubits.com/what-are-non-fungible-tokens-or-nfts/" rel="noopener noreferrer"&gt;NFT!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s all I will be covering in this guide. If you encounter any issues, comment down below and I’ll try to help!&lt;/p&gt;

&lt;h3&gt;
  
  
  Other Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://hackmd.io/@levicook/HJcDneEWF" rel="noopener noreferrer"&gt;https://hackmd.io/@levicook/HJcDneEWF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.metaplex.com/" rel="noopener noreferrer"&gt;https://docs.metaplex.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.gg/solana" rel="noopener noreferrer"&gt;Solana Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Follow &lt;a href="https://twitter.com/aeyakovenko?s=21" rel="noopener noreferrer"&gt;Anatoly&lt;/a&gt; and &lt;a href="https://twitter.com/rajgokal?s=21" rel="noopener noreferrer"&gt;Raj Gokal&lt;/a&gt; for good vibes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ps. If you made it till here, leave a like and a comment with your feedback! Oh and a follow would be over the top appreciated :')&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>nft</category>
      <category>solana</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
