Installation and Setup
Getting Started with Discord Bot Development on the Algorand Blockchain
This tutorial will walk you through the installation and setup needed to start building a Discord bot for the Algorand blockchain. The steps outlined below cover essential tools, libraries, and additional resources to ensure a smooth start.
Resources
- YouTube Tutorial:
- Download Python at https://www.python.org/downloads/
- (Ensure 'Add Python to PATH' is selected during installation)
Installing Essential Libraries
Install the following libraries in your terminal:
pip install aiohttp
pip install algokit
pip install py-algorand-sdk
pip install algorand-python
pip install python-dotenv
Note: If you encounter errors during Algokit installation regarding missing C++ tools, please follow the instructions in the video and install the Microsoft Visual C++ Build Tools.
Test Contract Example
Create a new Python file called testcontract.py
and add the following code to define a simple contract:
from algopy import ARC4Contract
from algopy.arc4 import abimethod
class TestContract(ARC4Contract):
def __init__(self) -> None:
pass
@abimethod
def test(self) -> None:
pass
Compile the contract with the following terminal command:
algokit compile py testcontract.py
If the approval and clear TEAL files are generated successfully, your setup is complete, and you can proceed with the tutorial series.
Running Your Own Node
If you wish to run your own Algorand node rather than using Algonode, refer to the tutorial playlist. Note: Based on community feedback, we've shifted from a Discord bot-focused series to a PUYA-focused series. Only two videos were released for the Discord bot series before this shift. Start with the first video in the new series, which includes node installation for Windows.
Visual Studio Code - Code Editing
Download Visual Studio Code to edit your code efficiently, and install the Python IntelliSense extension to help with code completion and suggestions.
This tutorial guides you through developing Discord bots for the Algorand blockchain. It’s designed to complement the YouTube tutorial series.
YouTube Tutorial
Installing Dependencies
Using Regular Terminal (not Ubuntu)
- PIP Installation:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
- AIOHTTP (required before installing Discord.py):
pip install aiohttp>=3.9.0b0
- Discord.py:
pip install discord.py
- Python AlgoSDK:
pip3 install py-algorand-sdk
Using Ubuntu Terminal
Algorand Node Installation
sudo apt-get update
sudo apt-get install -y gnupg2 curl software-properties-common
curl -o - https://releases.algorand.com/key.pub | sudo tee /etc/apt/trusted.gpg.d/algorand.asc
sudo add-apt-repository "deb [arch=amd64] https://releases.algorand.com/deb/ stable main"
sudo apt-get update
sudo apt-get install -y algorand-devtools
Preparing & Running Algorand Node
mkdir ~/node
cd ~/node
curl https://raw.githubusercontent.com/algorand/go-algorand/rel/stable/cmd/updater/update.sh -O
chmod 744 update.sh
./update.sh -i -c stable -p ~/node -d ~/node/data -n
goal node start -d data
goal node catchup Get Catchpoint from Mainnet -d data
Algorand Node Commands
- Start Node:
goal node start -d data
- Restart Node:
goal node restart -d data
- Stop Node:
goal node stop -d data
- Catchup Node:
goal node catchup [Catchpoint Link] -d data
Obtain Algorand Node Token & Port
cd node/data
cat algod.token (Displays token)
cat algod.net
(Displays port)
Basic Terminal Commands
- Clear Terminal:
clear
- Create Folder:
mkdir FolderName
- List Directories:
ls
- Change Directory:
cd FolderName
- Move Up One Directory:
cd ..
- Delete Directory:
rm -r FolderName
- View File Contents:
cat FileName
Useful Links
- Install Python (Select 'Add Python to PATH')
- Install Visual Studio Code
- Microsoft Store Ubuntu LTS
- Algorand Node Documentation
- Algorand Node Mainnet Catchpoint
- Discord Developer Portal