erc1820

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: Apache-2.0 Imports: 9 Imported by: 3

README

go-erc1820

Tag License GoDoc Travis CI codecov.io

Go module to simplify talking to the ERC-1820 registry contract.

Table of Contents

Install

go-erc1820 is a standard Go module which can be installed with:

go get github.com/wealdtech/go-erc1820

Usage

go-erc1820 provides simple access to the ERC-1820 registry contract.

Example
package main

import (
    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
	erc1820 "github.com/wealdtech/go-erc1820"
)

func main() {
    client, err := ethclient.Dial("https://infura.io/v3/SECRET")
    if err != nil {
        panic(err)
    }

    registry, err := erc1820.New(client)
    if err != nil {
        panic(err)
    }

    // Fetch the implementer for an interface
    implementer, err := registry.InterfaceImplementer("ERC777TokensRecipient", common.HexToAddress("907b4EB76F423595408C49c0BbB2bb117C91c594"))
    if err != nil {
        panic(err)
    }
    fmt.Printf("Implementer is %s\n", implementer.Hex())
}

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0 © 2019 Weald Technology Trading Ltd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Implementer

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

Implementer is the struct that holds information about an ERC-1820 interface implementer

func NewImplementer

func NewImplementer(backend bind.ContractBackend, address *common.Address) (*Implementer, error)

NewImplementer creates a new ERC-1820 registry implementer client

func (*Implementer) ImplementsInterface

func (i *Implementer) ImplementsInterface(iface string, address *common.Address) (bool, error)

ImplementsInterface returns true if the address implements the given interface for the given address

type Registry

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

Registry is the struct that holds information about the ERC-1820 registry

func NewRegistry

func NewRegistry(backend bind.ContractBackend) (*Registry, error)

NewRegistry creates a new ERC-1820 registry client

func (*Registry) InterfaceImplementer

func (r *Registry) InterfaceImplementer(iface string, address *common.Address) (*common.Address, error)

InterfaceImplementer returns the address of the implementer of the given interface for the given address

func (*Registry) Manager

func (r *Registry) Manager(address *common.Address) (*common.Address, error)

Manager returns the manager of the given address

func (*Registry) SetInterfaceImplementer

func (r *Registry) SetInterfaceImplementer(opts *bind.TransactOpts, iface string, address *common.Address, implementer *common.Address) (*types.Transaction, error)

SetInterfaceImplementer sets the address of the implementer of the given interface for the given address

func (*Registry) SetManager

func (r *Registry) SetManager(opts *bind.TransactOpts, address *common.Address, manager *common.Address) (*types.Transaction, error)

SetManager sets the manager of the given address

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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