# Module API
Each module in Miyabi provides additional endpoints. To verify if a module is correctly loaded, swagger has a list of the ones supported.
# Definition of Terms
Term | Definition |
---|---|
Asset Table | Is used to store a user assets in an address. In order to move assets between addresses, the signature of the owner is needed. If the table has a Trusted address defined, the owner of Trusted address can move assets from other addresses to its own using its signature. Generation of assets can only be done if they are signed by the table owner. |
Entity Table | Is used to store the data of users in binary key value pairs. This table supports a way to manage the relationships between different rows of pairs so a user can store arbitrary values separately. Also, it can implement a permissioned row table, which combined with the mentioned relationships, can have sets of data with different permissions for each user. |
Entity Owner | Is the individual that owns a particular row in an entity table. If an entity does not have an owner, it can only be accessed by the update admin. |
# Definition of Parameters
Parameter | Type | Description | Limit | Comment |
---|---|---|---|---|
Assembly ID | hexadecimal | Each contract has an unique assembly ID associated with its code. | N/A | Can be calculated through the Miyabi client command compilecontract, specifying the source code as a parameter. |
Contract Name | string | The contract name is the class name of a C# contract file | N/A | The class should inherit from contractbase. |
Instance Name | string | It is the name given to an instance of a contract. | N/A | |
Method Name | string | It is the name of a method inside the smart contract class. | N/A |
# Asset API
# Get Asset Table
Returns the list of asset addresses and balances for a particular table.
# Request
- Method: GET
- URL: /asset/table/{tableName}
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": { "Address1":"value1", "Address2":"value2", }, "atHeight": "Current block height of the request", }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
# Get Asset
Returns the asset amount from a given address if there is any, otherwise it will return 0.
# Request
- Method: GET
- URL: /asset/value/{tableName}/{Address}
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": "the value of the entry.", "atHeight": "Current block height of the request" }
returns 0 if the value does not exist.
If the table is read restricted, this endpoint cannot be used.
Object Not Found
- Code: 404
- Reason:
- Table does not exist
Validation Error
- Code: 400
- Reason:
- Address is not a valid public key
# Contract API
# Query Method
Queries a method in a deployed smart contract. This is a 'read-only' operation and will not change any state on the blockchain. The result of the method will be returned as a JSON string.
# Request
- Method: GET
- URL: /contract/query/{asmId}/{contractName}/{instanceName}/{methodName}
- Query Parameters in URL:
Arguments=["<parameters>",]
# Response
Success
Code: 200
Return value:
{ "value": "the result of the method.", "atHeight": "Current block height of the request" }
Object Not Found
- Code: 404
- Reason:
- Smart contract method does not exist
Validation Error
- Code: 400
- Reason:
- contractName, instanceName, methodName are null or empty
- Assembly ID is not a valid byte string
# Get Deployed Contract
Returns a list of all deployed contracts' assemblies.
# Request
- Method: GET
- URL: /contract/assemblies
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": [List of Assembly Ids], "atHeight": "Current block height of the request" }
# Get Instances
Return the white-listed assembly, namespace, and classes that can be used in the smart contract and the forbidden namespace, classes, and methods within the white list that cannot be used in a smart contract.
# Request
- Method: GET
- URL: /contract/instances
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": { "Instance Id": { "Assembly Id": "Assembly Id of the Instance", "Contract Name": "Contract Name of the Instance", "Instance Name": "Instance Name of the Instance", } }, "atHeight": "Current block height of the request", }
# Get Analyzer Parameters
Return the white-listed assembly, namespace, and classes that can be used in the smart contract and the forbidden namespace, classes, and methods within the white list that cannot be used in a smart contract.
# Request
- Method: GET
- URL: /contract/analyzer/parameters
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value":[{ "AnalyzerParameterName":"Analyzer parameters name - AllowedAssemblies, AllowedMembers, or ForbiddenMembers", "ListOfParameters":[<Fully qualified names of assemblies, namespace, class, methods, or members that belong to the list>] }], "atHeight": "Current block height of the request", }
# Entity API
# Get Entity Table
Returns the entire content from a given entity table. If it is read restricted, this endpoint cannot be used.
# Request
- Method: GET
- URL: /entity/table/{tableName}
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": { "Address": { "value":["Parent","Children"] } }, "atHeight": "Current block height of the request", }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
# Get Entity
Returns the value from a given entity in an entity table. If the table is read restricted, this endpoint cannot be used.
# Request
- Method: GET
- URL: /entity/value/{tableName}/{key}
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": { "EntryKey":"Value" }, "atHeight": "Current block height of the request", }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
Validation Error
- Code: 400
- Reason:
- entrykey is not a byte string
# Get Entity Tree
Returns the entity relationships from a given entity in an entity table. Each child will return the full information of the entry to form a hierarchical structure. It can be filtered by depth. If the table is read restricted, this endpoint cannot be used.
# Request
- Method: GET
- URL: /entity/tree/{tableName}/{key}
- Query Parameters in URL:
Depth (Default to 1000)
# Response
Success
Code: 200
Return value:
{ "value": { "value": "Entity Value", "children": "Children tree of the entity", "IsRecursive": "whether a entity can be its ancient entity or not" }, "atHeight": "Current block height of the request", }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
Validation Error
- Code: 400
- Reason:
- entrykey is not a byte string
- Depth is not a valid positive integer or null
# NFT API
# Get NFT Table
Returns the entire content from a given NFT table.
# Request
- Method: GET
- URL: /NFT/table/{tableName}
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": [{ "TokenId": "Owner Addresses" }], "atHeight": "Current block height of the request", }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
# Get Owner of NFT
Return the owner of a specific NFT
# Request
- Method: GET
- URL: /NFT/value/{tableName}/{tokenId}/owner
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": "the address of Owner", "atHeight": "Current block height of the request" }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
Validation Error
- Code: 401
- Reason:
- Token ID is not a valid ByteString
# Get Balance of Owner
Returns the number of tokens owned by a given owner.
# Request
- Method: GET
- URL: /NFT/value/{tableName}/{address}/balance
- Query Parameters in URL: None
# Response
Success
Code: 200
Return value:
{ "value": "the number of owned token", "atHeight": "Current block height of the request" }
Object Not Found
- Code: 404
- Reason:
- Table does not exist
- Owner does not exist
Validation Error
- Code: 401
- Reason:
- Owner does not hold a valid public key