api_ucn - UCHAIN-WORLD/uchain-fullnode GitHub Wiki

title: ucn api


  • help

    show command usage.

    • JS Parameters
     { 
       method: 'POST',  
       url: 'http://127.0.0.1:8707/rpc/v3',  
       headers:   
       {  
        'Content-Type': 'application/json'   
       },  
       body: 
       { 
         "jsonrpc": "3.0",  
         "method": "{COMMAND}",  
        "params": [ "test", "123456"],  
         "id": 7    
       },  
       json: true   
    };
    
  • Response (Example for shutdown)

    {
    "id": 7,
    "jsonrpc": "3.0",
    "result": "\nUsage: uc-cli shutdown [-h] [ADMINNAME] [ADMINAUTH]                      \n\n
    Info: stop ucd.                                                          \n\n
    Options (named):\n\n-h [--help]          Get a description and instructions for this command.\n\n
    Arguments (positional):\n\n
    ADMINNAME            admin name.                                         \n
    ADMINAUTH            admin password/authorization.                       \n"
    

}


  • sendto

    send ucn to a targert uid/address.
    • JS Parameters
        { 
            method: 'POST',  
            url: 'http://127.0.0.1:8707/rpc/v3',  
            headers:   
            {  
             'Content-Type': 'application/json'   
            },  
            body: 
            { 
              "jsonrpc": "3.0",  
              "method":"sendto",
              "params":["yang", "123456", "UVgjjVHYn9XF72dXW2mdYEFWHA1qNziyNb","10000000"],
               "id": 7   
            },  
            json: true   
         };
      
      • Response
    {
    "id" : 7,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"hash" : "10b8e5b3f2defbbc31e5b4a028e7aad15162ca9754f18bb3a63c0953a1cd48ac",
    	"inputs" : 
    	[
    		{
    			"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    			"previous_output" : 
    			{
    				"hash" : "648e38de0a935334c4acc8df4908a868e4fea6ea6ae36a717ddd77551591a600",
    				"index" : 1
    			},
    			"script" : "[ 3044022046d5c393b1d00e6777b9cb2a15a3dac42d737a0fa0072da4928b0f516fc7758502203f37f0dfb59f7ccb460315015a294095315c88e46a0bf346427718010cdaa73801 ] [ 027c99068f735e53064682b9ef1f548a00191b5ffb2fd9b9c8f32cde97793a0ed4 ]",
    			"sequence" : 4294967295
    		}
    	],
    	"lock_time" : "0",
    	"outputs" : 
    	[
    		{
    			"address" : "UVgjjVHYn9XF72dXW2mdYEFWHA1qNziyNb",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 0,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 547c64a7bc778f853a030fcde79cdd7f3127d40e ] equalverify checksig",
    			"value" : 10000000
    		},
    		{
    			"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 1,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 078910a58cea508623e2be9b38beb6e7d576e880 ] equalverify checksig",
    			"value" : 49423856082830000
    		}
    	],
    	"version" : "4"
    }
    }
    
    
    

  • sendtomulti

    send ucn to multi target addresses, must specify mychange address.
    • JS Parameters
      { 
          method: 'POST',  
          url: 'http://127.0.0.1:8707/rpc/v3',  
          headers:   
          {  
           'Content-Type': 'application/json'   
          },  
          body: 
         { 
               "jsonrpc": "3.0",  
               "method":"sendtomulti",
            "params":[
                 "yang",
                 "123456",
           {
               "receivers":[
                   "UVgjjVHYn9XF72dXW2mdYEFWHA1qNziyNb:10000",
                   "UP1zcxKcE4YahLNyz1PznwHmtVUqGaXvZS:10000"
               ],
       "change": "UXFQvGKWh8GzEtV1RNw2Vo1abnynPy58u1"  }],
        "id": 7   
           } 
        json: true   
       };
    
    • Response
    {
    "id" : 125,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"hash" : "e37e44b51d0cab51a18c4ffbacd240ec224727782b24d5caf16ce2c4e6fa9ad5",
    	"inputs" : 
    	[
    		{
    			"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    			"previous_output" : 
    			{
    				"hash" : "07c88c76fd6bc5553eff24ebb3862d8700a95abb486779daece50100869cfcf4",
    				"index" : 2
    			},
    			"script" : "[ 304402201c9ef224d44edb9b51abfbec5c5e84f17ba54917cbf3f3a5d55a4f9d61ac7d0b022057fd07bc51423aa878ce729163b1c13149b6b4474cc9deff0ece86e8eb10034801 ] [ 027c99068f735e53064682b9ef1f548a00191b5ffb2fd9b9c8f32cde97793a0ed4 ]",
    			"sequence" : 4294967295
    		}
    	],
    	"lock_time" : "0",
    	"outputs" : 
    	[
    		{
    			"address" : "UVgjjVHYn9XF72dXW2mdYEFWHA1qNziyNb",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 0,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 547c64a7bc778f853a030fcde79cdd7f3127d40e ] equalverify checksig",
    			"value" : 10000
    		},
    		{
    			"address" : "UP1zcxKcE4YahLNyz1PznwHmtVUqGaXvZS",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 1,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 0b57d7e2bcdb8d98ecd1f6b264a686c97cccb8b5 ] equalverify checksig",
    			"value" : 10000
    		},
    		{
    			"address" : "UXFQvGKWh8GzEtV1RNw2Vo1abnynPy58u1",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 2,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 65a28a57f631d6d6da1a0036e72942a60b95743d ] equalverify checksig",
    			"value" : 49423855977780000
    		}
    	],
    	"version" : "4"
    }
    }
    
    
    
    

  • sendfrom

    send ucn from a specified uid/address of this wallet to target uid/address, mychange goes to from_uid/address.
    • JS Parameters
      { 
          method: 'POST',  
          url: 'http://127.0.0.1:8707/rpc/v3',  
          headers:   
          {  
           'Content-Type': 'application/json'   
          },  
          body: 
          { 
            "jsonrpc": "3.0",  
            "method":"sendfrom",
       	    "params":[
       	        "yang",
       	        "123456",
       	        "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
       	        "UP1zcxKcE4YahLNyz1PznwHmtVUqGaXvZS",
       	        "50000"
       	    ]}
          json: true   
       };
    
    • Response
    {
    "id" : 125,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"hash" : "d807c05ea168001d32f8d9c679a547900321de6f545b31b1f88a5f6e43a94665",
    	"inputs" : 
    	[
    		{
    			"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    			"previous_output" : 
    			{
    				"hash" : "5f85142ffcff4bec0372b8bf38795c3e13bda06afd28cf70759fd3b6bc77a00a",
    				"index" : 1
    			},
    			"script" : "[ 304402206205e946ef0eef1dbdef1853098094870bf05193f2d0e668661f3ace2720213202207d6d4d57f2b9ac8b184ba5ff6ef7078be674f930ac264f498598ff7e12d301da01 ] [ 027c99068f735e53064682b9ef1f548a00191b5ffb2fd9b9c8f32cde97793a0ed4 ] [ 004605 ]",
    			"sequence" : 4294967295
    		}
    	],
    	"lock_time" : "0",
    	"outputs" : 
    	[
    		{
    			"address" : "UP1zcxKcE4YahLNyz1PznwHmtVUqGaXvZS",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 0,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 0b57d7e2bcdb8d98ecd1f6b264a686c97cccb8b5 ] equalverify checksig",
    			"value" : 50000
    		},
    		{
    			"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 1,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 078910a58cea508623e2be9b38beb6e7d576e880 ] equalverify checksig",
    			"value" : 44940000
    		}
    	],
    	"version" : "4"
    }
    }
    
    
    
    

  • deposit

    Deposit some ucn, then get reward for frozen some ucn.
    • JS Parameters
      { 
          method: 'POST',  
          url: 'http://127.0.0.1:8707/rpc/v3',  
          headers:   
          {  
           'Content-Type': 'application/json'   
          },  
          body: 
               { 
                        "jsonrpc": "3.0",  
                        "method":"deposit",
                        "params":[
                        "yang",
                        "123456",
                        "100000",
                      {
               "address":"USa9SKiMHZ3TRcodvJi6oGVgS65iy47Hh4",
           	    "deposit":"10"
                     }
                   ]
                  },
          json: true   
       };
    
    • Response
    {
    "id" : 125,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"hash" : "8d64b5d6df630ecc48582fdc5c406384460b058d4ccda2e98a65b110c33a5202",
    	"inputs" : 
    	[
    		{
    			"address" : "UXFQvGKWh8GzEtV1RNw2Vo1abnynPy58u1",
    			"previous_output" : 
    			{
    				"hash" : "2f5e0e56f7f9242757a4049443e9a86e6d979b99a25ca9f3ba7b4bc09d7a0195",
    				"index" : 3
    			},
    			"script" : "[ 3045022100b95defb08fd7ae7fcd059abf3587caa1ca8396fa71c2eadcc7cadff606f7ecd70220229da48ffc3702cfe1341a7118387dcdac04e1eabc386b9d16e2a7b9f59d0c1101 ] [ 026c05f0fe5306fc9c5282600f09305199da99664a6a90f430b59fae8b09cc7aeb ]",
    			"sequence" : 4294967295
    		}
    	],
    	"lock_time" : "0",
    	"outputs" : 
    	[
    		{
    			"address" : "USa9SKiMHZ3TRcodvJi6oGVgS65iy47Hh4",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 0,
    			"locked_height_range" : 1728000,
    			"script" : "[ 005e1a ] numequalverify dup hash160 [ 3254e428b11bf9c23a227c3148148fa868ff3e9d ] equalverify checksig",
    			"value" : 100000
    		},
    		{
    			"address" : "UXFQvGKWh8GzEtV1RNw2Vo1abnynPy58u1",
    			"asset" : 
    			{
    				"type" : "ucn"
    			},
    			"index" : 1,
    			"locked_height_range" : 0,
    			"script" : "dup hash160 [ 65a28a57f631d6d6da1a0036e72942a60b95743d ] equalverify checksig",
    			"value" : 49423605977660000
    		}
    	],
    	"version" : "4"
    }
    }
    
    
    
    


  • showbalances

    List all balance details of each address of this wallet. defaults show non-zero unspent address.
    • JS Parameters
      { 
          method: 'POST',  
          url: 'http://127.0.0.1:8707/rpc/v3',  
          headers:   
          {  
           'Content-Type': 'application/json'   
          },  
          body: 
            { 
                    "jsonrpc": "3.0",  
                    "method":"showbalances",
                 "params":[
                     "yang",
                   "123456"
                   ],
                  "id": 7   
                  },
          json: true   
       };
    
    • Response
    {
    "id" : 7,
    "jsonrpc" : "3.0",
    "result" : 
    [
    	{
    		"address" : "UXFQvGKWh8GzEtV1RNw2Vo1abnynPy58u1",
    		"available" : 49423605977660000,
    		"confirmed" : 49423605977660000,
    		"frozen" : 0,
    		"received" : 148271067933210000,
    		"unspent" : 49423605977660000
    	},
    	{
    		"address" : "UiyoSgUnCbfSFVKcufwMZALVMURmiEfswq",
    		"available" : 0,
    		"confirmed" : 390000000000,
    		"frozen" : 390000000000,
    		"received" : 390000000000,
    		"unspent" : 390000000000
    	},
    	{
    		"address" : "UTg5BtZmFAvV8FaDQUw6BxRVphvyw6QhqF",
    		"available" : 0,
    		"confirmed" : 0,
    		"frozen" : 0,
    		"received" : 0,
    		"unspent" : 0
    	},
    	{
    		"address" : "UkRYvsnfJkwSTAUCcZnqCK8sE1ZYJP6so7",
    		"available" : 0,
    		"confirmed" : 0,
    		"frozen" : 0,
    		"received" : 0,
    		"unspent" : 0
    	},
    	{
    		"address" : "UNfrtAxhJRi83PjTPjV3yNPKnjLYR22Bhx",
    		"available" : 44940000,
    		"confirmed" : 40176000379940000,
    		"frozen" : 40176000335000000,
    		"received" : 7652094948131270000,
    		"unspent" : 40176000379940000
    	}
    ]
    }
    
    
    
    

  • showbalance

    Show total balance details of this wallet.
    • JS Parameters
      { 
          method: 'POST',  
          url: 'http://127.0.0.1:8707/rpc/v3',  
          headers:   
          {  
           'Content-Type': 'application/json'   
          },  
          body: 
            { 
                     "jsonrpc": "3.0",  
                     "method":"showbalance",
                  "params":[
                  "yang",
                 "123456"
                 ]},
          json: true   
       };
    
    • Response
    {
    "id" : 7,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"total_available" : 49423606022600000,
    	"total_confirmed" : 89599996357600000,
    	"total_frozen" : 40176390335000000,
    	"total_received" : 7800366406064480000,
    	"total_unspent" : 89599996357600000
    }
    }
    
    
    
    


  • showaddressucn

    Get any valid target address UCN balance.
    • JS Parameters
        { 
            method: 'POST',  
            url: 'http://127.0.0.1:8707/rpc/v3',  
            headers:   
            {  
             'Content-Type': 'application/json'   
            },  
            body: 
           { 
                    "jsonrpc": "3.0",  
                    "method":"showaddressucn",
                    "params":[
                    "USa9SKiMHZ3TRcodvJi6oGVgS65iy47Hh4"
                      ]} ,
            json: true   
         };
      
      • Response
    {
    "id" : 7,
    "jsonrpc" : "3.0",
    "result" : 
    {
    	"address" : "USa9SKiMHZ3TRcodvJi6oGVgS65iy47Hh4",
    	"confirmed" : 110300,
    	"frozen" : 100300,
    	"received" : 110300,
    	"unspent" : 110300
    }
    }