Cannot send native currency / Asset not found

+2 votes

I am working on an automated solution that relies on the creation of a native currency. The native currency has been created and when I run listassets  i get 

{"method":"listassets","params":[],"id":"60385047-XXXXXX","chain_name":"demoChain"}

[
]

 But if I specifically ask for a wallet balance using:

 getaddressbalances 1NYNSkfDcWMrkCESLvbPamUa19e6XafgE64bZu

The response is :

{"method":"getaddressbalances","params":["1NYNSkfDcWMrkCESLvbPamUa19e6XafgE64bZu"],"id":"38421608-1566442653","chain_name":"demoChain"}

[
    {
        "assetref" : "",
        "qty" : 50,
        "raw" : 5000000000
    }
]

If I try and send the native from one address to another (global send, receive) using

sendassetfrom 1NYNSkfDcWMrkCESLvbPamUa19e6XafgE64bZu 19ycRXuYttRQeQ318Utt6hXmVYk6N1gfGZKhMa "" 0.005

The request fails with:

method":"sendassetfrom","params":["1NYNSkfDcWMrkCESLvbPamUa19e6XafgE64bZu","19ycRXuYttRQeQ318Utt6hXmVYk6N1gfGZKhMa","",0.005],"id":"95668556-1566442594","chain_name":"demoChain"}

error code: -8
error message:
Invalid asset reference

no idea what is going on. Have tried all the forums with no luck. I am fairly certain this is a noob question.Probably using the wrong method but any help would be appreciated. 

asked Aug 21, 2019 by John

1 Answer

+1 vote

The confusion is because, for the purposes of most APIs, the native currency is not considered an "asset". For example it will not appear in listassets and cannot be sent using sendassetfrom.

To send a quantity of the native currency, use this:

sendfrom 1NYNSkfDcWMrkCESLvbPamUa19e6XafgE64bZu 19ycRXuYttRQeQ318Utt6hXmVYk6N1gfGZKhMa 0.005

answered Aug 22, 2019 by MultiChain
Thank you so much! This worked perfectly.

Just maybe as a future feature it would be awesome to be able to name the native currency when you setup the chain. I am sure you have excellent reasons for doing it the way you do currently. Sometimes our feeble human minds just need a label to help understand stuff.

Thanks for all the awesome work. This solution is incredible and we are really enjoying the process of getting to understand how it works.
Thanks, an interesting idea for the future, although it would require quite a few changes to APIs.
...