New answers tagged

0

Python dictionary keys must be given as strings. Where your code says from, it should say "from": contract.functions.sendCoin(accounts[1], 10, {"from": accounts[0]})


0

Try this: contract.functions.sendCoin(accounts[1], 10).transact({"from": accounts[0]}) From official docs Execute the specified function by sending a new public transaction. Refer to the following invocation: myContract.functions.myMethod(*args, **kwargs).transact(transaction) The first portion of the function call myMethod(*args, **kwargs) selects the ...


0

I don't know if I understood correctly, You can get a function selector for a function in a smart contract like this. Greeter = w3.eth.contract(abi=abi, bytecode=bytecode) Greeter.functions.getTime().selector >>>'0x557ed1ba' Where getTime() is a public function of Smart contract. if a function accepts arguments,then Web3.sha3(text=f"setValue({'...


1

The relevant piece of documentation is here You'll need to get the contract ABI from somewhere, either by having it from when you deployed, or using a different tool. Once you have that, you can use web3.py to load it: store_var_contract = w3.eth.contract( address=address, abi=contract_interface['abi']) You can then call the function in the contract ...


1

I'm not sure that I'm understanding what you want to do entirely, so I'm going to try to rephrase your question, and please correct me if I got something wrong: Using a blockchain framework, but no smart contracts ("without SC"), can I get an account to send a transaction whenever it receives a transaction? If that is the case, I suspect the answer is that ...


0

Given the ABI of a contract, you can generate the signature of every function in that contract: signatures = {} for func in [obj for obj in abi if obj['type'] == 'function']: name = func['name'] types = [input['type'] for input in func['inputs']] signatures[name] = '{}({})'.format(name,','.join(types)) And then call Web3.sha3 with each one of ...


0

A contract on a blockchain does not store method signatures, only hashes of method signatures. This information is encoded in the EVM bytecode as "jump destinations" based on the method signature. For everything else, you need ABI files, precompiled or compile yourself. EtherScan collects contract source code and recompiles it when you "verify" the ...


Top 50 recent answers are included