custom_contracts

command
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 12 Imported by: 0

README

Custom Contracts Example

This directory contains examples of custom contracts using a simplified interface.

Directory Structure

custom_contracts/
├── core/               # Contract interface definitions
│   └── contract.go     # Core contract interface
└── contract/           # Example contracts
    └── counter.go      # Counter contract example

Simplified Interface

The contract interface provides a set of package-level functions for basic contract operations:

// Storage operations
Get(key string, value interface{}) error
Set(key string, value interface{}) error
Delete(key string) error

// Utility functions
Log(event string, args ...interface{})
Sender() string
ContractAddress() string

Example: Counter Contract

A simple counter contract that demonstrates the use of the interface:

// Initialize the counter
Initialize(initialValue int64) error

// Increment the counter
Increment() error

// Decrement the counter
Decrement() error

// Get current value
GetValue() (int64, error)

// Reset counter to 0
Reset() error

Notes

  • The interface is designed to be simple and focused on essential operations
  • Storage operations use string keys and interface{} values for flexibility
  • Logging and address functions are provided for convenience

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL