-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice.py
More file actions
30 lines (23 loc) · 763 Bytes
/
practice.py
File metadata and controls
30 lines (23 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from dotenv import load_dotenv
from web3 import Web3
load_dotenv()
infura_url = os.getenv('INFURA_URL')
web3 = Web3(Web3.HTTPProvider(infura_url))
# Replace with the contract address you want to interact with
contract_address = Web3.to_checksum_address("0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d")
# Replace with the ABI for the contract
abi = [
{
"constant": True,
"inputs": [],
"name": "name",
"outputs": [{"name": "", "type": "string"}],
"type": "function"
}
]
# Create the contract instance
contract = web3.eth.contract(address=contract_address, abi=abi)
# Call the 'name' function
token_name = contract.functions.name().call()
print(f"Token Name: {token_name}")