Code Monkey home page Code Monkey logo

Comments (19)

deckb avatar deckb commented on July 30, 2024

That looks like a connection issue. What url are you using?

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

I am using default as given in your code

ce = eospy.cleos.Cleos(url='http://api.pennstation.eosnewyork.io:7001')

And if that is the issue then could you implement something like - attempting the connection through all the trusted endpoints in a loop.

I also tried many from the list given in http://eosnetworkmonitor.io/ by extracting their api endpoints through bp.jason but none works.

from eospy.

deckb avatar deckb commented on July 30, 2024

The http://api.pennstation.eosnewyork.io:7001 endpoint is to a testnet that has been having problems lately. I would suggest using the proxy that was developed by a community member as your endpoint: https://proxy.eosnode.tools. You can find more information at https://eosnode.tools/proxy

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

I used

ce = eospy.cleos.Cleos(url='https://proxy.eosnode.tools')

but that also gave me below error

"C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\python.exe" "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py"
Traceback (most recent call last):
File "C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\lib\site-packages\eospy\dynamic_url.py", line 41, in post_url
r.raise_for_status()
File "C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://proxy.eosnode.tools/v1/chain/abi_json_to_bin

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py", line 22, in
data=ce.abi_json_to_bin(payload['account'],payload['name'],arguments)
File "C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\lib\site-packages\eospy\cleos.py", line 192, in abi_json_to_bin
return self.post('chain.abi_json_to_bin', params=None, json=json, timeout=timeout)
File "C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\lib\site-packages\eospy\cleos.py", line 33, in post
return cmd.post_url(url, **kwargs)
File "C:\Users\R.K Tyagi\AppData\Local\Programs\Python\Python37\lib\site-packages\eospy\dynamic_url.py", line 43, in post_url
raise requests.exceptions.HTTPError('Error: {}'.format(r.json()))
requests.exceptions.HTTPError: Error: {'code': 500, 'message': 'Internal Service Error', 'error': {'code': 3010001, 'name': 'name_type_exception', 'what': 'Invalid name', 'details': [{'message': 'Name not properly normalized (name: betdiceadmin , normalized: betdiceadmin) ', 'file': 'name.cpp', 'line_number': 15, 'method': 'set'}, {'message': '', 'file': 'abi_serializer.cpp', 'line_number': 496, 'method': '_variant_to_binary'}, {'message': '', 'file': 'abi_serializer.cpp', 'line_number': 496, 'method': '_variant_to_binary'}, {'message': '', 'file': 'abi_serializer.cpp', 'line_number': 510, 'method': '_variant_to_binary'}, {'message': ''{"from":"gi2dimrtgmge","to":"betdiceadmin ","quantity":"0.1 EOS","memo":"action:bet,seed:QMCmH3yQOknMlmoDcW,rollUnder:50"}' is invalid args for action 'transfer' code 'eosio.token'. expected '[{"name":"from","type":"account_name"},{"name":"to","type":"account_name"},{"name":"quantity","type":"asset"},{"name":"memo","type":"string"}]'', 'file': 'chain_plugin.cpp', 'line_number': 1819, 'method': 'abi_json_to_bin'}, {'message': 'code: eosio.token, action: transfer, args: {"from":"gi2dimrtgmge","to":"betdiceadmin ","quantity":"0.1 EOS","memo":"action:bet,seed:QMCmH3yQOknMlmoDcW,rollUnder:50"}', 'file': 'chain_plugin.cpp', 'line_number': 1825, 'method': 'abi_json_to_bin'}]}}

Process finished with exit code 1

from eospy.

deckb avatar deckb commented on July 30, 2024

You mention trying to use the "dice" contract but the output to your last error shows that you are trying to use abi_bin_to_json using the eosio.token account and the transfer action. Can you share what your payload variable looks like?

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

Hello Deckb, below is my payload

payload = {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "gi2dimrtgmge",
"permission": "owner",
}],
}

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

I changed "betdiceadmin" to "bet" and now I am receiving below error

"C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\Scripts\python.exe" "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py"
Traceback (most recent call last):
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\dynamic_url.py", line 41, in post_url
r.raise_for_status()
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://api.pennstation.eosnewyork.io:7001/v1/chain/push_transaction

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py", line 31, in
resp = ce.push_transaction(trx, key, broadcast=True)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\cleos.py", line 173, in push_transaction
return self.post('chain.push_transaction', params=None, data=data, timeout=timeout)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\cleos.py", line 33, in post
return cmd.post_url(url, **kwargs)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\dynamic_url.py", line 43, in post_url
raise requests.exceptions.HTTPError('Error: {}'.format(r.json()))
requests.exceptions.HTTPError: Error: {'code': 500, 'message': 'Internal Service Error', 'error': {'code': 3040000, 'name': 'transaction_exception', 'what': 'Transaction exception', 'details': [{'message': "action's authorizing actor 'gi2dimrtgmge' does not exist", 'file': 'transaction_context.cpp', 'line_number': 641, 'method': 'validate_referenced_accounts'}]}}

Process finished with exit code 1

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

I checked on eostracker - the account gi2dimrtgmge exists

from eospy.

deckb avatar deckb commented on July 30, 2024

You are trying to push the transaction to my personal testnet which does not have that account.

/usr/bin/cleos -u http://api.pennstation.eosnewyork.io:7001 get account gi2dimrtgmge

error 2019-01-30T12:54:00.307 thread-0  main.cpp:3449                 main                 ] Failed with error: unspecified (0)
unknown key (boost::tuples::tuple<bool, eosio::chain::name, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>): (0 gi2dimrtgmge)

You need to point to a mainnet endpoint. I suggest using the proxy https://eosnode.tools/proxy

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

I used the proxy account and now i get below error message

Traceback (most recent call last):
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\dynamic_url.py", line 41, in post_url
r.raise_for_status()
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://proxy.eosnode.tools/v1/chain/push_transaction

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py", line 31, in
resp = ce.push_transaction(trx, key, broadcast=True)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\cleos.py", line 173, in push_transaction
return self.post('chain.push_transaction', params=None, data=data, timeout=timeout)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\cleos.py", line 33, in post
return cmd.post_url(url, **kwargs)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\dynamic_url.py", line 43, in post_url
raise requests.exceptions.HTTPError('Error: {}'.format(r.json()))
requests.exceptions.HTTPError: Error: {'code': 500, 'message': 'Internal Service Error', 'error': {'code': 3050003, 'name': 'eosio_assert_message_exception', 'what': 'eosio_assert_message assertion failure', 'details': [{'message': 'assertion failure with message: to account does not exist', 'file': 'wasm_interface.cpp', 'line_number': 917, 'method': 'eosio_assert'}, {'message': 'pending console output: ', 'file': 'apply_context.cpp', 'line_number': 72, 'method': 'exec_one'}]}}

Process finished with exit code 1

from eospy.

deckb avatar deckb commented on July 30, 2024

It looks like whatever account you are trying transfer to does not exist:

"to account does not exist"

Can you send over the to and from fields from the data?

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

Below is what that I am using

arguments = {
"from": "gi2dimrtgmge", # sender
"to": "betdiceadmin", # receiver
"quantity": '0.1 EOS', # In EOS
"memo": "action:bet,seed:QMCmH3yQOknMlmoDcW,rollUnder:50",
}
payload = {
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "gi2dimrtgmge",
"permission": "active",
}],
}

And below is the link of betdiceadmin account that confirms the name of the account

https://eosauthority.com/account/betdiceadmin

from eospy.

deckb avatar deckb commented on July 30, 2024

Here is the code that I just used to successfully submit a bet. Should work if you replace with your actual account.

import eospy.cleos
import os
 
ce = eospy.cleos.Cleos(url='https://proxy.eosnode.tools')

arguments = {
            "from": "<youraccount>",  # sender
            "to": "betdiceadmin",  # receiver
            "quantity": '0.1000 EOS',  # In EOS
            "memo": "action:bet,seed:QMCmH3yQOknMlmoDcW,rollUnder:50",
        }
payload = {
        "account": "eosio.token",
        "name": "transfer",
        "authorization": [{
            "actor": "<youraccount>",
            "permission": "active",
        }],
    }
#Converting payload to binary
data=ce.abi_json_to_bin(payload['account'],payload['name'],arguments)
#Inserting payload binary form as "data" field in original payload
payload['data']=data['binargs']
#final transaction formed
trx = {"actions": [payload]}

script_dir = os.path.dirname(os.path.realpath(__file__))
key_file = os.path.join(script_dir,'account.key')

resp = ce.push_transaction(trx, key_file, broadcast=True)
print('------------------------------------------------')
print(resp)
print('------------------------------------------------')

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

Now I am receiving below error

Traceback (most recent call last):
File "C:/Users/R.K Tyagi/Documents/VulturesPick/EOS/eos.py", line 30, in
resp = ce.push_transaction(trx, key_file, broadcast=True)
File "C:\Users\R.K Tyagi\PycharmProjects\MagicDice\venv\lib\site-packages\eospy\cleos.py", line 163, in push_transaction
raise EOSKeyError('Must pass a WIF string or EOSKey')
eospy.exceptions.EOSKeyError: Must pass a WIF string or EOSKey

Process finished with exit code 1
And I am using owner key.

from eospy.

deckb avatar deckb commented on July 30, 2024

I do not suggest that you use your owner key for these types of actions. It looks like the key you are passing is not in the correct format. If you are trying to use a key file make sure you are using the latest version of libeospy which should be:

pip freeze | grep libeospy
libeospy==1.1.10

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

In your code inplace of account.key I am using my owner key. Don't you think that should work?

Could you suggest an app which can help me generate active key. Thanks for all your support.

from eospy.

deckb avatar deckb commented on July 30, 2024

That should work provided it is a valid key. You test if the key is valid by running the following:

python
>>> from eospy.keys import EOSKey
>>> EOSKey("paste your key here")

The above should be successful

If it fails then the private key is probably mis-typed.
As for creating a key you can use cleos

cleos create key --to-console

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

The above from python command line is successful but problem remains. What can be done?

from eospy.

ShilazTech avatar ShilazTech commented on July 30, 2024

So finally it worked. I had to give it like below:
key = ('mykey')
key_file = os.path.join(script_dir, key)

Thanks a lot for all the help. Much appreciated. You can close this.

from eospy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.