how to create custom fields for assets

0 votes

hi,

i've been trying to create a new asset with custom fields using this code.


from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import simplejson as json

rpc_user = 'rpc_user'
rpc_password = 'password'
rpc_connection = AuthServiceProxy("http://%s:%s@172.168.40.345:9876"%(rpc_user, rpc_password))

issue = rpc_connection.listpermissions("issue")
assetaddress = issue[0]['address']
assetname = 'wabbit'
assetquantity = 10000
assetunit = 1
assetnativeamt = 10
assetcustomfield = [{"type":"bugs","weight":250}]

asset = rpc_connection.issue(assetaddress, assetname, assetquantity, assetunit, assetcustomfield)


and this


asset = rpc_connection.issue(assetaddress, assetname, assetquantity, assetunit, json.dumps(assetcustomfield))


and get this error:


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bitcoinrpc/authproxy.py", line 116, in __call__
    raise JSONRPCException(response['error'])
bitcoinrpc.authproxy.JSONRPCException


 

i know i've overlooking something really obvious.

any ideas?

asked Sep 29, 2015 by santosh

1 Answer

0 votes

I don't know this Python library specifically, but I'm guessing the problem is that you're trying to pass the assetcustomfield as a preformatted JSON string, instead of a Python structure that is translated to JSON by the library.

So you might want to try substituting your current line for:

assetcustomfield={'type':'bugs', 'weight':'250'}

answered Sep 29, 2015 by MultiChain
...