Why is this not a dictionary? how do i make it one

Viewed 30

I have this code:

from web3 import Web3, HTTPProvider
import json
def check(to,tx):
        result = w3.eth.getTransactionReceipt(tx)
        a=w3.toJSON(result)
        print(a)
check("lol",0xf94a790494f8f2637a2d541c33ea1ac8736631ebb0b722e16cd7868d3d13d55d)

This is a output:

{"blockHash": "0x8f58ed2fff5f79eb03c36584a0c25de06ba51ade223c648c016d171db7f4f5e5", "blockNumber": 19235813, "contractAddress": null, "cumulativeGasUsed": 2422010, "effectiveGasPrice": 5000000000, "from": "0xdde85FF49AB49615A9864a5e2aFB04b3bd2F9199", "gasUsed": 21000, "logs": [], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "status": 1, "to": "0x9B1A917758CB4Ca014AF52261885e40266557E0a", "transactionHash": "0xf94a790494f8f2637a2d541c33ea1ac8736631ebb0b722e16cd7868d3d13d55d", "transactionIndex": 30, "type": "0x0"}

I want to slice blockhash for example, but doing a.get("blockhach") won't work since python thinks its not a dictionary but a string, dict() doesn't work, what's the solution?

0 Answers
Related