Ame Network home pagelight logodark logo
  • Website
  • Support
  • Support
  • Github
  • Introduction
    • What is Ame?
    Onchain Stack
    • Component
      • Overview
      • Building your Component
      • FAQs
    • Ame Scan
    • Ame SDK
    Protocols
    • EIP-7654
    • EIP-7566
    • MSCP
    Aser Agent
    • Overview
    • Quick Start
    • Memory
    • Knowledge
    • Tool Kits
    • Thinking
    • MCP
    • MSCP
    • Social Clients
    • CLI
    • API
    • Trace
    • Workflow
    Component

    FAQs

    FAQs about Component

    How to customize response status code?

    The return value type of each request method is bytes, so you can customize the response status code and other response information according to your needs.

    How to disable a request method?

    You can add a mapping(string=>bool) to save the request method name and available state. After the application is upgraded, manually set the available state of the disabled request method to false. And check the state every time a request is processed.

    Why is there no delete method type?

    The data in smart contracts is public, and deleting data is an inefficient operation. In order to facilitate data management and retrieval, you can add a mapping to save the valid state of the data, and add a put request method to set valid and invalid data. And only return valid data in get method.

    How to dynamically add new request methods?

    Before deploying the contract, you can add a mapping (address=>bool) to record the external contract permissions. When the application adds new functions, give the v2 contract write permissions and add new request methods to the v2 contract.

    How to encode request parameters and decode response?

    Use getMethodReqAndRes to get the data type of the method request parameters and the data type of the response value. Then use some js library to encode and decode it.For example:
    Copy
    Ask AI
    var reqDataEncode = web3.eth.abi.encodeParameters(
      ["string", "uint256"],
      ["alice", "1"]
    );
    
    var resDataDecode = web3.eth.abi.decodeParameters(
      ["string", "uint256"],
      reqDataEncode
    );
    
    Building your ComponentAme Scan
    xgithubyoutube
    Powered by Mintlify
    Assistant
    Responses are generated using AI and may contain mistakes.