Skip to main content

Python implementation of Foundry using python web3 module

Project description

foundpy

Foundpy is a Python implementation of a popular toolkit Foundry. It replicates Foundry's core functionality without needing Foundry's installation. Foundpy enables users to use Python's web3 module with similar command style as Foundry.

from foundpy import *
config.setup(
    rpc_url="http://rpc.url/",
    privkey="0xdeadbeef"
)
setup_addr = "0xE162F3696944255cc2850eb73418D34023884D1E"
cast.send(setup_addr, "solve(bytes)", b"args123")
cast.call(setup_addr, "isSolved()")

Installation

foundpy can be installed using pip:

pip install foundpy

Usage

foundpy is best used with jupyter notebooks. But it can be used in a python script as well.

first initialize the configuration with the RPC and your private key:

from foundpy import *
config.setup(
    rpc_url="http://rpc.url/",
    privkey="0xdeadbeef"
)

To interact with a contract, you can either use the cast object or instantiate a Contract object (source code required).

setup_addr = "0xE162F3696944255cc2850eb73418D34023884D1E"
cast.send(setup_addr, "solve(bytes)", b"args123" value=0)
# or
setup = Contract(setup_addr, "Setup.Sol") # or "Setup.Sol:Setup" to specify the class
setup.send("solve", b"args123", value=0)

To deploy a contract, you can either use the forge object or use the deploy_contract function. Simply make sure that the contract's source code is in the same directory as the script. The constructor arguments can be passed by adding them to the function call after the filename.

# This will return an address
attack = forge.create("Attack.sol:Attack", setup_addr, value=int(1*(10**18)))
# or
# This will return a Contract object, which you can interact with attack.call or attack.send
attack = deploy_contract("Attack.sol", setup.address, value=int(1*(10**18))) # or "Attack.Sol:Attack" to specify the class

You can check for more examples in the example directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foundpy-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

foundpy-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file foundpy-0.1.0.tar.gz.

File metadata

  • Download URL: foundpy-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for foundpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca629f1312355c02847d96781781cb113753de3317eadcc7af570ab8755fc23c
MD5 d84cf2683acd0f7d0e52d538e11d5734
BLAKE2b-256 25b21c6fc8e8312d8828bad706b50f1db49c76006238c86165ce3a440532107a

See more details on using hashes here.

File details

Details for the file foundpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: foundpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for foundpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0002130347d8a0f0d5decfaddc8ce2e06e0b8493db3f12680f460fc605c410a2
MD5 f2c15b5a578bec0c5ef3a12f953b72e8
BLAKE2b-256 449793b0c4a2769f184c3afe46b296cb7b93517fdbc46d37ceebf5d2a5c1c85f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page