LoginSignup
2
0

More than 5 years have passed since last update.

Web3.jsでUTF8文字列と16進数データの相互変換

Last updated at Posted at 2018-05-16
  • Web3.js 1.0.0 を使用した例です。

Web3.js のインストール

 $ npm install web3 --save

サンプルコード

let Web3 = require('Web3');

console.log(Web3.version);
// => 1.0.0-beta.34

// UTF8String to HexData
let data = Web3.utils.utf8ToHex('piyo');
console.log(data);
// => 0x7069796f

// HexData to UTF8String
let string = Web3.utils.hexToUtf8(data);
console.log(string);
// => piyo

Note

2
0
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
2
0