API v2 Usage

This documentation provides more detailed information about the API.v2(JSON-RPC 2.0) list and will be particularly helpful for people who want to build BaaS(Blockchain As A Service) appliacations. If you are interested in more basic usage of Metaverse, please refer to the docs instead.

Please note that this documentation is only valid for MVS FULL NODE.
Compatiblity for API v1, please refers to API v1.

API v2 Usage

Supported v0.7.3 and later

API Default Port URI Default URL
API v2 8820 /rpc/v2 http://127.0.0.1:8820/rpc/v2
Websocket 8821 /ws http://127.0.0.1:8821/ws

Refers to How to configure Port.

Build Json, then HTTP POST to URL:

{                                                                        
"id":number,
"method":"xxx",
"params":[
"param1", //command arguments from help
"param2",
{
"option1": value1, //command options from help
"option2": value2,
}
]
}

Example:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"getinfo","params":[],"id":25}' http://127.0.0.1:8820/rpc/v2
$ curl -X POST --data '{"jsonrpc":"2.0","method":"sendmore","params":["account_name","account_auth",{"receivers":"t7r9twiK5gAwhR2gXDqT2zqpzS6ogvaqnJ:100000"}],"id":25}' http://127.0.0.1:8820/rpc/v2

Obviously, Use help to get all commands(methods) list.

$ ./mvs-cli help
$ ./mvs-cli help $command

API v2 Call List

Account

Method Online-required Admin-required Account-required Version
getnewaccount × × × 0.7.3
validateaddress × × × 0.7.3
importaccount × × × 0.7.3
importkeyfile × × × 0.7.3
dumpkeyfile × × yes 0.7.3
getnewaddress × × yes 0.7.3
listaddresses × × yes 0.7.3
changepasswd × × yes 0.7.3
deleteaccount × × yes 0.7.3
getaccount × × yes 0.7.3

Blockchain

Method Online-required Admin-required Account-required Version
shutdown × yes × 0.7.3
getinfo × yes × 0.7.3
getheight × yes × 0.7.3
getpeerinfo × yes × 0.7.3
getmininginfo yes yes × 0.7.3
startmining yes × yes 0.7.3
stopmining yes × yes 0.7.3
getwork yes × yes 0.7.3
addnode × yes × 0.7.3
setminingaccount yes × yes 0.7.3
submitwork yes × yes 0.7.3
getmemorypool × yes × 0.7.3

Block

Method Online-required Admin-required Account-required Version
getblock × yes × 0.7.3
getblockheader × yes × 0.7.3

ETP

Method Online-required Admin-required Account-required Version
getbalance yes × yes 0.7.3
listbalances yes × yes 0.7.3
deposit yes × yes 0.7.3
send yes × yes 0.7.3
sendfrom yes × yes 0.7.3
sendmore yes × yes 0.7.3

Transaction

Method Online-required Admin-required Account-required Version
gettx yes × × 0.7.3
listtxs yes × yes 0.7.3

Asset

Method Online-required Admin-required Account-required Version
createasset × × yes 0.7.3
deletelocalasset × × yes 0.7.3
getaccountasset yes × yes 0.7.3
getaddressasset yes × yes 0.7.3
getasset yes × × 0.7.3
issue yes × yes 0.7.3
issuefrom yes × yes 0.7.3
listassets yes × optional 0.7.3
sendasset yes × yes 0.7.3
sendassetfrom yes × yes 0.7.3

Multi-Signatue

Method Online-required Admin-required Account-required Version
createmultisigtx × × yes 0.7.3
getpublickey × × yes 0.7.3
deletemultisig × × yes 0.7.3
getnewmultisig × × yes 0.7.3
listmultisig × × yes 0.7.3
signmultisigtx × × yes 0.7.3

Rawtx(offline-sign)

Method Online-required Admin-required Account-required Version
createrawtx × × × 0.7.3
signrawtx × × yes 0.7.3
decoderawtx × × × 0.7.3
sendrawtx × × × 0.7.3
  • Method : JSON-RPC Method
  • Online-required: whether needs to wait for almost latest height.
  • Admin-required: whether provides administrator authorization, defaluts to no. (name: administrator)(password: mvsgo).

    # mvs.conf
    [server]
    administrator_required = 1
  • Account-required : user account name, password required.

  • Version : release in version.

mvs-cli

mvs-cli uses /rpc/v2 to call mvsd after v0.7.3.