Comments (6)
You should be using the Cleos.abi_json_to_bin to convert the payload. The ABI is not fully functional yet.
eospy/examples/push_transaction.py
Line 29 in ae7c6cc
from eospy.
Thanks for replying. data = ce.abi_json_to_bin(payload['account'], payload['name'], arguments)
is ok.
Here is my code. When running, Line 57 error.
import eospy.cleos
import eospy.keys
from eospy.types import Abi, Action
from eospy.utils import parse_key_file
import os
import pytz
import json
ce = eospy.cleos.Cleos(url='https://eos.greymass.com:443')
# use a string or EOSKey for push_transaction
# # use EOSKey:
key = eospy.keys.EOSKey('5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3')
script_dir = os.path.dirname(os.path.realpath(__file__))
########################################
# VOTE
########################################
abi_file = os.path.join(script_dir, 'eosio.system.abi')
with open(abi_file) as rf:
abi_json = json.load(rf)
sys_abi = Abi(abi_json)
# wait to send transaction
import time
print('Pushing a vote after 2 seconds using abi file: {}'.format(abi_file))
time.sleep(2)
vote_payload = {
"account": "eosio",
"name": "voteproducer",
"authorization": [{
"actor": "eosaccount",
"permission": "active",
}],
}
vote_params = {
"voter": "eosaccount", # sender
"proxy": "eosproxy", # proxy
"producers": [] # producers
}
# Voting Converting payload to binary
data = ce.abi_json_to_bin(vote_payload['account'], vote_payload['name'], vote_params)
print(data)
############################### Problem ######################################
vote_data = sys_abi.json_to_bin(vote_payload['name'], vote_params)
############################### Problem ######################################
# Inserting payload binary form as "data" field in original payload
vote_payload['data'] = vote_data
print(vote_payload)
# final transaction formed
trx = {"actions": [vote_payload]}
# resp = ce.push_transaction(trx, eospy.keys.EOSKey(key), broadcast=True)
print('------------------------------------------------')
print(resp)
print('------------------------------------------------')
runing result:
Traceback (most recent call last):
File "p.py", line 57, in <module>
vote_data = sys_abi.json_to_bin(vote_payload['name'], vote_params)
AttributeError: 'Abi' object has no attribute 'json_to_bin'
from eospy.
What version of eospy are you running?
from eospy.
just git clone url, not use release edition.
from eospy.
I just ran the following using python 3.7 with master and it worked for me.
from eospy.types import Abi, Action
import json
abi_file = "/home/deck/Documents/git/eosnewyork/eospy/examples/eosio.system.abi"
with open(abi_file) as rf:
abi_json = json.load(rf)
sys_abi = Abi(abi_json)
vote_payload = {
"account": "eosio",
"name": "voteproducer",
"authorization": [{
"actor": "eosaccount",
"permission": "active",
}],
}
vote_params = {
"voter": "eosaccount", # sender
"proxy": "eosproxy", # proxy
"producers": [] # producers
}
data = sys_abi.json_to_bin(vote_payload['name'], vote_params)
print(data)
from eospy.
maybe the different versions of the dependencies. I run in another mbp, it worked. Thanks for replying. (PS. this issue can close)
from eospy.
Related Issues (20)
- Do you have security problems using abi_json_to_bin in your code? HOT 4
- Internal Service Error, unsatisfied_authorization HOT 2
- Create multisig account HOT 6
- "ImportError: cannot import name ABC" HOT 1
- Set Contract HOT 2
- Deserialize a packed trx offline HOT 5
- Can you please publish [email protected] to pypi? HOT 1
- What are the potential risks using eospy EOSKey for mainnet? HOT 1
- long sign time and eosjs verify HOT 20
- what function is equal to eosjs-ecc's ecc.sign or ecc.signHash HOT 1
- create other eosin.token example HOT 1
- Can't sign transaction with key.sign(digest)
- 3.6.5 int/float issue HOT 1
- set_code and set_abi do not work HOT 1
- HTTPConnectionPool(host='api.pennstation.eosnewyork.io', port=7001): Max retries exceeded with url: /v1/chain/abi_json_to_bin (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x75c91050>: Failed to establish a new connection: [Errno 111] Connection refused' HOT 2
- Missing changelog HOT 2
- Get children account list HOT 1
- Getting InvalidKeyFile Error HOT 2
- ImportError: cannot import name 'InvalidKeyFile' from 'eospy.exceptions' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eospy.