Questions tagged [web3py]

Web3.py is a library for interacting with EVM based blockchains and smart contracts in Python.

For more information see Web3.py documentation.

Web3.py is maintained by Ethereum Foundation.

578 questions
-1
votes
1 answer

python exec() raises SyntaxError exception when passing an object inside the string argument

So I am currently trying to deploy my smart contract using a brownie script as shown in the code below: from brownie import accounts, network import sys sys.path.append("../") import globalVars def main(): import_str = "from {0} import…
mnsdali
  • 3
  • 2
-1
votes
1 answer

Getting an 'unexpected keyword argument' when deploying the python code using py-solcx for smart contracts

I'm new to Solidity and Smart contracts stuff. The code is taken from the repository provided by PatrickAlphaC under here This is the code snippet I'm currently using. from solcx import compile_standard, install_solc install_solc("0.6.0") with…
-1
votes
1 answer

how to call smart contract function. python web3

https://polygonscan.com/tx/0x0a37f5af0aa5b15431e339a7dc4ce3bdc77f229e8bd69025a4740812e0c55e6f the transaction name that appears in the metamaks is collect_from_tiles. looking for this function in the contract. I noticed that she is in another…
Dion
  • 1
  • 1
-1
votes
1 answer

How to transfer ERC1155 token using web3py?

I need to transfer an ERC1155 token using Python... something very simple: send token from account1 to account2 using python. Token: ERC 1155 Network: Polygon Language: Python Could someone please leave an example how to do it? from web3 import…
-1
votes
1 answer

how to interact with smart contract correctly in python

i was trying to write a trading bot with x2y2 api, one instruction from x2y2 confused me: Before creating listings, the signer must approve the item's transfer by the X2Y2: ERC 721 Delegate contract with the setApprovalForAll function on the item's…
-1
votes
2 answers

Web3.py check liquidity pool balance

I'm trying to compute the balance of a lp address given the address of the token. So I have this function: web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed.binance.org/")) def CheckLiquidity(TokenAddress, web3): LPAddress =…
-1
votes
1 answer

is there a way to write these python codes for a transaction created, having a constructor? i get a syntax error with these

transaction = SimpleStorage.constructor{}.buildTransaction( ("chainId": chain_id, "from": my_address, "nonce": nonce) ) print(transaction)
-1
votes
4 answers

How to extract a word from a string in python

Im getting functions from a smart contract in this format I print them out in a loop: allFunctions = contract.all_functions() for text in allFunctions: print(text)
Joe Blow
  • 39
  • 6
-1
votes
1 answer

WETH Transaction does not appear in the web3.eth.get_transaction

I am trying to understand how can I see the amount of WETH transferred in a transaction. for example on OpenSea. When you go to etherscan you can see the amount. but if you use web3.eth.get_transcation(tx_hash) you will find the value to be 0 (…
makoki
  • 1
  • 1
-1
votes
2 answers

ContractsNotFound: Input JSON does not contain any sources

I'm trying to run this in the VS Code terminal for a Solidity Tutorial. Is there an error with my code, or could this be an issue with my environment? Code: from solcx import compile_standard, install_solc with open("./SimpleStorage.sol", "r") as…
-1
votes
2 answers

Multiple transfers within one transaction?

I am writing a program in Python using the web3 library, which needs to make several translations in a single transaction. Here is an example. But I didn't find anything about it in the documentation. Some examples do several transactions through a…
-1
votes
2 answers

TypeError: 'type' object is not subscriptable web3.py

Hey I am getting TypeError: 'type' object is not subscriptable when trying to print SimpleStorage.I am using env, my python version is 3.10.0 n the library is web3.py idk if this is enough this is my first q on stakeoverflow from solcx import…
3lii06
  • 45
  • 4
-1
votes
1 answer

Pending tx in txpool but later tx used the nonce

I have an odd issue after submitting some txs and them being in the 'pending' state but other txs used the nonces in those pending txs. If I use web3 to get the txpool using web3.geth.txpool.content(), I see several entries from my address in the…
Netman
  • 179
  • 1
  • 14
-1
votes
1 answer

How do I update an api call within a while loop?

I am doing a simple request that returns a confirmation number from a blockchain using a random hash from polygonscan. The problem I have is with the while loop, it keeps looping with the same confirmation number and not updating the true number…
axell2017
  • 41
  • 5
-1
votes
1 answer

private key on bsc network

i am using python with web3 for development. but it requires a private key, where can i find this private key. i am using //bsc-data seed from binance RPC. in ethereum there is infura...but in binance i cant figure out how to obtain this private…
FSO
  • 89
  • 1
  • 7