1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ETHのアカウントを作る

Last updated at Posted at 2019-05-06

概要

Ethreumのアカウントをweb3.jsを使って作成します

作り方

mkdir create-eth-account
cd create-eth-account
touch create.js

次にweb3をインストールします

npm i --save web3

あとはcreate.jsファイルを以下のように編集します

create.js

const Web3 = require('web3');

const networks  = {
    main: 'wss://mainnet.infura.io/ws/v3/',
    ropsten: 'wss://ropsten.infura.io/ws/v3/',
    kovan: 'wss://kovan.infura.io/ws/v3/',
    rinkeby: 'wss://rinkeby.infura.io/ws/v3/'
};

//InfuraのAPI-KEY
const apiKey = 'YOUR-API-KEY';

//ここではどのネットワークでも良い
const network = networks.rinkeby;

const getWeb3 = () => {
    const provider = network + apiKey;
    const web3 = new Web3(provider);
    return web3;
}

const createAccount = async() => {
    const web3 = getWeb3();
    const account = web3.eth.accounts.create();
    console.log(account);
}

createAccount();

あとは以下を実行すればアカウントが作れます

node create.js

こんな感じで表示されます

スクリーンショット 2019-05-06 13.54.27.png
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?