Skip to main content

Introduction to Interacting with Contracts

Interacting with contracts on OP_NET offers a seamless experience while leveraging innovative features like Unified Contract Addresses and Gas Optimization, all built on top of Bitcoin. This guide provides an overview of OP_NET's contract functionality, including how it compares to Ethereum and its gas system.


Unified Contract Addresses

OP_NET introduces Unified Contract Addresses, an approach that simplifies contract interactions by associating contracts with tweaked public keys. This system eliminates the complexity of managing multiple address formats, creating a streamlined developer experience.

Key Features
  • Tweaked Public Key: Contracts are tied to a tweaked public key, ensuring compatibility with Bitcoin's Taproot.
  • Unified Account System: Unified contract addresses are part of the OP_NET Unified Account system, which simplifies interactions across all address types.
tip

For more details, see How OP_NET Works: Unified Accounts.


Contract Functionality: Similar to Ethereum

OP_NET's contract functionality is inspired by Ethereum but tailored for the Bitcoin ecosystem. Key similarities and differences include:

Similarities

  • Function Calls: Contracts can define and expose functions, similar to Ethereum's smart contracts.
  • Event Logs: Contracts emit logs during execution, providing traceable interactions.
  • State Storage: Contracts can maintain persistent storage for data.

Differences

  • UTXO Model: OP_NET contracts operate on Bitcoin's UTXO model rather than Ethereum's account model.
  • Contract Deployment: Contracts are associated with Bitcoin transactions and a tweaked public key.

Gas System on OP_NET

The gas system on OP_NET ensures efficient transaction processing while balancing resource usage and network demand. It introduces the following key features:

1. Block Base Fee

  • Each block includes a base gas fee, dynamically adjusted based on network conditions.
  • Transactions pay for the gas they consume, which includes the base fee.

2. Gas Simulations

  • Providers automatically simulate transactions to estimate gas usage.
  • Simulations account for the current block's base fee, ensuring accurate gas calculations.
Important Note

The gas system on OP_NET is adaptive, and gas fees may change with each block. Always check the estimated gas before broadcasting a transaction.


What’s Next?

Now that you understand the basics, explore the following topics to dive deeper into contract interactions: