IZZZIO Blockchain Platform API Methods Reference

Version 1.2.0. LLC “Izio”, Moscow, 2024

This is a translation of the Russian original. If the versions differ, the Russian version prevails.

Contents

    Introduction

    The API consists of classes designed for remote invocation of the blockchain’s core procedures (Remote Procedure Call, RPC). Calls are made by means of POST and GET requests to the server. Several API implementations are provided: for use in Node.js applications, for PHP applications, and for direct JSON API calls.

    1. Node.js API

    Node.js API bindings. Available in the main repository under /api/node/

    1.1. NodeRPC class

    Constructor:

    new NodeRPC([RPCUrl = 'http://localhost:3001/', pass = ''])

    Arguments:

    • RPCUrl (string) - Address of the remote server to connect to, in the format “http://address:port”
    • pass (string) - Password for connecting to the remote server

    Returns object:

    An initialized object with a set of methods.

    HTTP request to the server:

    _urlRequest([method = 'GET', url = "", params = [], password = '', login = "1337"])

    Arguments:

    • method (string) - Request method
    • url (string) - Address to which the request is made
    • params (array) - Array of request parameters (for POST)
    • password (string) - Password (if the connection is password-protected)
    • login (string) - Login for the connection

    Returns Promise<object>:

    Returns a promise of the server’s response object for the request

    RPC request to the server:

    _request([method = "", params = [], paramStr = ''])

    Arguments:

    • method (string) - Method called on the server
    • params (array) - Array of request parameters (for POST)
    • paramStr (string) - Parameters to be appended to the request URL

    Returns Promise<object>:

    Returns a promise of an object with the contents of the data field of the server’s response

    Getting blockchain information and status:

    getInfo()

    Returns Promise<object>:

    Returns a promise with information about the blockchain

    Creating and registering a new wallet:

    createWallet()

    Returns Promise<object>:

    Returns a promise with information about the new wallet

    Getting the address of the current wallet:

    getWallet()

    Returns Promise<string>:

    Returns a promise with the address of the current wallet

    Changing the current wallet to a new one. The list of transactions will be recalculated, which may take considerable time:

    changeWalletByData(id, privateKey, publicKey)

    Arguments:

    • id (string) - Address of the new wallet
    • privateKey (string) - Private key for the new wallet
    • publicKey (string) - Public key for the new wallet

    Returns Promise<string>:

    Returns a promise with the operation status

    Getting a block by its id:

    getBlockById(blockId)

    Arguments:

    • blockId (number | string) - Block identifier

    Returns Promise<object>:

    Returns a promise with information about the block

    1.2. EcmaSmartRPC class

    This class provides the main set of methods for working with ECMA contracts. It inherits from NodeRPC.

    Constructor:

    new EcmaSmartRPC([RPCUrl = 'http://localhost:3001/', pass = ''])

    Arguments:

    • RPCUrl (string) - Address of the remote server to connect to, in the format “http://address:port”
    • pass (string) - Password for connecting to the remote server

    Returns object:

    An initialized object with a set of methods.

    Getting information about the ECMA smart contract subsystem.

    ecmaGetInfo()

    Returns Promise<object>:

    Returns a promise of an object with information about the ECMA smart contract subsystem.

    Getting information about a contract:

    ecmaGetContractInfo(contractAddress)

    Arguments:

    • contractAddress (string) - Address of the contract whose information is requested

    Returns Promise<object>:

    Returns a promise of an object with information about the contract.

    Getting a contract property:

    ecmaGetContractProperty(contractAddress, property)

    Arguments:

    • contractAddress (string) - Address of the contract whose information is requested
    • property (string) - Property name

    Returns Promise<any>:

    Returns a promise with the requested property. The type of the returned value depends on the type of the property.

    Calling a contract method with subsequent rollback of changes:

    ecmaCallMethod(contractAddress, method, params)

    Arguments:

    • contractAddress (string) - Contract address
    • method (string) - Name of the method being called
    • params (array) - Parameters for the method

    Returns Promise<any>:

    Returns a promise of the call result or an error.

    Calling a contract method with subsequent recording of changes to the blockchain:

    ecmaDeployMethod(contractAddress, method, params)

    Arguments:

    • contractAddress (string) - Contract address
    • method (string) - Name of the method being called
    • params (array) - Parameters for the method

    Returns Promise<any>:

    Returns a promise with the block contents or an error.

    Deploying a new contract to the network:

    ecmaDeployContract(source [, resourceRent = '0'])

    Arguments:

    • source(string) - JavaScript source code of the smart contract
    • resourceRent (string | number) - Number of tokens allocated for resource rent

    Returns Promise<any>:

    Returns the contract object or an error

    Deploying a new contract to the network with a signed block:

    ecmaDeployContractSignedBlock(block [, resourceRent = '0'])

    Arguments:

    • block (object) - JavaScript object of the signed contract block
    • resourceRent (string | number) - Number of tokens allocated for resource rent

    Returns Promise<any>:

    Returns the contract object or an error

    Calling a contract method with subsequent recording of changes to the blockchain. Unlike deployMethod, it takes a signed EcmaContractCallBlock as input:

    ecmaDeployMethodSignedBLock(contractAddress, block)

    Arguments:

    • contractAddress (string) - Contract address
    • block (object) - JavaScript object of the signed contract block

    Returns Promise<any>:

    Returns a promise with the block contents or an error.

    2. PHP API

    API classes for PHP. Available under /api/php

    2.1. NodeRPC class

    This class provides a basic set of methods for making requests to the blockchain.

    Constructor:

    public function __construct([$RPCUrl = 'http://localhost:3001/', $password = ''])

    Arguments:

    • $RPCUrl (string) - Address of the remote server to connect to, in the format “http://address:port”
    • $password (string) - Password for connecting to the remote server

    Returns mixed:

    An initialized object with a set of methods.

    cURL request to the server:

    private static function curlRequest([$method = 'get', $url, $params = [], $password = ''])

    Arguments:

    • $method (string) - Request method
    • $url (string) - Address to which the request is made
    • $params (array) - Array of request parameters (for POST)
    • $password (string) - Password (if the connection is password-protected)

    Returns mixed | string:

    Returns the server’s response to the request

    RPC request to the server:

    protected function request([$method, $params = [], $paramStr = ''])

    Arguments:

    • $method (string) - Method called on the server
    • $params (array) - Array of request parameters (for POST)
    • $paramStr (string) - Parameters to be appended to the request URL

    Returns array | mixed | InvalidMethodException | ReturnException | RpcCallException :

    Returns the body of the server’s response or an exception

    Getting blockchain information and status:

    public function getInfo()

    Returns mixed | InvalidMethodException | ReturnException | RpcCallException :

    Returns an object with information about the blockchain or an exception

    Creating and registering a new wallet:

    public function createWallet()

    Returns mixed | InvalidMethodException | ReturnException | RpcCallException:

    Returns information about the new wallet or an exception

    Getting the address of the current wallet:

    public function getWallet()

    Returns mixed | InvalidMethodException | ReturnException | RpcCallException:

    Returns an object with the address of the current wallet or an exception

    Changing the current wallet to a new one. The list of transactions will be recalculated, which may take considerable time:

    public function changeWalletByData($id, $private, $public)

    Arguments:

    • $id (string) - Address of the new wallet
    • $privateKey (string) - Private key for the new wallet
    • $publicKey (string) - Public key for the new wallet

    Returns array| InvalidMethodException | ReturnException | RpcCallException:

    Returns the new wallet or an exception

    Changing the current wallet to a new one. The list of transactions will be recalculated, which may take considerable time:

    public function changeWallet($wallet)

    Arguments:

    • $wallet (array) - Array obtained from the createWallet method

    Returns array| InvalidMethodException | ReturnException | RpcCallException:

    Returns the new wallet or an exception

    2.2. EcmaSmartRPC class

    This class provides the main set of methods for working with ECMA contracts. It inherits from NodeRPC.

    Constructor:

    public function __construct([$RPCUrl = 'http://localhost:3001/', $password = ''])

    Arguments:

    • $RPCUrl (string) - Address of the remote server to connect to, in the format “http://address:port”
    • $password (string) - Password for connecting to the remote server

    Returns mixed:

    An initialized object with a set of methods.

    Getting information about the ECMA smart contract subsystem.

    public function ecmaGetInfo()

    Returns array | mixed:

    Returns an object with information about the ECMA smart contract subsystem.

    Getting information about a contract:

    public function ecmaGetContractInfo($contractAddress)

    Arguments:

    • $contractAddress (string) - Address of the contract whose information is requested

    Returns array | mixed:

    Returns an object with information about the contract.

    Getting a contract property:

    public function ecmaGetContractProperty($contractAddress, $property)

    Arguments:

    • $contractAddress (string) - Address of the contract whose information is requested
    • $property (string) - Property name

    Returns array | mixed:

    Returns an object with the requested property. The type of the returned value depends on the type of the property.

    Calling a contract method with subsequent rollback of changes:

    public function ecmaCallMethod($contractAddress, $method, $params)

    Arguments:

    • $contractAddress (string) - Contract address
    • $method (string) - Name of the method being called
    • $params (array) - Parameters for the method

    Returns array | mixed:

    Returns the call result or an error.

    Calling a contract method with subsequent recording of changes to the blockchain:

    public function ecmaDeployMethod($contractAddress, $method, $params)

    Arguments:

    • $contractAddress (string) - Contract address
    • $method (string) - Name of the method being called
    • $params (array) - Parameters for the method

    Returns array | mixed:

    Returns the block contents or an error.

    Deploying a new contract to the network:

    public function ecmaDeployContract($source [, $resourceRent = '0'])

    Arguments:

    • $source(string) - JavaScript source code of the smart contract
    • $resourceRent (string | number) - Number of tokens allocated for resource rent

    Returns array | mixed:

    Returns the contract object or an error

    Deploying a new contract to the network with a signed block:

    public function ecmaDeployContractSignedBlock($block [, $resourceRent = '0'])

    Arguments:

    • $block (object) - JavaScript object of the signed contract block
    • $resourceRent (string | number) - Number of tokens allocated for resource rent

    Returns array | mixed:

    Returns the contract object or an error

    Calling a contract method with subsequent recording of changes to the blockchain. Unlike deployMethod, it takes a signed EcmaContractCallBlock as input:

    public function ecmaDeployMethodSignedBlock($contractAddress, $block)

    Arguments:

    • $contractAddress (string) - Contract address
    • $block (object) - JavaScript object of the signed contract block

    Returns array | mixed:

    Returns the block contents or an error.

    3. JSON RPC API

    Built-in RPC API methods. Available on the node’s RPC port. If rpcPassword is not empty, HTTP Auth is required, specifying the password and any arbitrary user name

    3.1. Main methods

    • GET /getInfo
    • GET /getBlock/:id:
    • GET /isReadyForTransaction
    • POST /createWallet
    • POST /resyncBlockchain
    • GET /downloadWallet
    • POST /restoreWallet
    • POST /changeWallet

    GET /getInfo

    Getting information about the current blockchain node

    GET /getBlock/:id:

    Getting a block object by its number

    GET parameters:

    • id - String. Block index

    GET /isReadyForTransaction

    Returns true or false. Checks whether synchronization is complete and the node is ready to create new transactions.

    POST /createWallet

    Creates a new wallet, generating a private and a public key. Returns a Wallet structure

    POST /resyncBlockchain

    Starts recalculation of the blockchain

    GET /downloadWallet

    Returns the current wallet file with the public and private keys

    POST /restoreWallet

    Loads a wallet structure as the main one

    POST parameters:

    • public - String. Public key of the wallet
    • private - String. Private key of the wallet
    • id - String. Wallet address
    • block - Number. Number of the block in which the wallet is defined
    • balance - Number. Wallet balance

    POST /changeWallet

    Same as restoreWallet

    POST parameters:

    • public - String. Public key of the wallet
    • private - String. Private key of the wallet
    • id - String. Wallet address
    • block - Number. Number of the block in which the wallet is defined
    • balance - Number. Wallet balance

    4. API methods of the EcmaContract class

    The contracts/ecma methods provide functionality for working with EcmaContract smart contracts

    The following methods are used to interact with a contract via the API:

    • POST contracts/ecma/deployContract
    • GET contracts/ecma/getContractInfo/:contractAddress:
    • GET contracts/ecma/getContractProperty/:contractAddress:/:property:
    • POST contracts/ecma/callMethod/:contractAddress:/:method:
    • POST contracts/ecma/deployMethod/:contractAddress:/:method:
    • POST contracts/ecma/deploySignedMethod/:contractAddress:
    • GET /contracts/ecma/getInfo

    POST contracts/ecma/deployContract

    Deploying a new contract to the network

    POST parameters:

    • resourceRent - Number (0 or greater). Number of tokens allocated for resource rent
    • source - String. JavaScript source code of the smart contract

    POST contracts/ecma/deployContract Alternative way of calling

    Deploying a new contract to the network using a signed block

    POST parameters:

    • resourceRent - Number (0 or greater). Number of tokens allocated for resource rent
    • source - JSON object containing the signed contract deployment block

    GET contracts/ecma/getContractInfo/:contractAddress

    Getting information about a contract

    GET parameters:

    • contractAddress - String. Contract address

    GET contracts/ecma/getContractProperty/:contractAddress:/:property

    Getting the value of a contract property

    GET parameters:

    • contractAddress - String. Contract address
    • property - String. Property name

    POST contracts/ecma/callMethod/:contractAddress:/:method:

    Calling a contract method with subsequent rollback of changes, returning the call result or an error

    GET parameters:

    • contractAddress - String. Contract address
    • method - String. Name of the method being called

    POST parameters:

    • argsEncoded - String. JSON-serialized value with the list of call arguments

    POST contracts/ecma/deployMethod/:contractAddress:/:method:

    Calling a contract method with subsequent recording of changes to the blockchain. Returns the contents of the new block or an error.

    GET parameters:

    • contractAddress - String. Contract address
    • method - String. Name of the method being called

    POST parameters:

    • argsEncoded - String. JSON-serialized value with the list of call arguments

    POST contracts/ecma/deploySignedMethod/:contractAddress:

    Calling a contract method with subsequent recording of changes to the blockchain. Unlike deployMethod, it takes a signed EcmaContractCallBlock as input

    GET parameters:

    • contractAddress - String. Contract address

    POST parameters:

    • source - String. JSON-serialized object of the signed block

    GET /contracts/ecma/getInfo

    Getting information about the latest block of the network

    ← Documents