Data

All commands for Data section are listed below and detailed on their own sections.

Push data

post

This endpoint forms the basis for the customized usage of the PIRI network. Thanks to this feature in the PIRI network, which enables data to be included in transactions and moved, user data can be transferred from any source, address, or recipient (recipient address).

Pirichain offers a dynamic method to facilitate the addition of data to the blockchain. Data can be added as a Key & Value pair with different security levels, denoted by "enc," which represents the encryption level. There are three different encryption types for "enc." 0: Non-Encrypted, where the Key & Value pair is stored openly in the blockchain. 1: Value Encrypted, where the Key value is stored openly, but the Value is encrypted. 2: Key & Value Encrypted, where both values are added to the blockchain in an encrypted form.

When data is stored encrypted in the PIRI network, two different approaches can be applied. The parameter that enables this is "to". In other words, customData can be made shareable with another PIRI address, beyond belonging to the PIRI address that added it to the system. This is made possible through a "shared key" in the PIRI network.

Once customData is added to the blockchain, it becomes immutable and cannot be altered or deleted, similar to a transaction. This ensures the immutability of the given data.

Thanks to this feature, applications for data-driven web3.0 concepts can be developed without the need for external applications, and the use of this feature with Pirichain Smart Scenarios can also be facilitated.

Body
addressstringRequired

PIRI Address

privateKeystringRequired

Private Key

tostringOptional

Recipient PIRI Address

customDatastringRequired

Custom data [{"key":"key","value":"value","enc":<0: non-encrypted, 1: value-encrypted, 2: key&value-encrypted>}, ...]

indPubKeystringOptional

Recipient Public Key

Responses
200

OK

application/json; charset=utf-8
post
POST /pushData HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 89

"address='text'&privateKey='text'&to='text'&customData='text'&indPubKey='text'"
200

OK

{
  "error": 0,
  "tx": "2053d0aad075f3af0574d3883cecff298c72a2d6b1cbcdb60baaeb0cd70cb0f9",
  "sign": "3046022100b87759aeb25195a49e9fef79faba7210b77b622dbb6bed04562c63d333989cea022100d62d1521f2b8b5458839aed44136f2c86e1383388394183debc7d95a61e5c9fa",
  "timeStamp": 1651837236483
}

Decrypt

post

This endpoint is created for a customData added to the PIRI network, with the intention of enabling decryption by either the data provider or the recipient. The data added with the "pushData1 endpoint" comes with different encryption levels, two of which do not require additional decryption: 1: Value Encrypted, 2: Key & Value Encrypted.

In such a scenario, the address that added the data to the blockchain or the address that became the recipient at the time of data addition through the "to" parameter can decrypt this encrypted data or data using this endpoint.

Body
customIDstringRequired

Custom Data Id

privateKeystringRequired

Private Key

receiptPubstringOptional

Recipient Public Key

Responses
200

OK

application/json; charset=utf-8
post
POST /decrypt HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 59

"customID='text'&privateKey='text'&receiptPub='text'"
200

OK

{
  "error": 0,
  "key": "key of encrypted data",
  "value": "value of encrypted data"
}

List data

post

This endpoint lists the data present in the PIRI network based on the skip and limit parameters.

Body
limitnumberRequired

Record count for per page

skipnumberOptional

Page count for skip according to limit value.

Responses
200

OK

application/json; charset=utf-8
post
POST /listData HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 20

"limit=1&skip=1"
200

OK

{
  "data": [
    {
      "_id": "632b8a7d96d5ee532e945af0",
      "txID": "c22af19b8eb45c4a67fdedf5cffa19e0b70e0ec33a766e8e4f4b315054dfb95a",
      "key": "0257ca14e439ad0f000dac6f20e03505",
      "value": "fb07e227f45ae43e3ad10305c6d9b68617dff238773a2364aa0a8ca42d058138",
      "timeStamp": 1663797885040,
      "from": "PRTMQ2aLJgU3kQSaXrCdVQ7XRvsmp3MH9n56fv9q62Q",
      "enc": 2,
      "__v": 0,
      "blockHeight": 711557
    }
  ],
  "count": 7162831
}

List data by address

post

This endpoint lists the data associated with the PIRI address specified in the "address" parameter on the PIRI network, depending on the skip and limit parameters.

Body
addressstringRequired

PIRI Address

limitnumberRequired

Record count for per page

skipnumberOptional

Page count for skip according to limit value.

Responses
200

OK

application/json; charset=utf-8
post
POST /listDataByAddress HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 37

"address='text'&limit=1&skip=1"
200

OK

{
  "data": [
    {
      "_id": "632b8169eed024f009a988c2",
      "txID": "2cfa3df4fbabe0bb38c7721faf1e05b0ac468deea95fcb513192f2b02a87efec",
      "key": "a30984384f3916940bfc5e2ab40212b4",
      "value": "d3d9ab4eb0c223d49e9faf10cda3cb3d",
      "timeStamp": 1663795561663,
      "from": "PRTMQ2aLJgU3kQSaXrCdVQ7XRvsmp3MH9n56fv9q62Q",
      "enc": 2,
      "__v": 0,
      "blockHeight": 711325
    }
  ],
  "count": 10209
}

List data by addresses

post

List data entries between specific addresses

Body
fromstringRequired

From address

tostringRequired

To address

limitnumberRequired

Number of results to return

skipnumberOptional

Number of results to skip

Responses
200

OK

application/json; charset=utf-8
post
POST /listDataByAddresses HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 46

"from='text'&to='text'&limit=1&skip=1"
200

OK

{
  "error": 0,
  "data": [
    {
      "_id": "632b8169eed024f009a988c2",
      "txID": "2cfa3df4fbabe0bb38c7721faf1e05b0ac468deea95fcb513192f2b02a87efec",
      "key": "a30984384f3916940bfc5e2ab40212b4",
      "value": "d3d9ab4eb0c223d49e9faf10cda3cb3d",
      "timeStamp": 1663795561663,
      "from": "PRTMQ2aLJgU3kQSaXrCdVQ7XRvsmp3MH9n56fv9q62Q",
      "to": "PRTMPaWeNEuR5p7edg7hRMkNogkLPUhqmwkpb2hCJb8",
      "enc": 2,
      "__v": 0,
      "blockHeight": 711325
    }
  ]
}

Push data raw transaction

post

Push data to blockchain using raw transaction format

Body
addressstringRequired

Sender address

pubKeystringRequired

Public key

signaturestringRequired

Transaction signature

timeStampstringRequired

Transaction timestamp

tostringRequired

Recipient address

customDatastringOptional

Custom data array in JSON format

indPubKeystringOptional

Individual public key

Responses
200

OK

application/json; charset=utf-8
post
POST /pushDataRawTransaction HTTP/1.1
Host: core.pirichain.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 123

"address='text'&pubKey='text'&signature='text'&timeStamp='text'&to='text'&customData='text'&indPubKey='text'"
200

OK

{
  "error": 0,
  "txHash": "2053d0aad075f3af0574d3883cecff298c72a2d6b1cbcdb60baaeb0cd70cb0f9"
}

Was this helpful?