Skip to content

Send and Receive PTN

zhiyuan.wu edited this page May 28, 2019 · 24 revisions

Console method call:

Create a trading createRawTransaction

Parameter format: send address, receive address, quantity, handling fee. For example:

wallet.transferPTN( from, to ,amount ,fee)

For example:

wallet.transferPTN("P1GGRyzx38osMCbuqBALq57E5W4kpejnEKE","P1KngL4CVV2aW65ybUZp9PvicrAeHGpcqXF","12","1")

then will return a txid like:

0xde71e26a5a1de8bf139446f7d167c457923fe8def021346793a0c60979d40a58

Restful API Method Call

Confirm the address and port on the server side first,The default port is 8545. Confirm file of ptn-config.toml, HTTPModules = ["net", "web3", "ptn","wallet"] Open a service of wallet resetful.

createRawTransaction

Use the POST method to send the following bodydata to the server address and port,Notice the header field of http Content-Type:application/json

{"jsonrpc":"2.0","method":"wallet_transferPTN","params":["P1GGRyzx38osMCbuqBALq57E5W4kpejnEKE","P1KngL4CVV2aW65ybUZp9PvicrAeHGpcqXF",12,1],"id":1}

The result looks like this

{ "jsonrpc": "2.0", "id": 1, "result": "0xde71e26a5a1de8bf139446f7d167c457923fe8def021346793a0c60979d40a58" }

Result is not all 0, indicating that the sending is successful

Get the PTN test coin GetPtnTestCoin

Parameter format: from Sender address to Receiver address amount limit Get the upper limit of the test coin,The actual number sent is a random value not greater than this value password Sender address password duration Unlock address time

Console Call the instance

wallet.getPtnTestCoin("P19kW96FMGRwczYGxyizdAY6mWYLckADZdz","P1GBQMq3jSPgTfTDBf2J5mwWWBPHSUtCP8C", "10", "1",10)

Restful API Call the instance

{"jsonrpc":"2.0","method":"wallet_getPtnTestCoin","params":["P15GK12gMx7Ei979MqSjsi7GgZf5Y2dn66e","P1GtaPbhCnSnMHpwEYbHYBVv4wMTz3yMUTG","10","1",10],"id":1}

balance inquiry getBalance

Parameter is the address to be queried:

wallet.getBalance(addresss)

Console Call the instance:

wallet.getBalance("P1GtaPbhCnSnMHpwEYbHYBVv4wMTz3yMUTG")

Restful API Call the instance

{"jsonrpc":"2.0","method":"wallet_getBalance","params":["P1GtaPbhCnSnMHpwEYbHYBVv4wMTz3yMUTG"],"id":1}

Clone this wiki locally