Skip to content

Instantly share code, notes, and snippets.

api.post('/:token_id/call', async (req, res, next) => {
const query = await Token.findOne({
token_id: req.params.token_id,
}).exec();
if(_.isNull(query))
return res.status(500).json({
code: 1,
message: 'The token id does not exist.'
});
api.post('/swapper/:address', async (req, res, next) => {
const abiPath = path.join(__dirname, '..', '..', 'contracts', 'HanwhaTokenSwapper.json');
const abi = JSON.parse(fs.readFileSync(abiPath).toString()).abi;
const contract = new web3.eth.Contract(abi, req.params.address);
const from = process.env.OPERATOR_ADDRESS;
let nonce;
try {
nonce = await web3.eth.getTransactionCount(from);
} catch (err) {
return res.status(400).json({
import { Router } from 'express';
import keythereum from 'keythereum';
import ethUtil from 'ethereumjs-util';
export default () => {
const api = Router();
api.post('/pk/to', async (req, res, next) => {
const datadir = process.env.DATADIR_LOCAL;
OPERATOR_ADDRESS="0x8562f445c9df1a80d7034593be5e5a6b9f8ce9d3"
OPERATOR_PRIVATE_KEY="74549f6407a2f3548dd2fcbffa55adc3e0c386dcda291dc830d6a82fcc17218b"
import { Router } from 'express';
import path from 'path';
import fs from 'fs';
import _ from 'lodash';
import Token from '../../models/token';
import Tx from 'ethereumjs-tx';
require('dotenv').config();
export default () => {

Ethereum Milestones

Ethereum은 Bitcoin의 한계점에 대한 불만으로 시작되었다. Bitcoin은 금융 산업을 분산화된 방식으로 대체하기 위해 나온 프로토콜이다. 비탈릭은 blockchain 사용에 대한 잠재성을 확인하고 bitcoin을 scrip langauge가 아닌 blockchain 위에 애플리케이션을 개발할 수 있도록 하는 제안을 했지만 거절되었다. 2013년에 그는 블록체인 위에 애플리케이션을 올릴 수 있는 플랫폼을 새로 제안하게 된다. 이러한 제안은 백서로 2013년 11월에 공개된다.

Public Announcement

2014년 1월 Ethereum platform 개발이 시작됨을 알린다. 초기 개발 멤버는 Vitalik Buterin, Mihai Alisie, Anthony Di Iorio 그리고 Charles Hoskinson로 구성되었다.

Ethereum Foundation

pragma solidity ^0.4.24;
contract Storage {
uint256 n;
function setN(uint256 _n) public {
n = _n;
}
function getN() public view returns(uint256) {
web3.eth.accounts
const owner = web3.eth.accounts[0]
owner
moment = require('moment')
const expireDates = [moment().add(100, 'minutes').unix(), moment().add(200, 'minutes').unix(),]
let token1, token2
HanwhaToken.new('HanwhaToken1', 'HWT1', '18', expireDates, {from: owner}).then(instance => token1 = instance)
HanwhaToken.new('HanwhaToken2', 'HWT2', '18', expireDates, {from: owner}).then(instance => token2 = instance)

Infura

Infura is a hosted Ethereum node cluster that lets your users run your application without requiring them to set up their own Ethereum node or wallet. Infura behaves just like a local install of Ethereum running RPC.

For security reasons, Infura does not manage your private keys, which means infura cannot sign transactions on your behalf.

However, Truffle can sign transactions through the use of its HDWalletProvider. This provider can handle the transaction signing as well as the connection to the Ethereum network.

Install HDWalletProvider:

Hex Prefix encoding

What are the differences between RLP and HP encoding? How does HP encoding work?

Root: {1: 'Dog', 2: B, 3: A}
A: {1: C, 2: D, 3: 'Cat'}
B: {1: 'Goat', 2: 'Bear', 3: 'Rat'}
C: {1: 'Eagle', 2: 'Parrot', 3: E}
D: {1: 'Shark', 2: 'Dolphin', 3: 'Whale'}
E: {1: 'Duck', 2: 'Chicken', 3: 'Pig'}