Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Martin-GHor/solidity-python

 
 

Repository files navigation

GitHub Actions Ethereum Solidity Jest

Solidity with python

A simple example to show how to connect python with blockchain smart contracts.

Prerequisites

  • Infura: Account and Key to access to a blockchain's node.

Installation

  1. Clone this repository with git

  2. Install nodeJs, npm and python

  3. Create an Infura or Alchemy Accounts

  4. Install truffle framework (npm install -g truffle)

  5. Install python dependencies (pip install web3)

  6. Install dependencies (npm i)

  7. Compile and migrate contracts

truffle develop

After truffle console start:

compile
migrate

Those steps will create the smart contracts binaries inside the ./compiled/contracts folder. You could change that in trufle-config.js.

Testing

In this repo, only we could create the smart contracts binaries and run tests over them. Inside truffle console (truffle develop):

truffle develop
test

Deploy to testnet

To deploy to test network.

# replace <NET> with desire network: rinkeby, goerli, mainnet
truffle migrate --reset --network <NET>

Run example in python

python3 example.py  -r <Provider> -e <providerKeyEth> -p <providerKeyPolygon> -a <addressAcount> -k <addressAccountKey> -n <networkToUse>

# Provider: INFURA or ALCHEMY
# Provider Key Eth: Your Key (in Infura is your projectId)
# Provider Key Polygon: Your Key
# Address Account: An Address to use with contract
# Address Key: Key from Address Account
# Network To Use: RINKEBy or POLYGON (if you need other network, you have yo change example code in example.py)

Contract Addresses

These are the networks and addresses where contract is deployed:

More Details

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 45.8%
  • Python 44.9%
  • Solidity 9.3%