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

hacktivator-program #196

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

EdwinLiavaa
Copy link

Title

  • Deploying a Vyper Smart Contract to RootStock (RSK) Testnet using Python Tutorial

Description

  • This guide walks through the process of deploying a smart contract to the RootStock (RSK) testnet using Python and Web3.py. We'll be deploying a simple Vyper contract that demonstrates how to interact with the RSK network.

Screenshots/GIFs

Testing

  • N/A

Checklist

  • [x ] I have read and understood the contributing guidelines.
  • [x ] I have followed the style guide and formatting guidelines.
  • [x ] I have added appropriate comments to explain the changes.
  • [x ] I have tested my changes thoroughly.

Refs

  • Related links to issues, tickets, etc.

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
devportal-rootstock ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 5:17pm

Copy link

vercel bot commented Dec 5, 2024

@EdwinLiavaa is attempting to deploy a commit to the IOV Labs Team on Vercel.

A member of the Team first needs to authorize it.

@owans owans self-requested a review December 6, 2024 14:43
@owans owans added the hacktivator-program Use this label for submissions to the hacktivator program label Dec 6, 2024
Copy link
Collaborator

@owans owans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EdwinLiavaa Thank you for your contributions, kindly attend to the comments from the PR review.

docs/04-resources/04-tutorials/index.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/index.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved

### uv

```bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a one line sentence of what this does

Copy link
Author

@EdwinLiavaa EdwinLiavaa Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv sync is a fast package management command that downloads and installs your project's Python dependencies while creating a lockfile for reproducible installations.

docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
uv sync
```

### pip/python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with here. Add a descriptive title and also why the reader should run the following commands in a short sentence

Copy link
Author

@EdwinLiavaa EdwinLiavaa Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pip/python section creates a virtual environment (python -m venv ./venv), activates it (source ./venv/bin/activate), and installs the project dependencies from requirements.txt (pip install -r requirements.txt).

echo "source $HOME/.zshenv >> $HOME/.zprofile"
```

- Python 3.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I install Python 3? its not clear

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for this tutorial we will install python3.11

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thank you, kindly include this with the command to install or a link.

Using the pkg: https://www.python.org/downloads/

Alos add that user should install the certificate

Check the python version: which -a python

If there is a way to do this via homebrew for Mac, and others for Windows, also specify: https://www.python.org/downloads/

Screenshot 2024-12-09 at 13 36 28

### pip/python

```bash
python -m venv ./venv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws an error:

python -m venv ./venv

owanate@Owanates-MacBook-Pro Web3py-Vyper-RootStock % python -m venv ./venv
zsh: command not found: python

This probably happened because of my comment above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Python's venv module is not installed on your system. You are using a MacBook, so You can try fix this by:

Reinstalling Python and make sure to check the option to install pip and venv during installation
Additionally, you should ensure you have Python 3 installed and are using the correct Python command (sometimes it needs to be python3 instead of python).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Cool

This works for me: python3 -m venv ./venv

echo "source $HOME/.zshenv >> $HOME/.zprofile"
```

- Python 3.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thank you, kindly include this with the command to install or a link.

Using the pkg: https://www.python.org/downloads/

Alos add that user should install the certificate

Check the python version: which -a python

If there is a way to do this via homebrew for Mac, and others for Windows, also specify: https://www.python.org/downloads/

Screenshot 2024-12-09 at 13 36 28

### pip/python

```bash
python -m venv ./venv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Cool

This works for me: python3 -m venv ./venv

pip install -r requirements.txt
```

## Quickstart
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're creating a hello.py file here right? Instead of quickstart, add a descriptive header title

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run the hello.py Python script as a quick test to verify that our project environment (either with UV or with pip/python virtual environment) is setup properly.

uv run hello.py # for UV
# or
python hello.py # for pip/python
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain in what cases uv or pip should be used and what the command returns

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this when I run the second command:

(venv) owanate@Owanates-MacBook-Pro Web3py-Vyper-RootStock % python3 hello.py
Hello from web3py-Vyper-RootStock!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both uv run hello.py and python hello.py will run the script and output "Hello from web3py-Vyper-RootStock!", with UV being preferred for faster, modern projects and pip for traditional Python setups.

docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
Execute the deployment script:

```bash
python deploy_favorites_unsafe.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EdwinLiavaa Error when running deployment script:

(venv) owanate@Owanates-MacBook-Pro Web3py-Vyper-RootStock % python3 deploy_favorites_unsafe.py
Traceback (most recent call last):
File "/Users/owanate/Documents/Learning/Web3py-Vyper-RootStock/deploy_favorites_unsafe.py", line 1, in
from web3 import Web3
ModuleNotFoundError: No module named 'web3'
(venv) owanate@Owanates-MacBook-Pro Web3py-Vyper-RootStock %

Also specify troubleshooting options too, its usually a good idea to let the reader know how to solve possible errors they may encounter when running the commands.

E.g, If you get this error: ModuleNotFoundError: No module named 'web3'
Do this:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error occurs because the web3 package is not installed in your virtual environment. To fix it, you should run pip install web3 or pip install -r requirements.txt while your virtual environment is activated to install all required dependencies.

sidebar_position: 7
title: Deploying a Vyper Smart Contract to Rootstock Testnet using Python
description: "This guide walks through the process of deploying a smart contract to the Rootstock testnet using Python and Web3.py. We'll be deploying a simple Vyper contract that demonstrates how to interact with the Rootstock network."
tags:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly check that these tags are enclosed in []

docs/04-resources/04-tutorials/rootstock-vyper.md Outdated Show resolved Hide resolved
@@ -13,67 +13,75 @@ values={[
{label: 'Port to Rootstock', value: 'port-dapps'}
]}>
<FilterItem
value="beginner, advanced"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the guide to the quickstart section: https://dev.rootstock.io/developers/quickstart/

Vyper Starter Kit

Copy link
Author

@EdwinLiavaa EdwinLiavaa Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well noted. I have incorprated all recommended changes on my local machine. I will now finish the review before I move the guide to the quickstart section accordingly.

Copy link
Author

@EdwinLiavaa EdwinLiavaa Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owans I have moved guide to quickstart section.

Copy link
Author

@EdwinLiavaa EdwinLiavaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have incorprated all recommended changes on my local machine. I will now finish the review before I move the guide to the quickstart section accordingly.

pip install -r requirements.txt
```

## Quickstart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run the hello.py Python script as a quick test to verify that our project environment (either with UV or with pip/python virtual environment) is setup properly.

uv run hello.py # for UV
# or
python hello.py # for pip/python
```
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both uv run hello.py and python hello.py will run the script and output "Hello from web3py-Vyper-RootStock!", with UV being preferred for faster, modern projects and pip for traditional Python setups.

Execute the deployment script:

```bash
python deploy_favorites_unsafe.py
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error occurs because the web3 package is not installed in your virtual environment. To fix it, you should run pip install web3 or pip install -r requirements.txt while your virtual environment is activated to install all required dependencies.

@@ -13,67 +13,75 @@ values={[
{label: 'Port to Rootstock', value: 'port-dapps'}
]}>
<FilterItem
value="beginner, advanced"
Copy link
Author

@EdwinLiavaa EdwinLiavaa Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well noted. I have incorprated all recommended changes on my local machine. I will now finish the review before I move the guide to the quickstart section accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktivator-program Use this label for submissions to the hacktivator program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants