Enhanced and raw ABIs
MultiBaas generates its own stable ABI that provides a stable platform to build DApps on. The MultiBaas ABI, along with the rest of the MultiBaas REST API, is versioned and the ABI will remain stable within the same version of the REST API.
The MultiBaas ABI combines the information provided by the solc ABI output, solc developer and user documentation output, and extra MultiBaas metadata, into a single data structure. It represents the state of a smart contract based on the ABI derived from its Solidity source code, and meta-configuration as persisted in MultiBaas.
The following is a comparison of the high level structure of the solc ABI vs. the MultiBaas ABI:
solc ABI:
[
{ //constructor, fallback, function or event },
...
]
MultiBaas ABI:
{
"constructor": {},
"methods": {},
"events": {},
"fallback": null
}
Example
When making a GET request for an uploaded contract, the response will contain both an abi field which is the enhanced MultiBaas ABI and a rawAbi field which is the ABI generated by solc.
Here is an example for a simple contract that has one method "tentacles" that returns a uint256:
pragma solidity ^0.5.7;
/// @dev Octopus is an octopus
contract Octopus {
/// @author Paul Oktopus
/// @dev Function to return the number of tentacles
/// @param _octopus The address of the octopus
/// @param tentacles The number of tentacles
/// @return uint256 the number of tentacles of the octopus
function tentacles(address _octopus) public view returns (uint256 tentacles) {
return 8;
}
}
And here is the result of querying that contract after it has been uploaded in MultiBaas:
Request:
GET .../contracts/octopus
Beginning of Response:
{
"status": 200,
"message": "success",
"result": {
"label": "octopus",
"contractName": "Octopus",
"version": "1.3",
"src": "...",
"bin": "...",
MultiBaas ABI:
"abi": {
"constructor": {
"name": "",
"signature": "",
"const": false,
"payable": false,
"inputs": null,
"outputs": null,
"author": "",
"notes": "",
"returns": "",
"description": "",
"cache": false
},
"methods": {
"tentacles(address)": {
"name": "tentacles",
"signature": "tentacles(address)",
"const": true,
"payable": false,
"inputs": [
{
"name": "_octopus",
"type": {
"type": "address",
"size": 20
},
"typeConversion": null,
"summarization": null,
"notes": "The address of the octopus"
}
],
"outputs": [
{
"name": "tentacles",
"type": {
"type": "uint",
"size": 256
},
"typeConversion": null,
"summarization": null,
"notes": ""
}
],
"author": "Paul Oktopus",
"notes": "Function to return the number of tentacles",
"returns": "uint256 the number of tentacles of the octopus",
"description": "",
"cache": false
}
},
"events": {},
"fallback": null
},
raw ABI (solc ABI):
"rawAbi": "[{\"constant\":true,\"inputs\":[{\"name\":\"_octopus\",\"type\":\"address\"}],\"name\":\"tentacles\",\"outputs\":[{\"name\":\"tentacles\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]",
Remainder of response:
"language": "solidity",
"languageVersion": "0.5.10",
"compilerVersion": "0.5.10",
"compilerOptions": "...",
"userDoc": "...",
"developerDoc": "...",
"metadata": "...",
"isFavorite": "...",
"instances": "..."
}
}