def init_web3(providers=default): from vns_web3 import Web3 if providers is default: w3 = Web3(ens=None) else: w3 = Web3(providers, ens=None) return customize_web3(w3)
def test_soliditySha3_ens(self, web3, types, values, expected): with ens_addresses(web3, { 'one.eth': "0x49EdDD3769c0712032808D86597B84ac5c2F5614", 'two.eth': "0xA6b759bBbf4B59D24acf7E06e79f3a5D104fdCE5", }): # when called as class method, any name lookup attempt will fail with pytest.raises(InvalidAddress): Web3.soliditySha3(types, values) # when called as instance method method, ens lookups can succeed actual = web3.soliditySha3(types, values) assert actual == expected
def name_to_hash(name): node = EMPTY_SHA3_BYTES if name: labels = name.split(".") for label in reversed(labels): labelhash = label_to_hash(label) assert isinstance(labelhash, bytes) assert isinstance(node, bytes) node = Web3().sha3(node + labelhash) return node
def ensure_hex(data): if not isinstance(data, str): return Web3().toHex(data) return data
def label_to_hash(label): label = normalize_name(label) if '.' in label: raise ValueError("Cannot generate hash for label %r with a '.'" % label) return Web3().sha3(text=label)
def sha3_text(val): if isinstance(val, str): val = val.encode('utf-8') return Web3().sha3(val)
from vns_web3 import ( IPCProvider, Web3, ) w3 = Web3(IPCProvider())
import json import vns_web3 from vns_web3 import Web3, HTTPProvider import rlp from solc import compile_source from web3.contract import ConciseContract web3 = Web3(HTTPProvider('http://192.168.0.40:8585')) def getCat(contract_address): json_file = open('dss/output/Cat.abi', 'r') json_abi = json.load(json_file) json_file.close() contract_address = web3.toChecksumAddress(contract_address) cat = web3.vns.contract(address=contract_address, abi=json_abi) return cat def getDai(contract_address): json_file = open('dss/output/Dai.abi', 'r') json_abi = json.load(json_file) json_file.close() contract_address = web3.toChecksumAddress(contract_address) dai = web3.vns.contract(address=contract_address, abi=json_abi) return dai def getDaiJoin(contract_address):
from vns_web3 import ( HTTPProvider, Web3, ) w3 = Web3(HTTPProvider())
from vns_web3 import Web3 w3 = Web3()
from vns_web3 import ( Web3, WebsocketProvider, ) w3 = Web3(WebsocketProvider())