Socket
Book a DemoInstallSign in
Socket

email-to-ethereum-address

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-to-ethereum-address

Email to Ethereum address directory.

1.3.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Email to Ethereum Address

An email to Ethereum address directory Web3 library. This library is a Web3js wrapper which manages interactions with an Ethereum smart contract application.

Note: This library currently runs on the Ethereum ROPSTEN (Revival) TESTNET and is intended for demonstration purposes only. This library requires a Web3 compatible client.

Workflow Diagram

Install

npm install email-to-ethereum-address

Build (from source)

npm install

// Bundle for web browser use.
// Outputs to dist/EmailToEthereumAddress.web.js
npm run build

Usage

Node (ES6)

const EmailToEthereumAddress = require('email-to-ethereum-address');
const Web3 = require("web3");

// The address transactions should be sent from.
const FROM_ACCOUNT = "0x0000000000000000000000000000000000000000";

// Initialize your web3 provider.
const web3 = new Web3.providers.HttpProvider("http://localhost:8545");

// Initialize the EmailToEthereumAddress library.
// Pass your web3 provider and account.
const emailToEthereumAddress = new EmailToEthereumAddress(web3, FROM_ACCOUNT);

// Request a new registration.
// On a successful request, a verification email will be sent to the provided email address.
emailToEthereumAddress.requestAddRecord("email@example.com").then(receipt => {
    console.log("TransactionHash: " + receipt.transactionHash);
});

// Lookup address from email.
emailToEthereumAddress.getAccount("email@example.com").then(address => {
    console.log("Address: " + address);
});

Web

<html>
<head>
    <script src="dist/EmailToEthereumAddress.web.js"></script>
</head>
</html>
<body>
<script>
    window.onload = function () {

        // Verify the browser has web3 injected.
        if (typeof web3 !== 'undefined') {

            // Lookup Etheruem accounts.
            web3.eth.getAccounts(function (err, accounts) {
                if (accounts.length > 0) {

                    // Grab account you wish to use.
                    var myAccount = accounts[0];

                    // Initial the EmailToEthereumAddress library.
                    // Pass your web3 provider and account.
                    var emailToEthereumAddress = new EmailToEthereumAddress(web3.currentProvider, myAccount);

                    // Request a new registration.
                    // On a successful request, a verification email will be sent to the provided email address.
                    emailToEthereumAddress.requestAddRecord("email@example.com", function (error, transactionHash) {
                        console.log("TransactionHash: " + transactionHash);
                    });

                    // Lookup address from email.
                    emailToEthereumAddress.getAccount("email@example.com", function (address) {
                        console.log(address);
                    });
                }
            });
        }
    };
</script>
</body>

Samples

See the samples folder for both node.js and web examples.

Node

Before running these samples, please modify your email and Ethereum addresses within the scripts.

# Get account
node samples/node/get_account.js

# Request Add Record
node samples/node/request_add_record.js

Web

Before running these samples, please modify your email address in the HTML file.

Open the HTML file in a web3 compatible browser.

  • samples/web/get_account.html
  • samples/web/request_add_record.html

Live Demo

Please visit here.

FAQs

Package last updated on 08 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.