-
Can anyone help with the error below? It works perfectly fine until I try to execute the print(transaction). Below is my code. from solcx import compile_standard, install_solc
import json
from web3 import Web3
with open("./SimpleStorage.sol", "r") as file:
simpel_storage_file = file.read()
# Compile solidity
install_solc("0.6.0")
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simpel_storage_file}},
"settings": {
"outputSelection": {
"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
}
},
}
)
with open("compiled_code.json", "w") as file:
json.dump(compiled_sol, file)
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]
abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]
# Connecting to ganache
w3 = Web3(Web3.HTTPProvider("HTTP://127.0.0.1:7545"))
chain_id = 1337
my_address = "0x27e0A545B03bFE673f036C108df49465e68D6F65"
private_key = "0x15530a613dd53507c305eeba6f5e0995bf356d6fbbd0a9a7e882357163f20c6d"
# Create the contract in Python
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
nonce = w3.eth.getTransactionCount(my_address)
transaction = SimpleStorage.constructor().buildTransaction(
{"chainId": chain_id, "from": my_address, "nonce": nonce}
)
print(transaction) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Hello @ti51120 that's strange, let me understand the error just show up when adding the printing statement? I read the error and the |
Beta Was this translation helpful? Give feedback.
-
For visability, the answer can be found here: https://stackoverflow.com/questions/70104101/valueerror-method-eth-maxpriorityfeepergas-not-supported-web3-py-with-ganache Encountered same error before, and it can be resolved by adding one more argument when building a transaction transaction = SimpleStorage.constructor().buildTransaction(
{
"gasPrice": w3.eth.gas_price,
"chainId": chain_id,
"from": my_address,
"nonce": nonce,
}
) |
Beta Was this translation helpful? Give feedback.
Hello @ti51120 that's strange, let me understand the error just show up when adding the printing statement? I read the error and the
maxPriorityFeeGas
is usually related with Alchemy. @PatrickAlphaC could you give us a hand on this one?