callbacks

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

Callbacks Interface

Description

The Callbacks interface defines a standard for smart contracts to receive notifications about IBC packet lifecycle events. This is not a precompile with a fixed address, but rather an interface specification that contracts must implement to receive callbacks from the IBC module.

Interface

Methods
onPacketAcknowledgement
function onPacketAcknowledgement(
    string memory channelId,
    string memory portId,
    uint64 sequence,
    bytes memory data,
    bytes memory acknowledgement
) external

Called when an IBC packet sent by the implementing contract receives an acknowledgement from the destination chain.

Parameters:

  • channelId: The IBC channel identifier
  • portId: The IBC port identifier
  • sequence: The packet sequence number
  • data: The original packet data
  • acknowledgement: The acknowledgement data from the destination chain

Invocation:

  • Only called by the IBC module
  • Only invoked for packets sent by the implementing contract
  • Called after successful packet delivery and acknowledgement
onPacketTimeout
function onPacketTimeout(
    string memory channelId,
    string memory portId,
    uint64 sequence,
    bytes memory data
) external

Called when an IBC packet sent by the implementing contract times out without being processed by the destination chain.

Parameters:

  • channelId: The IBC channel identifier
  • portId: The IBC port identifier
  • sequence: The packet sequence number
  • data: The original packet data

Invocation:

  • Only called by the IBC module
  • Only invoked for packets sent by the implementing contract
  • Called when packet timeout conditions are met

Implementation Requirements

Access Control

Implementing contracts must ensure that only the IBC module can invoke these callback methods. This prevents unauthorized contracts from triggering callback logic.

State Management

Contracts should maintain appropriate state to correlate callbacks with their original packet sends, typically using the sequence number as a unique identifier.

Error Handling

Callback implementations should handle errors gracefully as failures in callback execution may affect the IBC packet lifecycle.

Gas Considerations

Callback execution consumes gas on the source chain. Implementations should be gas-efficient to avoid transaction failures due to out-of-gas errors.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrecompileABI = PrecompileMetaData.ABI

PrecompileABI is the input ABI used to generate the binding from. Deprecated: Use PrecompileMetaData.ABI instead.

View Source
var PrecompileMetaData = &bind.MetaData{
	ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"portId\",\"type\":\"string\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"acknowledgement\",\"type\":\"bytes\"}],\"name\":\"onPacketAcknowledgement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"portId\",\"type\":\"string\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"onPacketTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
}

PrecompileMetaData contains all meta data concerning the Precompile contract.

Functions

func LoadABI

func LoadABI() (*abi.ABI, error)

Types

type Precompile

type Precompile struct {
	PrecompileCaller     // Read-only binding to the contract
	PrecompileTransactor // Write-only binding to the contract
	PrecompileFilterer   // Log filterer for contract events
}

Precompile is an auto generated Go binding around an Ethereum contract.

func NewPrecompile

func NewPrecompile(address common.Address, backend bind.ContractBackend) (*Precompile, error)

NewPrecompile creates a new instance of Precompile, bound to a specific deployed contract.

type PrecompileCaller

type PrecompileCaller struct {
	// contains filtered or unexported fields
}

PrecompileCaller is an auto generated read-only Go binding around an Ethereum contract.

func NewPrecompileCaller

func NewPrecompileCaller(address common.Address, caller bind.ContractCaller) (*PrecompileCaller, error)

NewPrecompileCaller creates a new read-only instance of Precompile, bound to a specific deployed contract.

type PrecompileCallerRaw

type PrecompileCallerRaw struct {
	Contract *PrecompileCaller // Generic read-only contract binding to access the raw methods on
}

PrecompileCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.

func (*PrecompileCallerRaw) Call

func (_Precompile *PrecompileCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error

Call invokes the (constant) contract method with params as input values and sets the output to result. The result type might be a single field for simple returns, a slice of interfaces for anonymous returns and a struct for named returns.

type PrecompileCallerSession

type PrecompileCallerSession struct {
	Contract *PrecompileCaller // Generic contract caller binding to set the session for
	CallOpts bind.CallOpts     // Call options to use throughout this session
}

PrecompileCallerSession is an auto generated read-only Go binding around an Ethereum contract, with pre-set call options.

type PrecompileFilterer

type PrecompileFilterer struct {
	// contains filtered or unexported fields
}

PrecompileFilterer is an auto generated log filtering Go binding around an Ethereum contract events.

func NewPrecompileFilterer

func NewPrecompileFilterer(address common.Address, filterer bind.ContractFilterer) (*PrecompileFilterer, error)

NewPrecompileFilterer creates a new log filterer instance of Precompile, bound to a specific deployed contract.

type PrecompileRaw

type PrecompileRaw struct {
	Contract *Precompile // Generic contract binding to access the raw methods on
}

PrecompileRaw is an auto generated low-level Go binding around an Ethereum contract.

func (*PrecompileRaw) Call

func (_Precompile *PrecompileRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error

Call invokes the (constant) contract method with params as input values and sets the output to result. The result type might be a single field for simple returns, a slice of interfaces for anonymous returns and a struct for named returns.

func (*PrecompileRaw) Transact

func (_Precompile *PrecompileRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*PrecompileRaw) Transfer

func (_Precompile *PrecompileRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type PrecompileSession

type PrecompileSession struct {
	Contract     *Precompile       // Generic contract binding to set the session for
	CallOpts     bind.CallOpts     // Call options to use throughout this session
	TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}

PrecompileSession is an auto generated Go binding around an Ethereum contract, with pre-set call and transact options.

func (*PrecompileSession) OnPacketAcknowledgement

func (_Precompile *PrecompileSession) OnPacketAcknowledgement(channelId string, portId string, sequence uint64, data []byte, acknowledgement []byte) (*types.Transaction, error)

OnPacketAcknowledgement is a paid mutator transaction binding the contract method 0x39b4073a.

Solidity: function onPacketAcknowledgement(string channelId, string portId, uint64 sequence, bytes data, bytes acknowledgement) returns()

func (*PrecompileSession) OnPacketTimeout

func (_Precompile *PrecompileSession) OnPacketTimeout(channelId string, portId string, sequence uint64, data []byte) (*types.Transaction, error)

OnPacketTimeout is a paid mutator transaction binding the contract method 0x1f8ee603.

Solidity: function onPacketTimeout(string channelId, string portId, uint64 sequence, bytes data) returns()

type PrecompileTransactor

type PrecompileTransactor struct {
	// contains filtered or unexported fields
}

PrecompileTransactor is an auto generated write-only Go binding around an Ethereum contract.

func NewPrecompileTransactor

func NewPrecompileTransactor(address common.Address, transactor bind.ContractTransactor) (*PrecompileTransactor, error)

NewPrecompileTransactor creates a new write-only instance of Precompile, bound to a specific deployed contract.

func (*PrecompileTransactor) OnPacketAcknowledgement

func (_Precompile *PrecompileTransactor) OnPacketAcknowledgement(opts *bind.TransactOpts, channelId string, portId string, sequence uint64, data []byte, acknowledgement []byte) (*types.Transaction, error)

OnPacketAcknowledgement is a paid mutator transaction binding the contract method 0x39b4073a.

Solidity: function onPacketAcknowledgement(string channelId, string portId, uint64 sequence, bytes data, bytes acknowledgement) returns()

func (*PrecompileTransactor) OnPacketTimeout

func (_Precompile *PrecompileTransactor) OnPacketTimeout(opts *bind.TransactOpts, channelId string, portId string, sequence uint64, data []byte) (*types.Transaction, error)

OnPacketTimeout is a paid mutator transaction binding the contract method 0x1f8ee603.

Solidity: function onPacketTimeout(string channelId, string portId, uint64 sequence, bytes data) returns()

type PrecompileTransactorRaw

type PrecompileTransactorRaw struct {
	Contract *PrecompileTransactor // Generic write-only contract binding to access the raw methods on
}

PrecompileTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.

func (*PrecompileTransactorRaw) Transact

func (_Precompile *PrecompileTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact invokes the (paid) contract method with params as input values.

func (*PrecompileTransactorRaw) Transfer

func (_Precompile *PrecompileTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error)

Transfer initiates a plain transaction to move funds to the contract, calling its default method if one is available.

type PrecompileTransactorSession

type PrecompileTransactorSession struct {
	Contract     *PrecompileTransactor // Generic contract transactor binding to set the session for
	TransactOpts bind.TransactOpts     // Transaction auth options to use throughout this session
}

PrecompileTransactorSession is an auto generated write-only Go binding around an Ethereum contract, with pre-set transact options.

func (*PrecompileTransactorSession) OnPacketAcknowledgement

func (_Precompile *PrecompileTransactorSession) OnPacketAcknowledgement(channelId string, portId string, sequence uint64, data []byte, acknowledgement []byte) (*types.Transaction, error)

OnPacketAcknowledgement is a paid mutator transaction binding the contract method 0x39b4073a.

Solidity: function onPacketAcknowledgement(string channelId, string portId, uint64 sequence, bytes data, bytes acknowledgement) returns()

func (*PrecompileTransactorSession) OnPacketTimeout

func (_Precompile *PrecompileTransactorSession) OnPacketTimeout(channelId string, portId string, sequence uint64, data []byte) (*types.Transaction, error)

OnPacketTimeout is a paid mutator transaction binding the contract method 0x1f8ee603.

Solidity: function onPacketTimeout(string channelId, string portId, uint64 sequence, bytes data) returns()

Jump to

Keyboard shortcuts

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