Basechain
  • About Basechain
  • Base BigBang Language
    • Introduction
    • 1. Getting started
      • 1.1 Installing BigBangNet
      • 1.2 BigBang basics
    • 2. Type
      • 2.1 Primitives
      • 2.2 Sequences
      • 2.3 Composites
    • 3. Keywords
    • 4. Storing data
      • 4.1 Constants
      • 4.2 Variables
      • 4.3 Maps
    • 5. Functions
      • 5.1 Public functions
      • 5.2 Private functions
      • 5.3 Read-only functions
  • 6. Control flow & error handling
    • 6.1 Asserts
    • 6.2 Try
    • 6.3 Unwrap flavours
    • 6.4 Response checking
  • 7. Using BigBangNet
    • 7.1 Creating a new project
    • 7.2 Writing your first contract
    • 7.3 Interacting with your contract
    • 7.4 Testing your contract
  • 8. Practice projects
    • 8.1 Time-locked wallet
    • 8.2 Smart claimant
    • 8.3 Multi-signature vault
  • 9. Traits
    • 9.1 Defining traits
    • 9.2 Implement traits
    • 9.3 Passing traits as arguments
  • 10. Building a marketplace
    • 10.1 Setup
    • 10.2 Listing & cancelling
    • 10.3 Fulfilling listings
    • 10.4 Uni tests
  • 11. Runtime cost analysis
  • Nodes & Miners
    • Run a Node with Docker
    • Run a Node with DigitalOcean
    • Run a Node with a Hosted Provider
    • Base Node Configuration
    • Mine testnet Base tokens
    • Verify Miner
    • Miner costs and fees
  • Website
  • X(Twitter)
  • Github
Powered by GitBook
On this page
  1. 6. Control flow & error handling

6.4 Response checking

We have learned that the response of a public function determines whether a state change occurs on the chain. This applies not only to the initial contract call but also to subsequent calls. If a principal calls Contract A, which then calls Contract B, any changes made to Contract B's data members will be reverted if Contract B returns an error. However, Contract A can still modify its own data members and have those changes take effect if it returns a success. It is important to note that the first contract in the call retains ultimate control. If the function returns an error, any subsequent actions will not occur.

Therefore, committing or reverting changes must be done sequentially.

This means that in a chain of multiple contract calls, the calling contract can be certain that a sub-call will not occur on-chain if it returns an error response. However, a contract may still depend on the success of the sub-contract call. For instance, a wallet contract may call a token contract to transfer a token. Developers often forget to check the return value, which can lead to mistakes. To prevent this, BigBang requires all intermediary responses to be checked. An intermediary response is a response that is part of an expression but not the one that is returned.

Previous6.3 Unwrap flavoursNext7. Using BigBangNet

Last updated 1 year ago