The Ethereum network recently introduced a global registrar object which is basicly a public smart contract on the chain.
Here is a snippet of an ethereum client command line output:
namereg: {
address: "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
AuctionEnded: function(),
Changed: function(),
NewBid: function(),
PrimaryChanged: function(),
Registrar: function(),
addr: function(),
allEvents: function(),
content: function(),
disown: function(),
name: function(),
owner: function(),
reserve: function(),
setAddress: function(),
setContent: function(),
setSubRegistrar: function(),
subRegistrar: function(),
transfer: function()
}
The namereg contract allows associating human-comprehensible names with human-incomprehensible data. One of the use cases is creating a global address book for Ethereum addresses. Using a namereg contract, one may send ether to "5chdn" instead of "0x<some hex value>". One may also register things like IPFS hashes, allowing one to use it as a decentralized DNS for a decentralized Web.
To test that, type in your geth console:
registrar = GlobalRegistrar.at('0xc6d9d2cd449a754c494264e1809c50e34d64562b');
To set up your own name and give it a test:
registrar.reserve.sendTransaction('thepiachu', {from: eth.accounts[0]});
registrar.setAddress.sendTransaction('thepiachu', eth.accounts[0], true, {from: eth.accounts[0]});
To test, see if you can resolve "thepiachu" to your ethereum address:
registrar.addr('thepiachu');
Now, whenever anyone want to send you some ether, you only need to do this:
eth.sendTransaction({from: eth.accounts[0], to: registrar.addr('thepiachu'), value: web3.toWei(1, 'ether'), gas: 21000});
You'll need to run the GlobalRegistrar.at()
line every time you start geth until this gets hard coded.
You can also replace the second parameter of .setAddress()
above with a contract's address to "call it by name".