Skip to content

API Basics

BlockApps STRATO blockchain platform exposes various services via REST API endpoints, which can be easily consumed and integrated into existing products and services.

This section will serve as a brief introduction to the concepts surrounding the STRATO API, and the basic ways to use it.

Assumptions

This article assumes a basic understanding of the STRATO platform and blockchain concepts such as:

  • Identity Management/OAuth
  • STRATO Accounts
  • Smart Contracts
  • EVM vs. SolidVM
  • Main Chain vs. Private Chains

Authorization

To make calls to the STRATO API, a call needs to be authorized with a valid JWT access token. An access token is received from the OAuth identity provider specified at STRATO Boot time. See the User Identity section for more information about how to obtain a valid access token.

All requests must contain the access token in the standard 'Authorization: Bearer' header format:

"Authorization: Bearer <token>"

Identity Verification

Before making a transaction on STRATO ^8.0, all users must have a verified identity through the on-chain Certificate Registry Dapp. See more about User Identities in STRATO.

Endpoint Routes

The STRATO API routes are prefixed by their functionality. All endpoints take the form of

https://<strato_address>/<prefix>/...
Below is a brief explanation of each endpoint prefix and what they are used for.

STRATO

https://<strato_address>/strato/
Contains most of the functionality with interacting with the STRATO platform, like making transactions, or getting user addresses. All calls to this endpoint (with the exception of /transaction/raw) use the STRATO key vault for authentication and key signatures.

STRATO Key Vault

https://<vault_address>/
This is a seperate service which STRATO nodes connect to, to verify users and attain private keys in a secure manner. This service can also be directly called by the user (see Shared Vault for more information).

Bloc

https://<strato_address>/bloc/
Used for calls that pertain to blockchain info, such as fetching contract state, function parameters, transaction results, etc.

STRATO API

https://<strato_address>/strato-api/
Calls that relate to low-level blockchain data, such as raw, signed transactions, account state, storage, block-data, etc. This endpoint is not widely used in favor of higher-level APIs like /strato or /bloc.

Cirrus

https://<strato_address>/cirrus/
Used to retrieve contract state from indexed blockchain data. Calls querying information about a contract will query over all the instances of that contract. This endpoint exposes PostgREST for querying data, so see the PostgREST v9.0 Documentation for the full explanation of querying cirrus.

Apex API

https://<strato_address>/apex-api
Used to monitor system related metrics, such as node health, recent transaction, blocks, and more.

Account Management

Create an Account

This endpoint will generate a public-private key pair in the STRATO key vault for the user associated with the access token provided in the Authorization header. If an account already exists in association with this access token, see the instructions for Getting an Account Address. This endpoint creates an account address associated with the user's key pair so that the user with this access token now has the provided blockchain account address. If gas is on in your network, the account will not be immediately useable. To initialize an account with tokens, use the Faucet Account Endpoint.

Endpoint

POST https://<strato_address>/strato/v2.3/key
Example

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  "https://<strato_address>/strato/v2.3/key"

Response

The address and public key of the STRATO account that is associated with the provided user access token.

{
  "address": "ad7e55be36a413416abe3bce416abe",
  "pubkey": "b3df6d4553d40874af617e2523b53e5280bb3dac01504c8fc9ac50ce6c7e16c99cfdcd6b18505dfef7ce0ccb164d1c1f046ecbb8d85a245e7abfc70",
  "status": "success"
}

If a STRATO account has already been created with the user key associated with this access token, then the API will respond with "User <username> already exists"

The BlockApps Rest createUser method will create a STRATO account associated with this OAuth user. If the user already exists, the method will fetch the address of this OAuth user.

const user = await rest.createUser({ token : OAUTH_TOKEN }, options)

Response

An object with the user's address and OAuth access token.

{
  address: "ad7e55be36a413416abe3bce416abe"
  token: "abc..."
}

Getting an Account Address

This endpoint will fetch the address of the account of the user associated with the access token provided.

Endpoint

GET https://<strato_address>/strato/v2.3/key
Example

curl -X GET \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  "https://<strato_address>/strato/v2.3/key"

The BlockApps Rest createUser method will fetch the address and of the STRATO account associated with this OAuth user. If the user does not exist, the method create a new STRATO account for this OAuth user.

const user = await rest.createUser({ token : OAUTH_TOKEN }, options)

Response

The address and public-key of the STRATO account:

An object with the user's address, public-key, and OAuth access token.

{
  address: "ad7e55be36a413416abe3bce416abe",
  token: "abc...",
  pubkey: "6dd79a1f64..."
}

Faucet (Add Value to) an Account

Every transaction performed on the blockchain has some computational cost to it (how much gas it takes), and STRATO uses tokens to control how much gas a user can use. A user has a balance of tokens that are spent on computation gas to perform operations. These tokens serve no monetary value in most STRATO networks and are not a form of cryptocurrency. They exist to guard against possible DoS attacks, such as code that executes indefinitely. For a more in-depth explanation of Gas in a blockchain network see the Official Ethereum Documentation on Gas.

By default the usage of these tokens (gas) in a network is disabled.

The /fill endpoint adds 2000 tokens to this blockchain account address. This function will not do anything if gas is disabled, and therefore does not need to be called.

Endpoint

POST https://<strato_address>/bloc/v2.2/users/user/<account_address>/fill

Example

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  "https://<strato_address>/bloc/v2.2/users/user/<account_address>/fill?resolve=true"

Response

This will return the status, hash, and other information for the account faucet that has just occurred.

{
  "status": "Success",
  "hash": "41b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d"
}

Note that if Gas is disabled, this endpoint will respond with a 200 status code and the following response body:

{
  "status": "Success",
  "hash": "0000000000000000000000000000000000000000000000000000000000000000",
  "txResult": null,
  "data": null
}

The BlockApps Rest createUser method will create and faucet a new STRATO account associated with this OAuth user. If the user already exists, the method will just fetch the address of this OAuth user.

Note that if Gas is disabled, the method's faucet will not add tokens to the account.

const user = await rest.createUser({ token : OAUTH_TOKEN }, options)

Response

An object with the user's address, public-key, and OAuth access token.

{
  address: "ad7e55be36a413416abe3bce416abe",
  pubkey: "abc..."
  token: "6dd79a1f64..."
}

Transactions

Warning

All users must have a verified identity through the on-chain Certificate Registry Dapp before being able to make a transaction. See more about User Identities in STRATO.

The transaction endpoint is used to perform three very common operations on the STRATO platform. These include Smart Contract Creation, Function Calls of a Smart Contract, and Balance Transfers of tokens between accounts (irrelevant if gas is disabled). We demonstrate here how to use this endpoint to accomplish contract creation and function calls.

Each transaction being sent is its own object in the request body array. A transaction has a payload, which contains key information like the name of the contract, arguments for the transaction, and possible contract source code. The metadata field specifies information like contract history and the VM to use. The type property is used to specify the type of transaction being done, such as a contract upload ("CONTRACT"), or a function call ("FUNCTION"). The txParams property contains guidelines for STRATO to run this transaction.

The chainid property of a transaction payload specifies the chain ID of the contract that this function belongs to. Transactions on the Main Chain do not need to have the chain ID specified. Transactions that are on a private chain must have the contract address in the form '\:\'. Contracts on the main chain do not have to have the chain ID specified.

STRATO also offers the ability to handle transactions signed directly by the user, rather than signing the transaction with the user's key in STRATO's Key Vault. This is a complex topic and is reserved for a separate Offline Transactions article.

For the following examples of transaction API calls, we will use the following contract source code:

contract SimpleStorage {
  uint storedData;
  constructor(uint _storedData) {
    storedData = _storedData;
  }
  function set(uint x) returns (uint) {
    storedData = x;
  }

  function get() returns (uint) {
    return storedData;
  }
}

The response from the transactions endpoint is an array of result objects for each transaction that was sent. Each result has the following fields:

  • success, whether or not the API call was successful or not.
  • hash, the transaction hash.
  • txResult, an object containing useful transaction data, such as VM kind, chain ID of transaction, block hash, and gasUsed.
  • data, an object containing a tag for the type of transaction, and contents, for the information relevant to the type of transaction, like a contract address, function returned values, etc.

See Transaction Results for more details on the shape of the returned data from a transaction.

Resolve Option

The transaction and faucet endpoints accept a query parameter of resolve which can be set true or false. By default this value is false. Setting resolve to true will make the API not return a response until the sent operation has completed or been terminated. If an operation does not resolve within 60 seconds, the API will respond with an error status. If resolve is false, then the API will send the transaction(s) to STRATO for completion, however it will return a response immediately back to the user with a status of "Pending", and the transaction hash.txResult and data will both be null.

Tip

Transactions sent with resolve=false must be resolved before a transaction with resolve=true is sent to the API, otherwise it will be discarded. Always ensure a transaction has been completed using the transaction results endpoint.

Create a New Contract

In the example below we use 'contract-src' to refer to solidity code that is this contract to be uploaded. The args are the values needed for the constructor of this contract.

For a contract upload, the type parameter must be set to "CONTRACT".

Endpoint

POST https://<strato_address>/strato/v2.3/transaction?resolve=true

Example

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "txs": [
        {
          "payload": {
            "contract": "SimpleStorage",
            "src": "<contract-src>",
            "args": {
              "_storedData": 3
            }
          },
          "type": "CONTRACT"
        }
    ],
    "txParams": {
      "gasLimit": 32100000000,
      "gasPrice": 1
    }
  }' \
  "https://<strato_address>/strato/v2.3/transaction?resolve=true"

Response

An array of results of each transaction sent in the request body.

The data in the contents field contains many useful data points such as contract address, and codeHash.

[
  { 
    "status": "success",
    "hash": "936f9ea1f29edd4f71af8004c115c90687b9dedc4b99c3e653c6a06f7341e6c1",
    "txResult": {...},
    "data": {
      "tag": "Upload",
      "contents": {
        ...,
        "address": "90f0a711cd0ab921bbc9b54c4a6bdb3219e590f9",
      }
    }
  }
]

The transaction hash and status of the pending transactions.

[
  {
    "status": "Pending",
    "hash": "c93ad8273db797e15e473fd40e058195ef7f3de5507dfc8adc88ca00f4ebd70b",
    "txResult": null,
    "data": null
  }
]
// create contract payload
const contracts = [
  {
    name: "SimpleStorage",
    source: contractSrc,
    args: {
      _storedData: 3,
    },
  }
]

const callOptions = {
  ...options,
  config: {
    ...options.config,
    isAsync: true
  }
}

const transactionResults = await rest.createContractList(user, contracts, callOptions)

Response

A list of each contract's upload info.

[
  {
    bin: "bin removed.",
    chainId: null,
    address: "90f0a711cd0ab921bbc9b54c4a6bdb3219e590f9",
    'bin-runtime': "bin-runtime removed.",
    codeHash: {
      kind: "EVM",
      digest: "e96a25b0aa2a8b185b7f833e5b1b1cd4f06d3f740091633dd59bfea7b283f7c8"
    },
    name: "SimpleStorage",
    src: "source removed.",
    xabi: "xabi removed."
  }
]

Call a Function

The transaction endpoint allows functions within contracts to be called. In the example below args are the arguments given to this function contract.

To call a function on a private chain, specify the chain ID in the query parameter chainid or in the transaction payload property chainid.

For function calls, the type parameter must be set to "FUNCTION".

Due to maintaining Ethereum ABI compatibility, the returned data type of each value is a string regardless of its Solidity type.

Endpoint

POST https://<strato_address>/strato/v2.3/transaction?resolve=true

Example

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "txs": [
      {
        "payload": {
          "contractName": "SimpleStorage",
          "contractAddress": "90f0a711cd0ab921bbc9b54c4a6bdb3219e590f9",
          "method": "set",
          "args": {
            "x": 5
          }
        },
        "type": "FUNCTION"
      }
    ],
    "txParams": {
      "gasLimit": 32100000000,
      "gasPrice": 1
    }
  }' \
  "https://<strato_address>/strato/v2.3/transaction?resolve=true"

Response

[
  { 
    "status": "Success",
    "hash": "936f9ea1f29edd4f71af8004c115c90687b9dedc4b99c3e653c6a06f7341e6c1",
    "txResult": {...},
    "data": {
      "tag": "Call",
      "contents": [ "5" ]
    }
  }
]
const calls = [
  {
    contract: {
      name: "SimpleStorage",
      address: contractAddress,
    },
    method: "set",
    args: {
      x: 5
    }
  }
]

const callOptions = {
  ...options,
  config: {
    ...options.config,
    isAsync: true
  }
}

const callResults = await rest.callList(user, calls, callOptions)

Response

An array of each function call's return value(s).

[
  // The returned values from first transaction
  [
    "5"
  ]
]

Using SolidVM for Transactions

In order to use BlockApps' SolidVM, simply specify the VM in a transaction payload's metadata to 'SolidVM'. Valid VM types are 'EVM', and 'SolidVM'.

Example

Create a new contract with SolidVM.

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "txs": [
        {
          "payload": {
            "contract": "SimpleStorage",
            "src": "<contract-src>",
            "args": {
              "_storedData": 3
            },
            "metadata": {
              "VM": "SolidVM"
            }
          },
          "type": "CONTRACT"
        }
      ],
      "txParams": {
        "gasLimit": 32100000000,
        "gasPrice": 1
      }
    }' \
  "https://<strato_address>/strato/v2.3/transaction?resolve=true"
const contracts = [
  {
    name: "SimpleStorage",
    source: contractSrc,
    args: {
      _storedData: 3,
    },
  }
]

const callOptions = {
  ...options,
  config: {
    ...options.config,
    isAsync: true,
    VM: "SolidVM",
  }
}

const callResults = await rest.createContractList(user, contracts, callOptions)

Response

The returned data will be in the same shape as a normal contract upload.

Passing Complex Data Structures to Transaction Arguments

STRATO v7.6 added support for passing complex data structures in contract creation and function call API requests in SolidVM contracts. This allows users to use these data types as arguments in these API calls. Below are added types supported and how to send them in a API request:

Multidimensional Arrays

Multidimensional arrays can be sent as normal multidimensional JSON arrays.

Example

contract MultiDArrExample {

  int[][] matrix;

  constructor(int[][] _matrix) {
    matrix = _matrix;
  }
}

Transaction Arguments:

...,
args: {
  _matrix: [
    [1, 2, 3],
    [4, 5, 6],
  ]
}

Structs

Structs can be sent to the API as JSON objects, where each key of the object represents a data-point in the Solidity struct.

Please note is up to the user to ensure the shape of the struct passed to the API matches the definition of the struct. Doing otherwise will raise an exception in VM.

Example

contract StructExample {

  struct MyStruct {
    int x;
    int y;
  }
  int z;

  constructor(MyStruct _myStruct) {
    z = _myStruct.x + _myStruct.y;
  }
}

Transaction Arguments:

...,
args: {
  _myStruct: {
    x: 1,
    y: 2,
  }
}

Mappings

Mappings can be sent to the API as JSON objects, where each key-value pair of the object represents a key-value pair in the Solidity mapping.

String-type keys must be wrapped in single quotes.

Address-like keys/values are unsupported.

Please note is up to the user to ensure the types of the keys and values passed to the API match the definition of the mapping. Doing otherwise will raise an exception in the VM.

Example

contract MappingExample {

  int z;

  constructor(mapping(string => int) _myMapping, string _k) {
    z = _myMapping[_k];
  }
}
Transaction Arguments:

...,
args: {
  _myMapping: {
    "'foo'": 47,
    "'bar'": 82,
  },
  _k: "foo"
}

Transaction Results

You may access any transaction's results using its hash.

Endpoint

Get a single transaction's results:

GET https://<strato_address>/bloc/v2.2/transactions/<tx-hash>/result

Get multiple transactions' results:

POST https://<strato_address>/bloc/v2.2/transactions/results

When accessing multiple transactions' results, provide an array with each requested transactions' hash as elements in the request body.

Example

curl -X GET \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  "https://<strato_address>/bloc/v2.2/transactions/936f9ea1f29edd4f71af8004c115c90687b9dedc4b99c3e653c6a06f7341e6c1/result"
const transaction = {
  hash: txHash
}

const txResult = await rest.resolveResult(user, transaction, options)

Response

The information of the requested transaction.

{
  "status": "Success",
  "hash": "3edacd3a2a12d1357f836a5e14f7e4294869ce45035eec9b8be5f4c761679188",
  "txResult": {
    "deletedStorage": "",
    "status": "success",
    "contractsDeleted": "",
    "gasUsed": "0000000000000000000000000000000000000000000000000000000000019381",
    "stateDiff": "",
    "time": 0.0006703,
    "kind": "EVM",
    "chainId": null,
    "response": "<response>",
    "blockHash": "3a0f1ed3834733a32aafbe948fabbe22db242278dec4efe872c8196a1ccec218",
    "transactionHash": "3edacd3a2a12d1357f836a5e14f7e4294869ce45035eec9b8be5f4c761679188",
    "etherUsed": "0000000000000000000000000000000000000000000000000000000000019381",
    "newStorage": "",
    "message": "Success!",
    "trace": "",
    "contractsCreated": "eca3e4bb4de0e1fbfae17b45fa3dfce5ba9f8784,0000000000000000000000000000000000000000,ea245c8e259dcf724dd4852da6b288f6b0452db6"
  },
  "data": {
    "tag": "Upload",
    "contents": {
      "bin": "<binary>",
      "chainId": null,
      "address": "eca3e4bb4de0e1fbfae17b45fa3dfce5ba9f8784",
      "bin-runtime": "<binary-runtime>",
      "codeHash": {
        "kind": "EVM",
        "digest": "33e5b1b1cd4f06d3f7400916e96a25b0aa2a8b185b7f833dd59bfea7b283f7c8"
      },
      "name": "SimpleStorage",
      "src": "<contract-src>",
      "xabi": {
        // ...compiler information for contract functions, variables, modifiers, etc.
      }
    }
  }
}
{
  "status": "Success",
  "hash": "936f9ea1f29edd4f71af8004c115c90687b9dedc4b99c3e653c6a06f7341e6c1",
  "txResult": {
    "deletedStorage": "",
    "status": "success",
    "contractsDeleted": "",
    "gasUsed": "000000000000000000000000000000000000000000000000000000000000682d",
    "stateDiff": "",
    "time": 0.0006397,
    "kind": "EVM",
    "chainId": null,
    "response": "",
    "blockHash": "2724b0519d2fec120eca6c74504d1ebd3c7d98a4f90e0667f7b67652ba837edc",
    "transactionHash": "936f9ea1f29edd4f71af8004c115c90687b9dedc4b99c3e653c6a06f7341e6c1",
    "etherUsed": "000000000000000000000000000000000000000000000000000000000000682d",
    "newStorage": "",
    "message": "Success!",
    "trace": "",
    "contractsCreated": ""
  },
  "data": {
    "tag": "Call",
    "contents": [
      // each element is a returned value from the function
    ]
  } 
}

Using Cirrus

Query Cirrus

You may access any number of a given contract's instances via the Cirrus search endpoint. This provides data like contract address, chain ID, instance variables, block timestamp, etc.

Cirrus is queriable through the PostgREST API. This allows for SQL-like queries to be made right from the API parameters without exposing raw query strings on the data tables. For complete documentation on using the Cirrus API with PostgREST, visit the Cirrus Documentation.

Endpoint

GET https://<strato_address>/cirrus/search/<contract-name>

Example

This query filters the results of the SimpleStorage contracts which have storedData less than or equal to 10, limits the returned array to only two elements, and only selects the chain ID, address, block_number, and the storedData variable that is in the SimpleStorage contract.

curl -X GET \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  "https://<strato_address>/cirrus/search/SimpleStorage?storedData=lte.10&limit=2&select=chainId,address,block_number,storedData"
const query = {
  storedData: 'lte.10',
  limit: 2,
  select: 'chainId,address,block_number,storedData'
}

const searchOptions = {
  ...options,
  query
}

const contract = {
  name: "SimpleStorage"
}

const results = await rest.search(user, contract, searchOptions)

Response

An array of each contract instance matching the PostgREST query given in the request's query parameters.

[
  {
    "chainId": "",
    "address": "90f0a711cd0ab921bbc9b54c4a6bdb3219e590f9",
    "storedData": 5,
    "block_number": 6
  },
  {
    "chainId": "",
    "address": "171077556038f63f7debba796d96886abce0d4e1",
    "storedData": 3,
    "block_number": 7
  }
]

Accessing Contract Audit Trail/History

You can query for the history of any contract with history enabled by specifying querying cirrus with history@<contract-name> as the contract name. Call this endpoint just as you would a normal contract's Cirrus endpoint.

Endpoint

GET https://<strato_address>/cirrus/search/history@<contract-name>

Example

curl -X GET \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  "https://<strato_address>/cirrus/search/history@SimpleStorage?address=eq.803af30af892a9d84aa2231077779e143ea80fb0&order=block_timestamp.asc"
const query = {
  address: `eq.${contractAddress}`,
  order: 'block_timestamp.asc'
}

const searchOptions = {
  ...options,
  query
}

const contract = {
  name: "history@SimpleStorage"
}

const results = await rest.search(user, contract, searchOptions)

Response

This call will return an array of a contract's historical data. Below is an example of the history of the SimpleStorage contract if the storedData had been initalized to 10, and then the set function was called to set the value of storedData to 20.

[
  {
    "address": "803af30af892a9d84aa2231077779e143ea80fb0",
    "chainId": "",
    "block_hash": "5b336c2537afda79291581ff4f8d89138ec653c0d137192e6b2e931a0c890da1",
    "block_timestamp": "2021-09-28 15:19:17 UTC",
    "block_number": "6",
    "transaction_hash": "2f3fd0cefd452a1dbf539ff443a93b3f098a6485b33dbc83e3642b982663f1bf",
    "transaction_sender": "f6fedad2c09578a52100835c27de7927d73e6f2c",
    "transaction_function_name": "",
    "storedData": 10
  },
  {
    "address": "803af30af892a9d84aa2231077779e143ea80fb0",
    "chainId": "",
    "block_hash": "3b370b4061dc7643204123eb112f416507ad322cec015cf82f7434a6062e2ece",
    "block_timestamp": "2021-09-28 15:20:17 UTC",
    "block_number": "7",
    "transaction_hash": "1f2b255f01e0f80ed95c028a55adb29f7603916638f3b3aaf810d4e47237fc62",
    "transaction_sender": "f6fedad2c09578a52100835c27de7927d73e6f2c",
    "transaction_function_name": "",
    "storedData": 20
  }
]

Private Chains

Create a Private Chain

Private chains are a highlight feature of the STRATO platform allowing you to perform all blockchain operations in a private environment only visible to the explicit members of the private chain. For more information about Private Chains, their benefits, and how to best use them, see the Private Chains Feature Page. Create a new private chain with a provided governance contract and parent chain.

Endpoint

POST https://<strato_address>/bloc/v2.2/chain
Example

Here we create a new private chain as a 'child' of the Main chain. It's governance contract as shown in the Governance Section. Note because that contract does not take any constructor arguments, the args property is empty. For each group that should be members of this chain, we add their X.509 Certificate information, a combination of Organization Name, Organization Unit, Common Name and an access field that specifies whether they are allowed access to the chain or not, to the members array. The balances array is used when gas is enabled. When creating a chain as a child of a non-Main chain, the chain ID must be specified in the parentChain property of the request body.

curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
      "args": {},
      "members": 
        [
          {
            "access": true,
            "orgUnit":<orgUnit_1>,
            "commonName":<commonName_1>,
            "orgName": <orgName_1>
          },
          {
            "access":true,
            "orgUnit":<orgUnit_2>,
            "commonName":<commonName_2>,
            "orgName": <orgName_2>
          }
        ],
      "balances":
        [
          {
            "address": <member_1_user_address>
            "balance": <member_1_balance>,
          },
          {
            "address": <member_2_user_address>
            "balance": <member_2_balance>,
          }
        ],
      "contract": "Governance",
      "src": <governance-src>,
      "label": "MyPrivateChain"
    }' \
"https://<strato_address>/bloc/v2.2/chain"
const chainInfo = {
  label: "MyPrivateChain",
  src: governanceSrc,
  args: {},
  members: [
    {
      address: memberAddress,
      enode: memberEnode
    }
  ],
  balances: [
    {
      address: memberAddress,
      balance: memberBalance
    }
  ],
}

const contractInfo = {
  name: "Governance"
}

const chainId = await rest.createChain(user, chainInfo, contractInfo, options)

Response

The chainId of the newly created chain:

"4574c8c75d6e88acd28f7e467dac97b5C60c3838d9dad993900bdf402152228e"

Access Chain Information

Get information about a specific chain or a number of chains. The query parameter chainid allows users to specify one or more chain IDs to get information about. If no chain IDs are provided, information about every chain this user has access to will be returned.

Endpoint

GET https://<strato_address>/strato-api/eth/v1.2/chain"
Example

curl -X GET \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <token>" \
  "https://<strato_address>/strato-api/eth/v1.2/chain?chainid=4574c8c75d6e88acd28f7e467dac97b5C60c3838d9dad993900bdf402152228e"

Response

[
  {

    "id": "4574c8c75d6e88acd28f7e467dac97b5C60c3838d9dad993900bdf402152228e",
    "info": {
      ...,
      "label": "MyPrivateChain",
      "members": [...],
      "accountInfo": [...],
      "nonce": "123...",
      "codeInfo": [...],
      "parentChain": null
    }
  }
]
const chainInfo = await rest.getChain(stratoUser, chainId, options)

Response

Information for the specified chain.

{
  id: "4574c8c75d6e88acd28f7e467dac97b5C60c3838d9dad993900bdf402152228e",
  info: {
    label: "MyPrivateChain",
    balances: [...],
    members: [...],
  }
}

More

For a full detailed reference of API endpoints, see the API Reference Guide section of this documentation.

Check out our VS Code extension! Signup for STRATO Mercata