ens

package
v1.8.22-0...-74acde4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

README

Swarm ENS interface

Usage

Full documentation for the Ethereum Name Service can be found as EIP 137. This package offers a simple binding that streamlines the registration of arbitrary UTF8 domain names to swarm content hashes.

Development

The SOL file in contract subdirectory implements the ENS root registry, a simple first-in, first-served registrar for the root namespace, and a simple resolver contract; they're used in tests, and can be used to deploy these contracts for your own purposes.

The solidity source code can be found at github.com/arachnid/ens/.

The go bindings for ENS contracts are generated using abigen via the go generator:

go generate ./contracts/ens

Fallback contract support

In order to better support content resolution on different service providers (such as Swarm and IPFS), EIP-1577 was introduced and with it changes that allow applications to know where content hashes are stored (i.e. if the requested hash resides on Swarm or IPFS).

The code under contracts/ens/contract reflects the new Public Resolver changes and the code under fallback_contract allows us to support the old contract resolution in cases where the ENS name owner did not update her Resolver contract, until the migration period ends (date arbitrarily set to June 1st, 2019).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MainNetAddress = common.HexToAddress("0x314159265dD8dbb310642f98f50C066173C1259b")
	TestNetAddress = common.HexToAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010")
)

Functions

func EncodeSwarmHash

func EncodeSwarmHash(hash common.Hash) ([]byte, error)

func EnsNode

func EnsNode(name string) common.Hash

Types

type ENS

type ENS struct {
	*contract.ENSSession
	// contains filtered or unexported fields
}

ENS is the swarm domain name registry and resolver

func DeployENS

func DeployENS(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *ENS, error)

DeployENS deploys an instance of the ENS nameservice, with a 'first-in, first-served' root registrar.

func NewENS

func NewENS(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*ENS, error)

NewENS creates a struct exposing convenient high-level operations for interacting with the Ethereum Name Service.

func (*ENS) Addr

func (ens *ENS) Addr(name string) (common.Address, error)

Addr is a non-transactional call that returns the address associated with a name.

func (*ENS) Register

func (ens *ENS) Register(name string) (*types.Transaction, error)

Register registers a new domain name for the caller, making them the owner of the new name. Only works if the registrar for the parent domain implements the FIFS registrar protocol.

func (*ENS) Resolve

func (ens *ENS) Resolve(name string) (common.Hash, error)

Resolve is a non-transactional call that returns the content hash associated with a name.

func (*ENS) SetAddr

func (ens *ENS) SetAddr(name string, addr common.Address) (*types.Transaction, error)

SetAddress sets the address associated with a name. Only works if the caller owns the name, and the associated resolver implements a `setAddress` function.

func (*ENS) SetContentHash

func (ens *ENS) SetContentHash(name string, hash []byte) (*types.Transaction, error)

SetContentHash sets the content hash associated with a name. Only works if the caller owns the name, and the associated resolver implements a `setContenthash` function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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