Skip to Content
DocumentationAnalog GMPBuilding With OATSProtocol ArchitectureBest Practices for Secure and Efficient OATS Integration

Best Practices for Secure and Efficient OATS Integration

While the Timechain provides a secure foundation with features like TSS and NPoS, you are responsible for securing your own dApp. To build secure and efficient smart contracts on Analog, consider the following:

  • Security First:
    • Ownable and Access Control: Use Ownable or a similar access control pattern to protect administrative functions like set_network. Only the owner should be able to change critical addresses.
    • Validate the Gateway: The most critical check in your onGmpReceived function is require(msg.sender == address(_gateway), "Unauthorized"). This ensures that mint/unlock operations can only be initiated by the trusted Analog GMP Gateway.
    • Input Validation: Sanitize all inputs to prevent unexpected behavior.
  • Gas Efficiency:
    • The cost() function helps estimate the fee required for the cross-chain transaction. Ensure your frontend can fetch this value and inform the user.
    • Keep the logic inside onGmpReceived as lean as possible to minimize gas consumption on the destination chain.
  • Modularity:
    • Separate your core token logic from the OATS interoperability logic. The Lock/Unlock model is a good example, where a dedicated Bridge contract handles all OATS interactions, leaving the original ERC20 token untouched.