create account

The Steem API by xeroc

View this thread on: hive.blogpeakd.comecency.com
· @xeroc ·
$42.61
The Steem API
The underlying technology if STEEM is very similar to the Graphene technology used in other blockchains. It consists of hash-linked blocks that may contain several transactions. In contrast to Bitcoin, each transaction can itself contain several so called operations that perform certain tasks (e.g. transfers, vote and comment operations, vesting operations, and many more).

Operations can easily be identified by their *operation type* as well as a different structure in the *operation data*.

For the sake of simplicity, this article will show how to read and interpret **transfer** operations on order to process customer deposits. In order to distinguish customers, we will make use of *memos* that can be attached to each transfer. Note, that these memos are stored on the blockchain in plain text.

## Transfer Operation

A transfer operations takes the following form:

```json
{
  "from": "hello",
  "to": "world",
  "amount": "10.000 STEEM",
  "memo": "mymemo"
}
```
where `from` and `to` identify the sender and recipient. The amount is a space-separated string that contains a floating point number and the symbol name `STEEM`. As mentioned above, the sender can attach a memo which is stored on the blockchain in plain text.

## Operations

Each operation is identified by an operation identifier (e.g. `transfer`) together with the operation-specific data and are bundled into an array of *operations*:

```json
[
  [operationType, {operation_data}],
  [operationType, {operation_data}],
  [operationType, {operation_data}],
]
```

Several operations can be grouped together but they all take the form `[operationType, {data}]`:
```json
[
  ["transfer", {
      "from": "hello",
      "to": "world",
      "amount": "10.000 STEEM",
      "memo": "mymemo"
      }
   ],
   ["transfer", {
      "from": "world",
      "to": "trade",
      "amount": "15.000 STEEM",
      "memo": "Gift!"
      }
   ]
]
```
The set of operations is executed in the given order. Given that STEEM has a single threaded business logic, all operations in a transaction are guaranteed to be executed atomically.

## Transactions

The set of operations is stored in a transaction that now carries the required signatures of the accounts involved, an expiration date as well as some parameters required for the TaPOS/DPOS consensus scheme.

```json
[
  {"ref_block_num": 29906,
   "ref_block_prefix": 1137201336,
   "expiration": "2016-03-30T07:15:00",
   "operations": [[
       "transfer",{
         "from": "hello",
         "to": "world",
         "amount": "10.000 STEEM",
         "memo": "mymemo"
       }
     ]
   ],
   "extensions": [],
   "signatures": ["20326......"]
   }
]
```

## Block

Several transactions from different entities are then grouped into a block by the block producers (e.g. witnesses and POW miners). The block carries the usual blockchain parameters, such as the transaction merkle root, hash of the previous block as well as the transactions.

```json
{
  "previous": "000274d2b850c8433f4c908a12cc3d33e69a9191",
  "timestamp": "2016-03-30T07:14:33",
  "witness": "batel",
  "transaction_merkle_root": "f55d5d65e27b80306c8e33791eb2b24f58a94839",
  "extensions": [],
  "witness_signature": "203b5ae231c4cf339367240551964cd8a00b85554dfa1362e270a78fa322737371416b00d1d7da434f86ad77a82b6cc1dd2255ca6325b731185fe2c59514e37b29",
  "transactions": [{
      "ref_block_num": 29906,
      "ref_block_prefix": 1137201336,
      "expiration": "2016-03-30T07:15:00",
      "operations": [[
          "transfer",{
            "from": "hello",
            "to": "world",
            "amount": "10.000 STEEM",
            "memo": "mymemo"
          }
        ]
      ],
      "extensions": [],
      "signatures": [
        "20326d2fe6e6ba5169a3aa2f1e07ff1636e84310e95a40af12483af21a3d3c5e9564565ede62659c2c78a0d9a65439ad4171a9373687b86a550aa0df9d23ade425"
      ]
    }
  ],
  "block_id": "000274d3399c50585c47036a7d62fd6d8c5b30ad",
  "signing_key": "STM767UyP27Tuak3MwJxfNcF8JH1CM2YMxtCAZoz8A5S8VZKQfZ8p",
  "transaction_ids": [
    "64d45b5497252395e38ed23344575b5253b257c3"
  ]
}
```

Furthermore, the call `get_block <blocknumber>` returns the transaction ids (i.e. the hashes of the signed transaction produced by the sender) that uniquely identify a transaction and thus the containing operations.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
👎  , ,
properties (23)
authorxeroc
permlinksteem-blockchain-data-structure
categoryundefined
json_metadata{}
created2016-04-13 16:27:03
last_update2016-04-13 16:27:03
depth0
children1
last_payout2016-08-03 00:00:06
cashout_time1969-12-31 23:59:59
total_payout_value21.304 HBD
curator_payout_value21.301 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,312
author_reputation118,819,064,085,695
root_title"The Steem API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131
net_rshares21,191,419,675,992
author_curate_reward""
vote details (49)
@vaerospace ·
https://steemit.com/life/@vaerospace/it-seems-that-if-you-dare-use-a-footer-in-your-comments-mentioning-your-posts-or-sevices
👍  
properties (23)
authorvaerospace
permlinkre-xeroc-steem-blockchain-data-structure-20171026t142420903z
categoryundefined
json_metadata{"tags":[null],"links":["https://steemit.com/life/@vaerospace/it-seems-that-if-you-dare-use-a-footer-in-your-comments-mentioning-your-posts-or-sevices"],"app":"steemit/0.1"}
created2017-10-26 14:24:09
last_update2017-10-26 14:24:09
depth1
children0
last_payout2017-11-02 14:24:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length125
author_reputation1,406,057,356,244
root_title"The Steem API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,620,266
net_rshares0
author_curate_reward""
vote details (1)