Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha3() must be called with Web3 instance as first argument (got str instance instead) #15

Open
chrisrusso opened this issue Apr 20, 2018 · 2 comments

Comments

@chrisrusso
Copy link

chris@ubuntu:~/Desktop/MAIAN/tool$ sudo ./run_examples
[sudo] password for chris:

====================================================================================================
[ ] Compiling Solidity contract from the file example_contracts/example_suicidal.sol ... Done
Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 105, in main
fhashes = get_function_hashes( args.soliditycode[1] )
File "/home/chris/Desktop/MAIAN/tool/contracts.py", line 59, in get_function_hashes
hash_op = Web3.sha3(hs.encode('utf-8'), encoding='bytes')
TypeError: unbound method sha3() must be called with Web3 instance as first argument (got str instance instead)

====================================================================================================
[ ] Check if contract is SUICIDAL

[ ] Contract address :
[ ] Contract bytecode : 606060405236156100825760e060020a6000350463416ce86f...
[ ] Bytecode length : 4246
[ ] Blockchain contract: False
[ ] Debug : False

[ ] Search with call depth: 1 : Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 163, in main
if 0 == MyGlobals.checktype: ret = check_suicide.check_one_contract_on_suicide(code, '', MyGlobals.debug, MyGlobals.read_from_blockchain, False)
File "/home/chris/Desktop/MAIAN/tool/check_suicide.py", line 69, in check_one_contract_on_suicide
run_one_check( i, ops, contract_address, debug, read_from_blockchain )
File "/home/chris/Desktop/MAIAN/tool/check_suicide.py", line 25, in run_one_check
clear_globals()
File "/home/chris/Desktop/MAIAN/tool/values.py", line 164, in clear_globals
MyGlobals.s = Solver()
NameError: global name 'Solver' is not defined

====================================================================================================
[ ] Connecting to PRIVATE blockchain emptychain ... ESTABLISHED
[ ] Deploying contract ................. confirmed at address: 0x9e536236abf2288a7864c6a1afaa4cb98d464306
[ ] Contract code length on the blockchain : 16546 : 0x60606040526004361061011d5760...
[ ] Contract address saved in file: ./out/example_suicidal.bytecode_source.address
[ ] Check if contract is SUICIDAL

[ ] Contract address : 0x9e536236abf2288a7864c6a1afaa4cb98d464306
[ ] Contract bytecode : 60606040526004361061011d576000357c0100000000000000...
[ ] Bytecode length : 16544
[ ] Blockchain contract: True
[ ] Debug : False

[ ] Search with call depth: 1 : Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 142, in main
if 0 == MyGlobals.checktype: ret = check_suicide.check_one_contract_on_suicide(code, contract_address, MyGlobals.debug, MyGlobals.read_from_blockchain, True, fhashes)
File "/home/chris/Desktop/MAIAN/tool/check_suicide.py", line 69, in check_one_contract_on_suicide
run_one_check( i, ops, contract_address, debug, read_from_blockchain )
File "/home/chris/Desktop/MAIAN/tool/check_suicide.py", line 25, in run_one_check
clear_globals()
File "/home/chris/Desktop/MAIAN/tool/values.py", line 164, in clear_globals
MyGlobals.s = Solver()
NameError: global name 'Solver' is not defined

====================================================================================================
[ ] Compiling Solidity contract from the file example_contracts/example_prodigal.sol ... Done
Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 105, in main
fhashes = get_function_hashes( args.soliditycode[1] )
File "/home/chris/Desktop/MAIAN/tool/contracts.py", line 59, in get_function_hashes
hash_op = Web3.sha3(hs.encode('utf-8'), encoding='bytes')
TypeError: unbound method sha3() must be called with Web3 instance as first argument (got str instance instead)

====================================================================================================
[ ] Check if contract is PRODIGAL

[ ] Contract address :
[ ] Contract bytecode : 650200d2f18c73506060604052361561007f5760e060020a60...
[ ] Bytecode length : 1830
[ ] Blockchain contract: False
[ ] Debug : False

[ ] Search with call depth: 1 : Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 164, in main
elif 1 == MyGlobals.checktype: ret = check_leak.check_one_contract_on_ether_leak(code, '', MyGlobals.debug, MyGlobals.read_from_blockchain, False)
File "/home/chris/Desktop/MAIAN/tool/check_leak.py", line 105, in check_one_contract_on_ether_leak
run_one_check( i, ops, contract_address, debug, read_from_blockchain )
File "/home/chris/Desktop/MAIAN/tool/check_leak.py", line 63, in run_one_check
clear_globals()
File "/home/chris/Desktop/MAIAN/tool/values.py", line 164, in clear_globals
MyGlobals.s = Solver()
NameError: global name 'Solver' is not defined

====================================================================================================
[ ] Connecting to PRIVATE blockchain emptychain ... ESTABLISHED
Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 114, in main
supposed_contract_address = predict_contract_address(MyGlobals.etherbase_account)
File "/home/chris/Desktop/MAIAN/tool/contracts.py", line 165, in predict_contract_address
adr = Web3.sha3(rlp.encode([normalize_address(accountAddress), nonce]), encoding='bytes')[-40:]
TypeError: unbound method sha3() must be called with Web3 instance as first argument (got str instance instead)

====================================================================================================
[ ] Check if contract is GREEDY

[ ] Contract address :
[ ] Contract bytecode : 606060405236156100615760e060020a60003504631e9a6950...
[ ] Bytecode length : 2126
[ ] Debug : False
Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 165, in main
elif 2 == MyGlobals.checktype: ret = check_lock.check_one_contract_on_ether_lock(code, '', MyGlobals.debug, MyGlobals.read_from_blockchain)
File "/home/chris/Desktop/MAIAN/tool/check_lock.py", line 88, in check_one_contract_on_ether_lock
clear_globals()
File "/home/chris/Desktop/MAIAN/tool/values.py", line 164, in clear_globals
MyGlobals.s = Solver()
NameError: global name 'Solver' is not defined

====================================================================================================
[ ] Compiling Solidity contract from the file example_contracts/ParityWalletLibrary.sol ... Done
Traceback (most recent call last):
File "maian.py", line 182, in
main(sys.argv[1:])
File "maian.py", line 105, in main
fhashes = get_function_hashes( args.soliditycode[1] )
File "/home/chris/Desktop/MAIAN/tool/contracts.py", line 59, in get_function_hashes
hash_op = Web3.sha3(hs.encode('utf-8'), encoding='bytes')
TypeError: unbound method sha3() must be called with Web3 instance as first argument (got str instance instead)

@konradweiss
Copy link

I get a similar error. An instance is needed. my error reported a missing positional argument 'value' when calling: Web3.sha3(hs.encode('utf-8'), encoding='bytes')

hs.encode('utf-8') gets the var_name 'self' and then 'value' has none.

@77aq
Copy link

77aq commented Jul 10, 2018

Maybe you can try the following instructions to reinstall Z3 to solve the "Solver" problem . I have tried and succeed.

virtualenv venv
source venv/bin/activate
python scripts/mk_make.py --python
cd build
make
make install

You will find Z3 and the Python bindings installed in the virtual environment

venv/bin/z3 -h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants