This package is a work in progress. Breaking changes are likely to be made.
- Create
submitBid()
method to combineshaBid()
andnewBid()
shaBid()
andnewBid()
don't need to be exposed once that's done.
- Add fast forwarding on TestRPC
- Add more tests for getEntry to check bid and reveal status within the auction period
- Setup linting for the AirBnB js style guide
- Create
openAuction()
which would automatically runstartAuctions()
with 9 random dummy bids alongside the one you actually wanted. - Create a bid object constructor to simplify bid management, the bid object contains at least
- name, hash, bid value, owner address, secret, and date submitted. Possibly also:
- reveal period start time, registration date.
- Possibly connect
submitBid()
toopenAuction()
, and run if the auction is not already open before submitting. - Create a deed object constructor. The deed object contains all properties of a Deed contract, as well as the unhashed name (if known).
- Anticipate and return errors for any inputs that would cause the contract to throw.
Constructs a new Registrar instance, providing an easy-to-use interface to the
Initial Registrar, which governs the .eth
namespace. Either Registrar.init(),
or registrar.initDefault() must be called
Example usage:
var Registrar = require('eth-registrar-ens');
var Web3 = require('web3');
var web3 = new Web3();
var registrar = new Registrar(web3)
// On Ropsten with the public ENS registry
registrar.init();
console.log(registrar.ens.registry.address); // '0x112234455c3a32fd11230c42e7bccd4a84e02010'
console.log(registrar.rootNode); // '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae'
var name = 'foobarbaz';
registrar.startAuction(name);
var owner = web3.eth.accounts[0]
var value = web3.toWei(1, 'ether');
// generate a sealed bid
var bid = registrar.shaBid(name, owner, value, 'secret');
// submit a bid, and a deposit value. The parameters of your true bid are secret.
var deposit = web3.toWei(2, 'ether');
registrar.newBid(bid, {value: deposit});
// reveal your bid during the reveal period
registrar.unsealBid(name, owner, value, 'secret');
// After the registration date has passed, assign ownership of the name
// in the ENS. In this case, the highest bidder would now own 'foobarbaz.eth'
registrar.finalizeAuction(name);
Throughout this module, the same optionally-asynchronous pattern as web3 is used: all functions that call web3 take a callback as an optional last argument; if supplied, the function returns nothing, but instead calls the callback with (err, result) when the operation completes.
Functions that create transactions also take an optional 'options' argument; this has the same parameters as web3.
Parameters
web3
object A web3 instance to use to communicate with the blockchain.address
address The address of the registrar.min_length
integer The minimum length of a name require by the registrar.tld
string The top level domainens
string The address of the ENS instance
Meta
- author: J Maurelian
- license: LGPL
Returns the properties of the entry for a given a name
Parameters
name
string The name to get the entry forcallback
function An optional callback; if specified, the function executes asynchronously.
Returns any An Entry object
Converts a name to a hash string, and opens an auction on that hash.
Parameters
name
string The name to start an auction onparams
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The txid if callback is not supplied.
Opens auctions for multiple names at once. Since names are registered as hashes, this helps to prevent other bidders from guessing which names you are interested in.
Parameters
names
array An array of names to start auctions onparams
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The txid if callback is not supplied.
Generates the "bid string" (hash) which representing a sealed bid. This does not submit the bid to the registrar, it only calls on the registrar's corresponding method.
ToDo: Make owner
default to sender if not specified.
Parameters
name
string The name to be bid onaddress
string An optional owner addressvalue
number The value of your bid in weisecret
secret An optional random valueowner
callback
Returns any the sealed bid hash string
Submits a bid string to the registrar, creating a new sealed bid entry. The value
Parameters
bid
stringparams
object A dict of parameters to pass to web3. An amount must be included.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Submits the parameters of a bid. The registrar will then generate the bid string, and associate them with the previously submitted bid string and deposit. If you have not already submitted a bid string, the registrar will throw. If your bid is revealed as the current highest; the difference between your deposit and bid value will be returned to you, and the previous highest bidder will have their funds returned. If you are not the highest bidder, all your funds will be returned. Returns are sent to the owner address on the bid.
Parameters
name
stringowner
address An optional owner address; defaults to sendervalue
number The value of your bidsecret
secret The secret used to create the bid stringoptions
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Not yet implemented After the registration date has passed, calling finalizeAuction will set the winner as the owner of the corresponding ENS subnode.
Parameters
name
stringoptions
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Not yet implemented The owner of a domain may transfer it, and the associated deed, to someone else at any time.
Parameters
name
string The node to transfernewOwner
string The address to transfer ownership tooptions
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Not yet implemented After one year, the owner can release the property and get their ether back
Parameters
name
string The name to releaseoptions
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Not yet implemented Submit a name 6 characters long or less. If it has been registered, the submitter will earn a portion of the deed value, and the name will be updated
Parameters
name
string An invalid name to search for in the registry.options
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Not yet implemented Transfers the deed to the current registrar, if different from this one. Used during the upgrade process to a permanent registrar.
Parameters
name
The name to transfer.options
object An optional transaction object to pass to web3.callback
function An optional callback; if specified, the function executes asynchronously.
Returns any The transaction ID if callback is not supplied.
Constructs a new Entry instance corresponding to a name.
Parameters