Apibase Monitor

Ready for Sale

UTILITYTOOLSDOCUMENTS

Apibase Monitor

Apibase is a solidity smart-contract with the purpose and scope to bridge comunication between a custom contracts and the external world (out of the blockchain) through API requests.
It has methods to log events with indexed parameters and a java application, on top of Web3j package, is built to monitor and operate API requests with the response written back to the Apibase smart contract.
Apibase will call the custom contract with the response it receives.

Apibase contract in details:

+ Events

- __RequestIdEvent__  logs the queryApiBase function call with the below parameters:  
    1. uint256 indexed requestId, logs the request id specific to the call  
    2. uint256 indexed _queryType, logs the query id specific to the call; 0 storage is contract internal and 1 storage is made to mongodb and a link to the response is made  
    3. uint256 indexed _customRequestId, logs the custom request id that was sent by the calling contract  
    4. string _method, logs the request type GET or POST  
    5. string _url, logs the URL to be called by the java monitor  
    6. string _params, logs the parameters to attach in case of a POST call, in json format  
  • ApiCompleted logs the updateApiResponse function call with the below parameters:

    1. uint256 indexed _requestId, logs the request id specific to the call
  • OwnershipRenounced logs the updateApiResponse function call with the below parameters:

    1. address indexed previousOwner;
  • OwnershipTransferred

    1. address indexed previousOwner, logs the previous owner of the contract
    2. address indexed newOwner, logs the new owner of the contract

+ Available Variables
- owner is the owner of the contract; only the owner can execute the main methods of the contract
- gasAddress is the address to receive the payment for response gas
- myTypeMap is a solidity map to store the query type (0 contract internal response storage/1 contract external storage) in the format: requestId => queryType
- myResultMap is a solidity map to store the results for each request in the format: requestId => result
- allowedOwnerMembers is a solidity map to store the allowed member addresses to connect, access and operate the Apibase contract
- requestAllowedOwnerMembers is a solidity map to store the requests that are correlated to their owner; only the request owner can see the result
- requestCallingContractAddress is a solidity map to store the contract addresses that are correlated to each request id
- requestIsProcessed is a solidity map to store the requests that are processed by java monitor
- customRequestIds list of custom request Ids to be returned to calling contract: requestId => customRequestId
- counter stores the internal request id counter

+ Methods
- _queryApiBase
1. address _callingContract, log the address of the calling contract
2. uint256 _type, is the query type specific to the call; 0 storage is contract internal and 1 storage is made to mongodb and a link to the response is made
3. string _method, is the request type GET or POST
4. string _url, is the URL to be called by the java monitor
5. string _params, are the parameters to attach in case of a POST call in json format
6. uint256 customRequestId, logs the custom request id that was sent by the calling contract

        __Note:__ can be executed only by approved member    
- __updateApiResponse__   
    1. uint256 _requestId, the request id  
    2. string _response, the response relative to the request id  
    __Note:__ can be executed only by contract owner  
  • getResult returns the response for a request id

    1. uint256 _requestId, the request id

      Note: can be executed only by approved member

  • getRequestType gets the request type (GET or POST) specific for a request id

    1. uint256 _requestId, the request id

      Note: can be executed only by approved member

  • getAllowedOwnerMembers returns if an address is a member and can call the Apibase contract

    1. address _member

      Note: can be executed only by contract owner

  • addOwnerMember enables the member address to call the Apibase contract

    1. address _memberAddress

      Note: can be executed only by contract owner

  • disableOwnerMember disables the member address from calling the Apibase contract

    1. address _memberAddress

      Note: can be executed only by contract owner

  • setGasPayAddress sets the account address that records the payments for response calls from Apibase contract to the calling contract

    1. address _address

      Note: can be executed only by contract owner

  • getGasPayAddress returns the account address that records the payments for response calls from Apibase contract to the calling contract

    Note: can be executed only by approved member

Custom contract:

The custom contract is the contract that connects and creates a communication to the Apibase contract.
The response from the Apibase contract comes back and it is written

+ Mandatory methods:
- updateValue used by Apibase java monitor to send back the response for the callApi call
1. string _result

The custom contract must contain the below Apibase interface:

``` contract ApiBase {
function queryApiBase(address _callingContract, uint256 _type, string _method, string _url, string _params);
function updateApiResponse(uint256 _requestId, string _response);
}
```

Reviewed by Modex
Buy

Copyright © Modex Marketplace