Lesson 4: Warnings and error while printing Transaction in deploy.py #1374
Answered
by
cromewar
Noveleader
asked this question in
Q&A
-
|
Error I am getting while printing Transaction My code : from solcx import compile_standard, install_solc
import json
from web3 import Web3
with open(r"c:\Users\hp\VS code\Web_3\SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
print("Installing...")
install_solc("0.8.12")
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
}
},
},
solc_version="0.8.12",
)
with open(r"c:\Users\hp\VS code\Web_3\compiled_code.json", "w") as file:
json.dump(compiled_sol, file)
# get bytecode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]
# get abi
abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]
# for connecting to the ganache
w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:7545"))
chain_id = 1337
my_address = "0x61DAA7d6b655c24D9D18C45BB1e17770Cf85e6b8"
private_key = "0x7fbfa9b1b42185223cf9ac09266270659ff1a625a66bcf260999a09ae161b89a"
# create the contract in python
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
print(SimpleStorage)
nonce = w3.eth.getTransactionCount(my_address)
print(nonce)
# 1. Build a transaction
# 2. Sign a transaction
# 3. Send a transaction
transaction = SimpleStorage.constructor().buildTransaction(
{"chainId": chain_id, "from": my_address, "nonce": nonce}
)
print(transaction) |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Apr 6, 2022
Replies: 1 comment 3 replies
-
|
Hello @Noveleader You must add the gasprice into the transaction: |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Noveleader
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @Noveleader
You must add the gasprice into the transaction:
check this out: https://stackoverflow.com/questions/70051896/python-web3-and-ganache-error-method-eth-maxpriorityfeepergas-not-supported