This project demonstrates a basic Web3py usecase. It comes with a sample contract, a test for that contract, a sample script that deploys the contract, and an example of task implementation which simply lists the available contracts.
Start by cloning the repository:
git clone https://github.com/manuelinfosec/web3py-simple-storage-fcc
cd web3py-simple-storage-fcc
Open keys.json
and fill in your address and its corresponding private key:
{
"address": "0xE882D838eF07e796bf6b19636931F143e3eC4Dc3",
"private-key": ""
}
Run scripts/deploy.py
from the project directory:
python3 scripts/deploy.py
A custom network deployment is possible by changing the HTTP provider and chain ID. The script defaults to Rinkeby testnet with chain ID, 4. Do so by editing deploy.py
:
# imports
my_address = load(open("keys.json"))['address']
private_key = load(open("keys.json"))['private-key']
# Rinkeby Testnet
network: str = "<node-url>"
chainId: int = None
solc_version = "0.8.7"
# deploy.py continues
Replacing network
and chainId
with its a node url and its chain ID, respectively. You could create a node address alongside an API key with Infura.
Next, run tests/test-deploy.py
from the project directory:
python3 tests/test-deploy.py
If you appreciate this, feel free to follow me on:
You could also donate (send funds):
Ethereum/Binance Smart Chain/Polygon/Avalanche/etc address: 0xE882D838eF07e796bf6b19636931F143e3eC4Dc3