Time to read: 1 min
Deploy and Interact with a Smart Contract using Web3.py
Web3.py is a Python library that allows developers to interact with Ethereum-based blockchains with Python. Rootstock has an Ethereum-like API available that is fully compatible with Ethereum-style JSON-RPC invocations. Therefore, developers can leverage this compatibility and use the Web3.py
library to interact with Rootstock similar to how developers interact with smart contracts on Ethereum.
In this guide, you'll learn how to use the Web3.py library to deploy and interact with smart contracts on Rootstock.
Interact with Rootstock using Rust
See tutorial on how to interact with Rootstock using Rust
Prerequisites
- A testnet account with tRBTC funds.
- An API KEY from the Rootstock RPC Service.
- Set up the project
- A Solidity Compiler installed -> see solidity compiler installation instructions
Set up the project and install dependencies:
# create a directory for the project
mkdir web3-python-guide && cd web3-python-guide
# install python 3.10
brew install python@3.10
# set up the development virtual environment
python3.10 -m venv env
source env/bin/activate
# install dependencies
pip install Web3 py-solc-x
Solidity compiler installation instructions for MacOs:
brew install solc-select
solc-select use 0.8.19 --always-install
solc --version
# Version: 0.8.19+commit.7dd6d404.Darwin.appleclang