Skip to content

a web3py project deploying and interacting with a simple smart contract.

License

Notifications You must be signed in to change notification settings

manuelinfosec/web3py-simple-storage-fcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Sample Web3py Project

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.

Quickstart

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": ""
}

Deploy

Run scripts/deploy.py from the project directory:

python3 scripts/deploy.py

Deployment to a testnet or mainnet

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.

Testing contracts

Next, run tests/test-deploy.py from the project directory:

python3 tests/test-deploy.py

Connect with me

If you appreciate this, feel free to follow me on:

Manuel Twitter Manuel Infosec YouTube Chiemezie Njoku Linkedin Manuel Medium

Appreciation

You could also donate (send funds):

Ethereum/Binance Smart Chain/Polygon/Avalanche/etc address: 0xE882D838eF07e796bf6b19636931F143e3eC4Dc3

About

a web3py project deploying and interacting with a simple smart contract.

Topics

Resources

License

Stars

Watchers

Forks