Lesson:4 it's showing no transactions on rinkeby etherscan of the metamask address #1418
Answered
by
cromewar
Riyazmansuri
asked this question in
Q&A
-
When deploying to the Infura testnet everything is working fine in the terminal, the eth in the wallet is also reduced but it's showing no transactions on the etherscan. code:-
from solcx import compile_standard, install_solc
import json
from web3 import Web3
import os
from dotenv import load_dotenv
load_dotenv()
install_solc("0.6.0")
with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
}
},
},
solc_version="0.6.0",
)
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"]
w3 = Web3(
Web3.HTTPProvider("https://rinkeby.infura.io/v3/d2662ec9a8d84a868c1566348b6be772")
)
chain_id = 4
my_address = "0xD19924d417b2E32E60003fd584e18a04201ea49e"
private_key = "0x2b930f813dc68dc4ee12790e04a0db725a75d49a8c6ddb593f8bbd3ce06c2d0d"
SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
nonce = w3.eth.getTransactionCount(my_address)
transaction = SimpleStorage.constructor().buildTransaction(
{
"chainId": chain_id,
"gasPrice": w3.eth.gas_price,
"from": my_address,
"nonce": nonce,
}
)
signed_txn = w3.eth.account.sign_transaction(transaction, private_key=private_key)
print("Deloying Contract...")
tx_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction)
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print("Deloyed")
print(simple_storage.functions.retrieve().call())
print("Updating Contract...")
store_transaction = simple_storage.functions.store(15).buildTransaction(
{
"chainId": chain_id,
"gasPrice": w3.eth.gas_price,
"from": my_address,
"nonce": nonce + 1,
}
)
signed_store_tx = w3.eth.account.signTransaction(
store_transaction, private_key=private_key
)
send_store_tx = w3.eth.send_raw_transaction(signed_store_tx.rawTransaction)
tx_receipt = w3.eth.wait_for_transaction_receipt(send_store_tx)
print("Updated!")
print(simple_storage.functions.retrieve().call()) |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Apr 18, 2022
Replies: 1 comment 2 replies
-
Hello @Riyazmansuri |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Riyazmansuri
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @Riyazmansuri
Etherscan is not good at tracking this kind of transactions, have you tried with other block explorer for rinkeby?