ConsenSys/addresstoip

Name: addresstoip

Owner: ConsenSys

Description: Ethereum contracts for mapping Ethereum addresses to IP addresses

Created: 2015-12-07 06:37:42.0

Updated: 2016-12-03 01:53:16.0

Pushed: 2016-01-30 01:21:11.0

Homepage: null

Size: 19

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

About

The AddressToIP contracts are a pair of Ethereum contracts that map Ethereum addresses to IP addresses. The transaction sender can set and delete his, and only his, IP address entry. The data is public, so that anyone can obtain an IP for an Ethereum address (assuming the mapping exists).

The IPv4 contract is at address 0xd21e907c322c69a9932135eeb1d52fe5b661179a .

The IPv6 contract is at address 0x93a2863108236d86b3b02f851e0620af16d59568 .

Features
API and gas estimate
AddressToIPv4

get_ip(address addr) returns (uint32) (no gas)

set_ip(uint32 ip) (20,318 gas)

delete_ip() (20,295 gas)

AddressToIPv6

get_ip(address addr) returns (uint128) (no gas)

set_ip(uint128 ip) (20,362 gas)

delete_ip() (20,273 gas)

Source code
ract AddressToIPv4 {

mapping (address => uint32) ips;

function AddressToIPv4() {
}

function set_ip(uint32 ip) {
    ips[msg.sender] = ip;
}

function delete_ip() {
    delete ips[msg.sender];
}

function get_ip(address addr) returns (uint32) {
    return ips[addr];
}


ract AddressToIPv6 {

mapping (address => uint128) ips;

function AddressToIPv6() {
}

function set_ip(uint128 ip) {
    ips[msg.sender] = ip;
}

function delete_ip() {
    delete ips[msg.sender];
}

function get_ip(address addr) returns (uint128) {
    return ips[addr];
}

Compiler version

0.1.6-0/Release-Linux/g++/int linked to libethereum-0.9.93-0/Release-Linux/g++/int

See also

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.