Questions tagged [python]

Python is a dynamic and strongly typed programming language designed to emphasize usability.

Filter by
Sorted by
Tagged with
1
vote
3answers
3k views

How to convert/decode Solidity bytes32 to Python string via web3.py

Inside a Solidity contract, I have this variable: zBytes32 = "HelloBytes32"; after Python web3.py retrieving that variable, zbytes32 = contractInstance.functions.getzBytes32().call() print(...
1
vote
2answers
2k views

Given an ETH wallet address - Fetch all ERC721 tokens currently owned

I would like to create an application that - given a specific wallet address - fetches and displays all NFTs/ERC721 tokens currently owned. How can this be accomplished? Are there any examples ...
1
vote
2answers
101 views

What is the best (cheapest) method to store RGB/RGBA pixel data in a smart contract (on ethereum-classic blockchain) with python?

I would to implement a method to store pixel (RGB/RGBA) in a Smart contract (on ethereum-classic blockchain) from python and with the cheapest method ( when storing and updating pixel data) I try to ...
1
vote
2answers
2k views

How can I simply sign an Ethereum transaction?

I want to use blockcypher to work with the Ethereum network. In the documentation they give an example of a signer tool written on Go, but I'm use Python. What is the simplest way to sign a ...
1
vote
2answers
1k views

Python creat payment and send it with private key

I am thinking/trying to create payment system. Just to learn more about crypto. I would like to generate public and private key. And send(broadcast) payment into the eth network using python. How ...
1
vote
1answer
715 views

Decoding Contract Log's "Data" field With eth-abi Throws Error: "Padding bytes were not empty: b'0x0000000000'"

I used this guide to create the code below. I suspect the error is somewhat related to the encoding processes I do to the strings, as that is the only place where I deviate from the guide. Here is my ...
1
vote
1answer
395 views

Solidity contract using python library

Is it possible to have a smart contract which uses computational libraries from python? If so, how? Is there a size restriction on this? I wish to run an algorithm inside a contract.
1
vote
1answer
85 views

What is the name of the ether unit with 4 and 8 decimals?

I have a function that returns the name of ether units. My problem is that it doesn't work in the cases when the decimal value is 4 or 8. The decimal value belongs to a token, and I need the correct ...
1
vote
1answer
162 views

Getting `No Python at ...` error trying to install Brownie with pipx on Windows

When I try and pipx install eth-brownie I get the following error: PS C:\Users\karee\web3_py_simple_storage> pipx install eth-brownie No Python at 'C:\Users\karee\AppData\Local\Programs\Python\...
1
vote
2answers
1k views

How to get smart contract information about ABI token balance by web3?

when I get ethereum block data like below... from web3 import Web3 w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545')) print(w3.isConnected()) block = w3.eth.get_block('latest') it can get block ...
1
vote
1answer
2k views

Subscribing to new block headers using python (web3py)

I am looking for a subscribe function in web3py like the one implemented in web3js: web3.eth.subscribe('newBlockHeaders' [, callback]); As there currently is no implementation of it in web3py, has ...
1
vote
1answer
425 views

Can you check if an address is a contract or an EOA with eth-brownie or some other python native package?

I'm trying to categorize smart contracts versus EOAs since I am treating them differently in an application. Does anyone have ideas? I know in solidity you could try address.code.length or extcodesize ...
1
vote
3answers
794 views

How to get Transaction Action Etherscan

I'm trying to get Transaction Action information from Etherscan Apis by using a transaction hash without success. Here is what I want to extract (Swap 1 Ether For 2 Yf-DAI) with the API. I have ...
1
vote
2answers
610 views

Web3.py Sending Transaction Not Updating Contract

I'm new to the world of Web3.py however I have an ERC20 compliant contract and I am tryin to call the transfer() method on it to simply transfer some tokens from sender to receiver. I am testing it ...
1
vote
1answer
122 views

Bit manipulation (python vs solidity)

I am working on translating code from Python to Solidity and everything has worked up until this last loop. Cannot figure out where the difference is in the code (besides the bytes being in decimal ...
1
vote
1answer
139 views

Hashing header "offline" python

I am trying to prove that the TransactionsRoot and the ReceiptsRoot do belong to a specific block. So that I can verify without web3 that all the transactions and receipts actually belong to this ...
1
vote
1answer
211 views

Web3 (python) - confirming transaction hash format

Due to the fact, that I am storing txId obtained from the user, before determining whether transaction has been ended or not, I want to make sure that the transaction hash, which will be stored in my ...
1
vote
1answer
116 views

Argument encoding: list of uints (uint[48])

Using python web3 module, attempting to call a contract function that takes one argument, a list of 48 uints: function checkOrderBatch(uint[48] input) external view returns(uint16[16] status, uint[...
1
vote
1answer
871 views

Transaction done, but nonce does not update and call to a function returns zero

I've used web3py to deploy a contract and send some transactions to it. I calculate the nonce this way: nonce = web3.eth.getTransactionCount(account, "pending") When I deploy the contract, ...
1
vote
1answer
7k views

dictionaries inside lists - python [closed]

i'm trying to access a dictionary within a list and cannot seem to get my for loop to get the key, then the value... i've place an image herein so that its easy for me to explain. so you can see, i ...
1
vote
1answer
1k views

How to use sendRawTransaction of web3.py?

I read the web3.eth.API carefully and I typed the code in my project. signed_txn = self.web3.eth.account.signTransaction( { 'nonce': self.web3.eth.getTransactionCount(Web3....
1
vote
1answer
1k views

How to call write functions via Python web3.py, w3.eth.sendRawTransaction()

Hi I am running Python web3.py (not web3.js) to interact with contract functions: w3 = Web3(HTTPProvider('http://room1.abc.com:8545/')) txn = ctrtInstance.functions.setzString(zString)....
1
vote
2answers
2k views

How to communicate with smart contract using python?

I have developed a smart contract on remix IDE and now I want to communicate with it using python. What python libraries can I use ?
1
vote
1answer
676 views

ImportError while trying to use Web3.py

I set up a private network on my computer and was running some codes written in Python using web3.py, until I faced ImportError: ImportError: The 'pyparsing' package is required; normally this is ...
1
vote
2answers
603 views

How does web3.py cope with constant getter functions?

I've build a smart contract and now I'm testing it using the python interface of web3.py. In my contract, I declared some private variables and I created getter functions with modifiers to return ...
1
vote
2answers
869 views

Web3 Python Client

How can I call contract methods from python using my private key? I want to connect to Rinkeby Test Network and then send a transaction that I signed with my private key. Is there any ways to perform ...
1
vote
2answers
529 views

Extract v, r and s from signature for use with pyethereum.transaction library

Given an unsigned transaction, constructed using pythereum.transaction, and a signature, created by signing the transaction's hash with a private key, how do I extract the v, r, s values from the ...
1
vote
1answer
148 views

The official library for work with ethereum payments

I looking for way to generate ether wallet (priv-pub pair), handle incoming transaction to that wallet and make/push to network transaction from it. How to do that via go-ethereum or pyethereum (full ...
1
vote
1answer
2k views

Python ECDSA Public Key Recovery

How do you recover the EC public key from a VRS style signature in python? I am trying to setup some encryption between two parties via ECIES, but I first wanted to obtain the public key via recovery ...
1
vote
1answer
35 views

How to create Bitcoin-like wallet structure for Ethereum?

'Hi everyone! Any suggestions for an architecture to reach to Bitcoin's wallet structure for Ethereum? Appreciate any help, R. Geth version: 1.10.12-stable Geth's web3 api version: 0.20.1 OS: Windows ...
1
vote
2answers
278 views

Brownie Chainlink Import Error VSCode - 'File import callback not supported'

The code seems to have successfully compiled, but VSCode keeps showing this error - "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found. File import callback not ...
1
vote
1answer
52 views

Possible to use python packages inside Brownie scripts folder?

I tried to set up a Brownie project that looks like this project +- scripts | +- package_one | | +- __init__.py | | +- deploy_contract_one.py | +- package_two | | +- __init__.py | | +- ...
1
vote
1answer
459 views

ImportError: cannot import name 'interface' from 'brownie'

I was trying to implement this script to be able to wrap ETH into wETH. So, I installed Brownie by running pip3 install eth-brownie. However, I am having trouble importing interface in the first line ...
1
vote
1answer
344 views

Retrieving Matic Reward Rates on AAVE with a Python script

I am trying to build a Python script to retrieve different AAVE rates programmatically (borrow, lending, and rewards), on the Polygon blockchain (will be very similar for Ethereum). I am using Python. ...
1
vote
1answer
74 views

isConnected() is freezes and returns nothing in web3.py

I use: python3.7, web3==4.9.2, Infura and/or own Node. After web3 was initialized it returns isConnected() response only in first time, after that it freezes. web3.py: from web3 import Web3 from web3....
1
vote
1answer
212 views

Ganache gives error when I try to mint token to wallet after contract deploy

i use: python 3.5, docker, ganache (image image: trufflesuite/ganache-cli:v6.9.1) what do i do: (simplified example) I have two container: container with ganache and container with general logic. ...
1
vote
2answers
1k views

Error: Non-hexadecimal digit found

I seem to be running the following error when I try to run this script: , from brownie import AdvancedCollectible, accounts, network, config def main(): dev = accounts.add(config['wallets']['...
1
vote
1answer
180 views

How to replicate pushing and deleting from an array of structs from Solidity in Vyper?

I'm trying to re-create a Solidity contract in Vyper for a demonstration and am trying to figure out the best way to replicate adding/removing from an array of structs... As far as I can tell I'd have ...
1
vote
1answer
947 views

Getting txpool with python web3 and infura

I am trying to monitor pending transactions with python web3 and an infura node. I am currently using web3.eth.getBlock(block_identifier='pending', full_transactions=True) on a loop to fetch pending ...
1
vote
1answer
764 views

Execute smart contract function on python

so I already successfully make a smart contract and deployed it on my BC network. I can execute the function using the Ethereum wallet. My question is, how can I execute the functions on Python ...
1
vote
1answer
440 views

Verify ethereum signed message using python

Is there any way to verify signed message using python? Google do not provide any useful info. I don't believe that there are no any lib which can do it. Any suggestions? Many thanks!!!
1
vote
1answer
225 views

How get private key in private network?

I launched a private RPC Blockchain network and connected through another computer to this network. The connection is successful. How can I get a private key(through Python) if the file is on another ...
1
vote
1answer
1k views

Problems calling function with web3 from python

I was trying to call a function from my python server to a contract deployed in Ropsten. This is my method in the contract: function send(address receiver, uint amount) public { require(msg....
1
vote
1answer
674 views

How to build a simple transaction?

Where is the information on the tx package build protocol? Bitcoin as an example, Bitcoin Wiki - Protocol Documentation: tx Is there an example of serialization for python like this answer to How to ...
1
vote
2answers
172 views

How can I read/write ethereum as a database by python code? [closed]

I am a startup in this domain. I see some article about Ethereum could save data as a contract. But they are too complex to me. If I already have an Ethereum account with some ETH. Is there some ...
1
vote
1answer
319 views

Hash functions soldity to python

In Solidity, I run the following code: function hashTest() public returns(bytes32,bytes32,bytes32) { bytes32 _solution = 0xbc756c25d68ea2f260ea5f15e1e1c734c019cbc014270dd386eacca4699f60f6; bytes32 v ...
1
vote
1answer
1k views

How to read "allevents" using Python web3 (there's capability in web3.js)?

Is there a mechanism to create a listener for all events being emitted from a smart contract for the python web3 library. There is a way to do it in web3.js: myContract.events.allEvents([options][, ...
1
vote
1answer
197 views

Python state channel client

Stumbled upon this piece of Solidity code which is an Ethereum payment channel : https://github.com/mattdf/payment-channel How am I to write a Python client that interacts with it over Web3 ? What ...
1
vote
1answer
237 views

Connect pyethapp to testrpc - Is there an equivalent to `geth attach` in pyethapp?

I have an instance of testrpc running: testrpc -a 1000 when using geth, I'd do this: geth attach rpc:http://localhost:8545 to link to it. I have pyethapp installed and would like to do something ...
1
vote
1answer
28 views

What does Data Keyword do?

data domains[](owner, ip) # list Source video:

1 2 3
4
5
10