NAV
javascript shell

Introduction

BlockApps is the leading provider of Ethereum blockchain development solutions. Our client, written in Haskell, provides a highly scalable Ethereum compliant blockchain with a industry standard RESTful API.

Blockchain Applications

What is a blockchain?

A blockchain is a distributed append only ledger. Blockchain technology is the core innovation underlying Bitcoin. In the Bitcoin use case, a blockchain database is used to secure the storage and transfer of value. Ethereum generalizes Bitcoin by adding complex executable logic into the blockchain protocol.

What is a smart contract?

A smart contract is a software object that runs on top of a blockchain protocol. Smart contracts can model and execute business processes of arbitrary complexity across any number of parties.

Smart contracts are invoked via signed message (“message transactions”). These message transactions induce state changes in the smart contract that model the progress of a business process.

What is Ethereum?

Ethereum is a blockchain protocol which was designed from the ground up as an application platform. Instead of focusing solely on value transfer, Ethereum allows the application developer to embed arbitrary business logic on top of core protocol. This allows non-specialist programmers to begin building blockchain applications immediately, without needing to digest the low level cryptographic primitives necessary to create applications on top of the Bitcoin blockchain.

STRATO API Endpoints

Strato exposes the Ethereum blockchain technology from an industry standard RESTful interface. This allows application developers to quickly build applications that communicate with the Blockchain, and to easily integrate blockchain technology within existing applications and enterprise workflows.

The API endpoints below describe the Strato REST API.

GET Block

$.get("http://strato-dev4.blockapps.net/eth/v1.2/block?number=0")
  .done(function( data ) {
    //operations on the returned json block
  });
curl "http://strato-dev4.blockapps.net/eth/v1.2/block?number=1"

Sample Response:

[
  {
    "next":
    "/eth/v1.2/block?index=2&number=1",
    "kind":"Block",
    "blockUncles":[],
    "receiptTransactions":
      [
        {
          "transactionType":"FunctionCall",
          "hash":"22e32c67b2f241539c0199016397b5f7acaa833aba406689e1eeec88ef8ab9e7",
          "gasLimit":3141592,
          "kind":"Transaction",
          "data":"8df554b3",
          "gasPrice":1,
          "to":"e0e636aa52c57f51933276b0d40fe6dccd146435",
          "value":0,
          "from":"145667e13d85e7d960ffd69d67f05e0ea758179f",
          "r":"324c220b78cad3d76e6aae79fe65f312bf393ff1aa5a1e0414996f18797f8b9c",
          "s":"3b411e394699a17d521d1f4b88612a748e7209d46cc465db6ec7729366fa4a29",
          "v":"1c",
          "nonce":0
        }
      ],
    "blockData":
      {
        "extraData":0,
        "gasUsed":0,
        "gasLimit":314465996,
        "kind":"BlockData",
        "unclesHash":"1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "mixHash":"0000000000000000000000000000000000000000000000000000000000000000",
        "receiptsRoot":"56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
        "number":1,
        "difficulty":131072,
        "timestamp":"2016-06-06T23:25:07.000Z",
        "coinbase":"20a0b1b3fe8f96093231157617c13f1fda624a61",
        "parentHash":"604c9640a118959211e7dc1ce86dbdd468dd8c778476cb0352b258f67efd69f6",
        "nonce":6,
        "stateRoot":"d32fd01ec8109553e71b093267baa01b6e255320d5d5de1e7aee59fe9ddf2713",
        "transactionsRoot":"a97bf6a9db044a313004056ceb9f479b7899ad048a4eeb3adc765aba39b5b48e"
      }
    }
  ]

GET /block

GET /block/last/{integer}

Note that blocks come with a next field that contains the index for the next 100 results.

Parameter Description
number Returns blocks that match a specific number
blockid Returns blocks that match a specific blockid
maxnumber Returns blocks with a number less than a maximum
minnumber Returns blocks with a number greater than a minimum
gaslim Returns blocks that match the specified gas limit
maxgaslim Returns blocks with agas limit less than a maximum gas limit
mingaslim Returns blocks with a gas limit greater than a minimum
gasused Returns blocks that match the specified gas used
maxgasused Returns blocks with gas used less than a maximum
mingasused Returns blocks with gas used greater than a minimum
diff Returns blocks with a specific difficulty
maxdiff Returns blocks with a difficulty less than a maximum
mindiff Returns blocks with a difficulty greater than a minimum
txaddress Queries blocks by their contained transaction addresses
coinbase Queries blocks by the coinbase of contained transactions
address Queres blocks by the address of contained transactions
hash Queries blocks by their hash

GET Account

$.get("http://strato-dev4.blockapps.net/eth/v1.2/account?address=307976d54fc4634be31bcbe5b5595e193fe1d447")
  .done(function( data ) {
    //operations on the returned json block
  });
curl "http://strato-dev4.blockapps.net/eth/v1.2/account?address=12ce574b47058f3c64510a6a5149d6a9f74589b4"

Sample Response:

[
  {
    contractRoot: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    kind: "AddressStateRef",
    balance: "999999999999999744018",
    address: "12ce574b47058f3c64510a6a5149d6a9f74589b4",
    latestBlockNum: 15,
    code: "",
    nonce: 5
  }
]

GET /account?

Parameter Description
balance Returns accounts that match a specific balance
maxbalance Returns accounts with a balance less than a maximum
minbalance Returns accounts with a balance greater than a minimum
nonce Returns accounts that match a specific nonce
maxnonce Returns accounts with a nonce less than a maximum
minnonce Returns accounts with a nonce greater than a minimum
address Returns accounts with the specified address

GET Transaction

$.get( "http://strato-dev4.blockapps.net/eth/v1.2/transaction?value=0")
  .done(function( data ) {
    //operations on the returned json block
  });
curl "http://strato-dev4.blockapps.net/eth/v1.2/transaction?value=0"

Sample Response:

[
  {
    "transactionType": "Contract",
    "next": "/eth/v1.0/transaction?index=107&value=0",
    "hash": "3e93a4eed8ab656da79b0bd7a6cf584568ad5870206abbb3ff0f2455ad223615",
    "gasLimit": 3141592,
    "codeOrData":   "606060405260908060116000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605257603f565b005b60506004803590602001506071565b005b605b600450607f565b604051808281526    0200191505060405180910390f35b806000600050819055505b50565b60006000600050549050608d565b9056",
    "gasPrice": 1,
    "value": "0",
    "from": "79dfdc8d2397cf742bbbf562d55c51bfa0363dae",
    "blockNumber": 2,
    "r": "b861ce10b06554bfdd11a37ae425bbc815c0c5e051af482f8332e87d33860395",
    "s": "dd638748645e8a887154c78078babd343633ac91571659d36d1638148ce3042a",
    "v": "1c",
    "nonce": 0
  }
]

GET /transaction?

GET /transaction/last/{integer}

Parameter Description
from Returns transactions from the specified address
to Returns transactions to the specified address
address Returns transactions involving the specified address
value Returns transactions of a specific value
maxvalue Returns transactions with a value less than a maximum
minvalue Returns transactions with a value greater than a minimum
gasprice Returns transactions with the specified gas price
maxgasprice Returns transactions with a gas price less than a maximum
mingasprice Returns transactions with a gas price greater than a minimum
gaslimit Returns transactions with the specified gas limit
maxgaslimit Returns transactions with a gas limit less than a maximum
mingaslimit Returns transactions with a gas limit greater than a minimum
blocknumber Returns Transactions with a given blocknumber
$.get( "http://strato-dev4.blockapps.net/eth/v1.2/transactionResult/3e93a4eed8ab656da79b0bd7a6cf584568ad5870206abbb3ff0f2455ad223615"))
  .done(function( data ) {
    //operations on the returned json block
  });
curl "http://strato-dev4.blockapps.net/eth/v1.2/transactionResult/3e93a4eed8ab656da79b0bd7a6cf584568ad5870206abbb3ff0f2455ad223615"

Sample Response:

[
  {
    "deletedStorage": "",
    "contractsDeleted": "",
    "gasUsed": "0000000000000000000000000000000000000000000000000000000000000000",
    "time": 0.00549,
    "response": "60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14   605257603f565b005b60506004803590602001506071565b005b605b600450607f565b6040518082815260200191505060405180910390f35b8060006000508   19055505b50565b60006000600050549050608d565b9056",
    "blockHash": "3df4762bc1cf90465eaa69308bf6a7270b37572174ecd35778c46e73b5fffc3b",
    "transactionHash": "3e93a4eed8ab656da79b0bd7a6cf584568ad5870206abbb3ff0f2455ad223615",
    "etherUsed": "0000000000000000000000000000000000000000000000000000000000000000",
    "newStorage": "",
    "message": "Success!",
    "trace": "EVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #0 | 0000 : PUSH1 | 3112140 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #1 | 0002 : PUSH1 | 3112137 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #2 | 0004 : MSTORE | 3112134 | 0 | 3x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #3 | 0005 : PUSH1 | 3112122 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #4 | 0007 : DUP1 | 3112119 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #5 | 0008 : PUSH1 | 3112116 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #6 | 000A : PUSH1 | 3112113 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #7 | 000C : CODECOPY | 3112110 | 0 | 2x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #8 | 000D : PUSH1 | 3112086 | 0 | 0x32 ]\n\nEVM [ eth | 0 | caca1ed8beeb93c6ca1fb35e18f544e33bd87db7 | #9 | 000F : RETURN | 3112083 | 0 | 0x32 ]\n\n",
    "contractsCreated": "caca1ed8beeb93c6ca1fb35e18f544e33bd87db7"
  }
]

GET /transactionResult/#hash

This route returns information about the the transaction passed to it as #hash, including the VM trace if the transaction triggered a contract.

Types of transactions

Transaction Format
Contract If toAddress != Null and len(code)>=0 then we have a Contract.
FunctionCall If toAddress == Null and len(code)>0 then we have a FunctionCall.
Transfer If toAddress != Null and len(code)==0 we have a Transfer.

POST Transaction

POST /transaction

The /transaction endpoint expects a signed transaction as a JSON object and includes it into the peer to peer network for confirmation. Having POST-ed a transaction to the Strato REST API, one may poll its status via the /transactionResult endpoint. As a transaction needs to be digitally signed, we recommend you use the blockapps-js library or the tools in bloc to automatically create and POST the transaction.

POST Faucet

POST /faucet

Parameter Description
address Sends (test)-ether to the specified address

In development mode, this endpoint will send a transaction to the address POST parameter with some (test)-ether. This allows the developer to invoke contracts from the specified address.

    $.post("http://strato-dev4.blockapps.net/eth/v1.2/faucet", { address: "deadbeef" },
        function( data ) {
              console.log( data );
        });
   curl -d "address=deadbeef" http://strato-dev4.blockapps.net/eth/v1.2/faucet

POST Solc

POST /solc

Compile a smart contract with the solidity compiler.

Parameter Description
src The solidity source
    $.post("http://strato-dev4.blockapps.net/eth/v1.2/solc", { src: "contract f {uint global; function f() {global=7;}}" },
          function( data ) {
              console.log( data );
          });
    curl --data-urlencode src="contract f {uint global; function f() {global=7;}} http://strato-dev4.blockapps.net/eth/v1.2/solc

Sample Response: json {"abis": [{"name": "f", "abi": [{"inputs":[],"type":"constructor"}]}], "contracts": [{"name": "f", "bin": "60606040525b60076000600050819055505b600a80601e6000396000f30060606040526008565b00"}], "xabis": {"f":{"global":{"atStorageKey":"0","bytesUsed":"20","jsType":"Int","solidityType":"uint256"}}}}

POST Extabi

POST /extabi

Get the symbol table associated with a solidity source file.

Parameter Description
src The solidity source
    $.post("http://strato-dev4.blockapps.net/eth/v1.2/extabi", { src: "contract f {uint global; function f() {global=7;}}" }, function( data ) {
              console.log( data );
          });
    curl --data-urlencode src="contract f {uint global; function f() {global=7;}} http://strato-dev4.blockapps.net/eth/v1.2/extabi

Sample Response: json { "f": { "global": { "atStorageKey": "0", "bytesUsed": "20", "jsType": "Int", "solidityType": "uint256" } } }

GET Difficulty

GET /stats/difficulty

Get the network’s current difficulty

GET Total Transactions

GET /stats/totaltx

Get the total number of transactions that have been included in a block.

GET Storage

GET /storage

The storage route exposes the underlying storage for smart contracts, unparsed. If you know the source code associated with a particular contract, you can view the human readable storage via blockapps-js or bloc.

Parameter Description
address Returns storage from address
    $.get( "http://strato-dev4.blockapps.net/eth/v1.2/storage?address=de90be4d81952283bbc166631d4fd6e00edb2f34"))
       .done(function( data ) {
          console.log( data );
    });
    curl http://strato-dev4.blockapps.net/eth/v1.2/storage?address=de90be4d81952283bbc166631d4fd6e00edb2f34

Sample Response [ {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000aabb","key":"0000000000000000000000000000000000000000000000000000000000000000"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000ccdd","key":"0000000000000000000000000000000000000000000000000000000000000001"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000eeff","key":"0000000000000000000000000000000000000000000000000000000000000002"}, {"addressStateRefId":810,"value":"00000000000000000000000006f7eb2d23408fc0aecb10fd3c22692289226554","key":"0000000000000000000000000000000000000000000000000000000000000003"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000001e","key":"43c45235d50d416c6473365ecb796b275a713600aff8dde70699c5589aa994dd"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000001e","key":"45703c382274837dcecf5b3278985c0ffba8b31d3a1c718bc8d1558167b6b3bd"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000001e","key":"aa6e29a4f6093aeeb21a7c3b7b2f2b6a2a7ee6451cad0126be08843568d88a81"}, {"addressStateRefId":810,"value":"000000000000000000000000000000000000000000000000000000000000000a","key":"fca97163f25d977e4089c938b1c32bfadc2a1493899997eece4fadc375cf06ae"} ]

Extra parameters

Parameter Description
raw passes the pre-processor and gives you the raw result (default: raw=0).
index a cursor for querying the next 100 items correctly.

Developer Tools

bloc

Bloc is an open source framework for building blockchain applications. Head over to our github to install bloc

blockapps-js

Blockapps-js is a npm package for interacting with the BlockApps API.

External Resources

Solidity Docs

Solidity is the programming language used for writing smart contracts. For more information on solidity details visit the soldity documentation.