Satz
  • 👋Welcome
  • 🤝Introduction
    • What is SatsChain?
    • How is SatsChain different from L2s?
    • What is the security paradigm for SatsChain?
  • 📇Use Cases
    • Cerebrum (Retail use cases)
    • Institutional use cases
    • Anchoring L2s on BTC
  • 🖥️For Developers
  • 📝Smart Contracts
    • What is smart contract?
    • Build a Contract
    • Leverage Compass Library for contracts
    • What type of contracts can be supported?
  • 🔐Contract Deployment
    • Deploy smart contract on SatsChain
  • ⛓️Core Principles
    • What are Inscriptions?
    • Taproot/native-segwit user addresses
    • What is EVM?
    • What is Solidity?
    • How BTC connects with EVM?
  • 🛠️Sats Infrastructure
    • Leveraging OP_RETURN
    • Sats Intel
    • Sats Nuclei
    • Sats Reverse Processor (SRP)
    • Sats connector
    • Compass (EVM <> BTC)
      • Compass Solidity Library
      • Compass Logic
      • Rainbow table
  • ⚙️Configurations
    • Testnet
    • Mainnet
  • 📚Developer Guide
    • Deploy contract
    • Anchoring of L2s
    • How to interact with Smart Contract?
    • Fetching current state via JSON RPC integration
    • How to integrate compass library in solidity code
  • Website
  • WhitePaper
  • Twitter
Powered by GitBook
On this page
  1. Developer Guide

How to interact with Smart Contract?

PreviousAnchoring of L2sNextFetching current state via JSON RPC integration

Last updated 11 months ago

Interacting with smart contracts on Satschain involves using decentralized applications (DApps) and the Satschain explorer. This detailed guide will walk you through the process step-by-step, from connecting your wallet to monitoring your transactions.

Prerequisites

Before you begin interacting with smart contracts on Satschain, ensure you have the following:

  • A compatible wallet (e.g., Unisat) installed and set up.

  • Some Satschain tokens in your wallet to cover transaction fees, if you are not using 0 Gas Price.

  • Access to the Satschain explorer and DApp interfaces over the internet.

Step 1: Connecting Your Wallet

To interact with smart contracts on Satschain, you need to connect your wallet to the Satschain explorer. Follow these steps:

  1. Install a Compatible Wallet: Ensure you have a wallet that supports Satschain. Unisat is a popular choice that integrates well with Satschain.

  2. Set Up Your Wallet: If you haven't already, create a new wallet or import an existing one using your seed phrase or private key. Ensure you securely store your seed phrase or private key.

  3. Connect to Satschain: At the moment Satschain operates on testnet, so be sure to set the network appropriately.

  4. Select Satschain Network: Switch your wallet to the Satschain network. Your wallet is now ready to interact with smart contracts on Satschain.

Step 2: Accessing the Smart Contract Interface

Once your wallet is connected to Satschain, you can access the smart contract interface through the Satschain explorer. Here's how:

  1. Navigate to the Explorer: Open your browser and go to the Satschain explorer at https://explorer.Satschain.xyz/.

  2. Search for the Smart Contract: Use the search bar to enter the contract address or name. This will bring up the contract's details page.

  3. Contract Details Page: The contract details page provides information about the contract, including its address, creator, creation date, and a list of transactions associated with it. Here, you can also see the contract's ABI (Application Binary Interface), which defines how to interact with it.

Step 3: Interacting with the Contract

Interacting with a smart contract involves calling its functions. These functions can be categorized into two types: read functions and write functions.

Read Functions

Read functions are used to retrieve data from the blockchain. These functions do not change the state of the blockchain and therefore do not require gas fees. To call a read function:

  1. Locate the Read Functions: On the contract details page, find the section for read functions.

  2. Call the Function: Select the function you want to call. If the function requires input parameters, enter them in the provided fields.

  3. Execute the Function: Click the "Read" button. The data returned by the function will be displayed on the screen.

Write Functions

Write functions change the state of the blockchain and require gas fees. To call a write function:

  1. Locate the Write Functions: On the contract details page, find the section for write functions.

  2. Input Parameters: Select the function you want to call and enter the required parameters.

  3. Confirm the Transaction: Click the "Write" button. Your wallet will prompt you to confirm the transaction and pay the associated gas fees.

  4. Transaction Confirmation: Once you confirm the transaction, it will be sent to the Satschain network for processing. You can monitor its status through your wallet or the explorer.

Step 4: Monitoring Transactions

After interacting with a smart contract, it's essential to monitor your transactions to ensure they are successfully processed. The Satschain explorer provides tools to track transaction status and view detailed logs.

Viewing Transactions

  1. Transaction List: On the contract details page, there is a list of recent transactions. This list includes transaction hashes, timestamps, and statuses.

  2. Transaction Details: Click on a transaction hash to view its details. This page provides information such as the block number, gas used, and status (pending, confirmed, or failed).

Event Logs

Smart contracts often emit events to log significant actions. These events can be useful for debugging and tracking contract activity.

  1. Locate Event Logs: On the transaction details page, there is a section for event logs.

  2. Event Details: Each event log includes the event name, parameters, and the transaction hash that triggered the event. Review these logs to understand the contract's behavior during the transaction.

Interacting with smart contracts on Satschain is a straightforward process once you understand the basics. By following the steps outlined in this guide, you can confidently connect your wallet, access the smart contract interface, interact with read and write functions, and monitor your transactions.

📚