Skip to content

Instantly share code, notes, and snippets.

View tranvictor's full-sized avatar

Victor Tran tranvictor

View GitHub Profile
2018/12/05 11:31:36.186382 reserve_core.go:380: old nonce: <nil>, init price: <nil>, count: 0, err:
2018/12/05 11:31:36.441203 reserve_core.go:409: initial set rate tx, init price: 7000000000
2018/12/05 11:31:40.598151 reserve_core.go:467: Core ----------> Set rates: ==> Result: tx: 0x81348b8ebaa39a27dff9f7bf3c52d8043f6dac785580bac38a6386ed4665edbf, nonce: 230340, price: 7000000000, error: , storing error:
2018/12/05 11:32:46.193758 reserve_core.go:380: old nonce: <nil>, init price: <nil>, count: 0, err:
2018/12/05 11:32:46.450731 reserve_core.go:409: initial set rate tx, init price: 6500000000
2018/12/05 11:32:48.780508 reserve_core.go:467: Core ----------> Set rates: ==> Result: tx: 0x43203d27b244f81c99e587c215f876a1907663935f2d63feeadd50c9329b5dea, nonce: 230341, price: 6500000000, error: , storing error:
2018/12/05 11:33:56.458542 reserve_core.go:380: old nonce: 230341, init price: 6500000000, count: 1, err:
2018/12/05 11:34:02.415530 reserve_core.go:394: Trying to replace old tx with new price: 128763720
@tranvictor
tranvictor / gist:526f791408002a1ba1e65f3758337b2b
Last active November 26, 2018 12:59
Proposed workflow for kotocrypto to use kyber protocol to enable erc20 support

First scenario: A user wants to buy ERC20 (the one that kyber supports) using fiat

  1. Tokocrypto keeps monitoring ETH-ERC20 rate on Kyber using either Kyber's trading APIs or reading it directly on Ethereum blockchain, Kyber provides the rates here.
  2. Tokocrypto displays the rate in the way you want (rate to fiat calculation and fee calculation can be done here)
  3. The user submits an order to buy ERC20 using fiat according to the rate Tokocrypto shows, lets say the rate is R (mean he needs to spend R amount of fiat A in order to buy 1 token B)
  4. Up to now, his order is pending
  5. Tokocrypto do balance lockup (for example deduct fiat balance, increase locked balance of token B...)
  6. **Tokocrypto do a transaction to Kyber's smart contract in order to convert necessary amount of eth to token B (at this step, there are several things you can do like specifying which address you will receive the tokens, which rate you want to proceed and will you still want to proceed if the rate goes down but lets discu
Contract Addresses
KyberNetworkProxy
0x818E6FECD516Ecc3849DAf6845e3EC868087B755
KyberNetwork
0x91a502C678605fbCe581eae053319747482276b9
KyberReserve
0xEB52Ce516a8d054A574905BDc3D4a176D3a2d51a
KyberNetworkProxyContract.trade(
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', //ETH
srcAmount, // uint srcAmount
'0xaD6D458402F60fD3Bd25163575031ACDce07538D', //DAI for Rospten
web3.eth.accounts[0], // send to MetaMask owner account
maxDestAmount, //uint maxDestAmount
minConversionRate, //uint minConversionRate
0, //uint walletId
{ value: srcAmount },
function(error, result)

KyberWidget for Etheremon

KyberWidget for Etheremon allow users to pay for catchable monsters from any of tokens supported by Kyber.

Demo

A simple demo is available at https://widget.knstats.com/shop/. If you specify https://kyberpay-sample.knstats.com/callback as callback URL, you could go to https://kyberpay-sample.knstats.com/list to see postback transaction list.

How to use the widget

Include widget's CSS and javascript

KyberWidget

Payment button (widget) to allow users to pay for goods from tokens supported by Kyber, yet the merchants/ vendors can accept in whichever token they prefer.

What does it do

The widget provides a friendly and convenient user interface for users to use ERC20 tokens to pay to an ETH address. Users can use different wallets of choice (for example, keystore, trezor, ledger, private key and metamask) to sign the transaction and make the payment, the widget will broadcast the transaction to the Ethereum network automatically and notify the app (vendors) about the transaction.

How to use the widget

All you have to do is to place a button with proper url to your website.

Eg.

KyberWidget

Payment button (widget) to allow users to pay for goods from tokens supported by Kyber, yet the merchants/ vendors can accept in whichever token they prefer.

What does it do

The widget provides a friendly and convenient user interface for users to use ERC20 tokens to pay to an ETH address. Users can use different wallets of choice (for example, keystore, trezor, ledger, private key and metamask) to sign the transaction and make the payment, the widget will broadcast the transaction to the Ethereum network automatically and notify the app (vendors) about the transaction.

How to use the widget

All you have to do is to place a button with proper url to your website.

Eg.

# KyberWidget
Payment button (widget) to allow users to pay for goods from tokens supported by Kyber, yet the merchants/ vendors can accept in whichever token they prefer.
## What does it do
The widget provides a friendly and convenient user interface for users to use ERC20 tokens to pay to an ETH address. Users can use different wallets of choice (for example, keystore, trezor, ledger, private key and metamask) to sign the transaction and make the payment, the widget will broadcast the transaction to the Ethereum network automatically and notify the app (vendors) about the transaction.
## How to use the widget
All you have to do is to place a button with proper url to your website.
Eg.
kr:
dictionary:
name: &name 이름
email: &email 이메일
password: &password 비밀번호
submit: &submit 제출
kyber_swap: &kyber_swap KyberSwap
kyber_go: &kyber_go KyberGO
subscribe: &subscribe 구독하기
subscribe_news: 뉴스레터 구독하기
def callUpdateToKyberAPI(email, addresses, timestamps)
key = Rails.application.secrets.kyber_key
nonce = (Time.now.to_f * 1000).to_i
msg = URI.encode_www_form(
[[:addresses, addresses], [:nonce, nonce], [:timestamps, timestamps], [:user, email]])
uri = URI.parse("https://mainnet-data.kyber.network/update-user-addresses")
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(
uri.path, initheader = {