//go:build unittest
// +build unittest

package server

import (
	"net/http"
	"net/http/httptest"
	"testing"
	"time"

	"github.com/golang/glog"
	"github.com/linxGnu/grocksdb"
	"github.com/trezor/blockbook/bchain"
	"github.com/trezor/blockbook/bchain/coins/eth"
	"github.com/trezor/blockbook/common"
	"github.com/trezor/blockbook/db"
	"github.com/trezor/blockbook/tests/dbtestdata"
)

func httpTestsEthereumType(t *testing.T, ts *httptest.Server) {
	tests := []httpTests{
		{
			name:        "explorerAddress " + dbtestdata.EthAddr7b,
			r:           newGetRequest(ts.URL + "/address/" + dbtestdata.EthAddr7b),
			status:      http.StatusOK,
			contentType: "text/html; charset=utf-8",
			body: []string{
				`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"><link rel="stylesheet" href="/static/css/bootstrap.5.2.2.min.css"><link rel="stylesheet" href="/static/css/main.min.4.css"><script>var hasSecondary=true;</script><script src="/static/js/bootstrap.bundle.5.2.2.min.js"></script><script src="/static/js/main.min.4.js"></script><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content="Trezor Fake Coin Explorer"><title>Trezor Fake Coin Explorer</title></head><body><header id="header"><nav class="navbar navbar-expand-lg"><div class="container"><a class="navbar-brand" href="/" title="Home"><span class="trezor-logo"></span><span style="padding-left: 140px;">Fake Coin Explorer</span></a><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarSupportedContent"><ul class="navbar-nav m-md-auto"><li class="nav-item pe-xl-4"><a href="/blocks" class="nav-link">Blocks</a></li><li class="nav-item"><a href="/" class="nav-link">Status</a></li></ul><span class="navbar-form"><form class="d-flex" id="search" action="/search" method="get"><input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address or xpub" focus="true"><button class="btn" type="submit"><span class="search-icon"></span></button></form></span><div class="bb-group ms-lg-2 mt-2 mt-lg-0" role="group" aria-label="Currency switch"><input type="radio" class="btn-check" name="btnradio" id="primary-coin" autocomplete="off" checked><label class="btn" for="primary-coin">FAKE</label><input type="radio" class="btn-check" name="btnradio" id="secondary-coin" autocomplete="off"><label class="btn" for="secondary-coin">USD</label><button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></button><div class="dropdown-menu row"><div class="col-3"><a href="?secondary=EUR&use_secondary=true">EUR</a></div><div class="col-3"><a href="?secondary=USD&use_secondary=true">USD</a></div></div></div></div></div></nav></header><main id="wrap"><div class="container"><div class="row g-0 ms-2 ms-lg-0"><div class="col-md-10 order-2 order-md-1"><h1>Address address7b.eth</h1><h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b</span></h5><h4 class="row"><div class="col-lg-6"><span class="copyable">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">000</span><span class="ns">123</span><span class="ns">450</span><span class="ns">123</span></span> FAKE</span></div><div class="col-lg-6"><span>0.<span class="amt-dec">00</span> USD</span></div></h4></div><div class="col-md-2 order-1 order-md-2 d-flex justify-content-center justify-content-md-end mb-3 mb-md-0"><div id="qrcode"></div><script type="text/javascript" src="/static/js/qrcode.min.js"></script><script type="text/javascript">new QRCode(document.getElementById("qrcode"), { text: "0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b", width: 120, height: 120 });</script></div></div><table class="table data-table info-table"><tbody><tr><td style="white-space: nowrap;"><h5>Confirmed</h5></td><td></td></tr><tr><td style="width: 25%;">Balance</td><td><span class="amt copyable" cc="0.000000000123450123 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">000</span><span class="ns">123</span><span class="ns">450</span><span class="ns">123</span></span> FAKE</span><span class="sec-amt">0.<span class="amt-dec">00</span> USD</span></span></td></tr><tr><td>Transactions</td><td>2</td></tr><tr><td>Non-contract Transactions</td><td>0</td></tr><tr><td>Internal Transactions</td><td>0</td></tr><tr><td>Nonce</td><td>123</td></tr></tbody></table><div class="accordion mt-2 mb-2" id="erc20"><div class="accordion-item"><div class="accordion-header" id="erc20Heading"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#erc20Body" aria-expanded="false" aria-controls="erc20Body"><div class="row g-0 w-100"><h5 class="col-md-4 mb-md-0">ERC20 Tokens <span class="badge bg-secondary">2</span></h5><h5 class="col-md-8 mb-md-0"><span tt="Total value of tokens">-</span></h5></div></button></div><div id="erc20Body" class="accordion-collapse collapse" aria-labelledby="erc20Heading" data-bs-parent="#erc20"><div class="accordion-body"><table class="table data-table mt-0 mb-0"><tbody><tr><th style="width: 25%;">Contract</th><th style="width: 30%;">Quantity</th><th style="width: 35%;">Value</th><th class="text-end" style="width: 10%;"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th></tr><tr><td class="ellipsis"><a href="/address/0x0d0F936Ee4c93e25944694D6C121de94D9760F11"><span class="copyable" cc="0x0d0F936Ee4c93e25944694D6C121de94D9760F11" alias-type="Contract">Contract 13</span></a></td><td><span class="copyable">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">001</span><span class="ns">000</span><span class="ns">123</span><span class="ns">013</span></span> S13</span></td><td>-</span></td><td class="text-end">1</td></tr><tr><td class="ellipsis"><a href="/address/0x4af4114F73d1c1C903aC9E0361b379D1291808A2"><span class="copyable" cc="0x4af4114F73d1c1C903aC9E0361b379D1291808A2" alias-type="Contract">Contract 74</span></a></td><td><span class="copyable">0.<span class="amt-dec">001<span class="ns">000</span><span class="ns">123</span><span class="ns">074</span></span> S74</span></td><td>-</span></td><td class="text-end">1</td></tr></tbody></table></div></div></div></div><div class="accordion mt-2 mb-2" id="erc721"><div class="accordion-item"><div class="accordion-header" id="erc721Heading"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#erc721Body" aria-expanded="false" aria-controls="erc721Body"><div class="row g-0 w-100"><h5 class="col-12 mb-md-0">ERC721 Tokens <span class="badge bg-secondary">1</span></h5></div></button></div><div id="erc721Body" class="accordion-collapse collapse" aria-labelledby="erc721Heading" data-bs-parent="#erc721"><div class="accordion-body"><table class="table data-table mt-0 mb-0"><tbody><tr><th style="width: 25%;">Contract</th><th style="width: 65%;">Tokens</th><th class="text-end" style="width: 10%;"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th></tr><tr><td class="ellipsis"><a href="/address/0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9"><span class="copyable" cc="0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9" alias-type="Contract">Contract 205</span></a></td><td><a href="/nft/0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9/1">1</a></td><td class="text-end">1</td></tr></tbody></table></div></div></div></div><div class="row pt-3 pb-1"><h3 class="col-sm-6 col-lg-3 m-0 align-self-center">Transactions</h3><div class="col-sm-6 col-lg-3 my-2 my-lg-0 align-self-center"><select  class="w-100" onchange="self.location='?filter='+options[selectedIndex].value"><option>All</option><option  value="inputs">Address on input side</option><option  value="outputs">Address on output side</option><option  value="0">Non-contract</option><option  value="1">Internal</option><option  value="3">Contract 13 (ERC20)</option><option  value="2">Contract 74 (ERC20)</option><option  value="4">Contract 205 (ERC721)</option></select></div><div class="col-lg-6"></div></div><div><div class="tx-detail"><div class="row head"><div class="col-xs-7 col-md-8"><a href="/tx/0xca7628be5c80cda77163729ec63d218ee868a399d827a4682a478c6f48a6e22a" class="ellipsis copyable txid">0xca7628be5c80cda77163729ec63d218ee868a399d827a4682a478c6f48a6e22a</a><span class="ps-1" tt="Replace-by-Fee (RBF) transaction, could be overridden"> RBF</span></div><div class="col-12 small txvalue"><span tt="4-byte signature">0x23b872dd</span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-in"><div class="col-12"><span class="ellipsis"><a href="/address/0x837E3f699d85a4b0B99894567e9233dFB1DcB081"><span class="copyable">0x837E3f699d85a4b0B99894567e9233dFB1DcB081</span></a></span></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-out"><div class="col-12"><span class="ellipsis"><a href="/address/0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9"><span class="copyable" cc="0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9" alias-type="Contract">Contract 205</span></a></span></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div><div class="row subhead">ERC721 Token Transfers</div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x837E3f699d85a4b0B99894567e9233dFB1DcB081"><span class="copyable">0x837E3f699d85a4b0B99894567e9233dFB1DcB081</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis tx-own"><span class="copyable" cc="0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b" alias-type="ENS">address7b.eth</span></div></div></div><div class="col-md-3 amt-out">ID <a href="/nft/0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9/1">1</a> S205</div></div><div class="row footer"><div class="col-sm-12 col-md-6">Fee <span class="amt txvalue copyable ms-3" cc="0.00008794500041041 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">087</span><span class="ns">945</span><span class="ns">000</span><span class="ns">410</span><span class="ns">41</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">18</span> USD</span><span class="csec-amt">0.<span class="amt-dec">78</span> USD</span></span> <span class="fw-normal small">(<span cc="1.500000007"><span>1.<span class="amt-dec">500<span class="ns">000</span><span class="ns">007</span></span></span></span> Gwei/gas)</span></div><div class="col-sm-12 col-md-6 text-end"><span class="me-4"><span class="txvalue unconfirmed">Unconfirmed Transaction!</span></span><span class="amt txvalue copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div></div><div class="tx-detail"><div class="row head"><div class="col-xs-7 col-md-8"><a href="/tx/0xc92919ad24ffd58f760b18df7949f06e1190cf54a50a0e3745a385608ed3cbf2" class="ellipsis copyable txid">0xc92919ad24ffd58f760b18df7949f06e1190cf54a50a0e3745a385608ed3cbf2</a><span class="ps-1" tt="Replace-by-Fee (RBF) transaction, could be overridden"> RBF</span></div><div class="col-12 small txvalue"><span tt="4-byte signature">0x4f150787</span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-in"><div class="col-12"><span class="ellipsis"><a href="/address/0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"><span class="copyable">0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D</span></a></span></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-out"><div class="col-12"><span class="ellipsis"><a href="/address/0x479CC461fEcd078F766eCc58533D6F69580CF3AC"><span class="copyable">0x479CC461fEcd078F766eCc58533D6F69580CF3AC</span></a></span></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div><div class="row subhead">ERC20 Token Transfers</div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f"><span class="copyable">0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"><span class="copyable">0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D</span></a></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="7.675000000000000001 S13"><span class="prim-amt">7.<span class="amt-dec">675<span class="ns">000</span><span class="ns">000</span><span class="ns">000</span><span class="ns">000</span><span class="ns">001</span></span> S13</span><span class="sec-amt">-</span></span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"><span class="copyable">0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f"><span class="copyable">0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f</span></a></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="854.307892726464 S74"><span class="prim-amt">854.<span class="amt-dec">307<span class="ns">892</span><span class="ns">726</span><span class="ns">464</span></span> S74</span><span class="sec-amt">-</span></span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis tx-own"><span class="copyable" cc="0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b" alias-type="ENS">address7b.eth</span></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"><span class="copyable">0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D</span></a></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="871.180000950184 S74"><span class="prim-amt">871.<span class="amt-dec">180<span class="ns">000</span><span class="ns">950</span><span class="ns">184</span></span> S74</span><span class="sec-amt">-</span></span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"><span class="copyable">0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis tx-own"><span class="copyable" cc="0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b" alias-type="ENS">address7b.eth</span></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="7.674999999999991915 S13"><span class="prim-amt">7.<span class="amt-dec">674<span class="ns">999</span><span class="ns">999</span><span class="ns">999</span><span class="ns">991</span><span class="ns">915</span></span> S13</span><span class="sec-amt">-</span></span></div></div><div class="row footer"><div class="col-sm-12 col-md-6">Fee <span class="amt txvalue copyable ms-3" cc="0.000216368 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">216</span><span class="ns">368</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">43</span> USD</span><span class="csec-amt">1.<span class="amt-dec">93</span> USD</span></span> <span class="fw-normal small">(<span cc="1"><span>1</span></span> Gwei/gas)</span></div><div class="col-sm-12 col-md-6 text-end"><span class="me-4"><span class="txvalue unconfirmed">Unconfirmed Transaction!</span></span><span class="amt txvalue copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div></div></div></div></main><footer id="footer"><div class="container"><nav class="navbar navbar-dark"><span class="navbar-nav"><a class="nav-link" href="https://satoshilabs.com/" target="_blank" rel="noopener noreferrer">Created by SatoshiLabs</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="https://trezor.io/terms-of-use" target="_blank" rel="noopener noreferrer">Terms of Use</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/" target="_blank" rel="noopener noreferrer">Trezor</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/trezor-suite" target="_blank" rel="noopener noreferrer">Suite</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/support" target="_blank" rel="noopener noreferrer">Support</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="/sendtx">Send Transaction</a></span><span class="navbar-nav ml-md-auto d-lg-flex d-none"><a class="nav-link" href="https://trezor.io/compare" target="_blank" rel="noopener noreferrer">Don't have a Trezor? Get one!</a></span></nav></div></footer></body></html>`,
			},
		},
		{
			name:        "explorerAddress " + dbtestdata.EthAddr5d,
			r:           newGetRequest(ts.URL + "/address/" + dbtestdata.EthAddr5d),
			status:      http.StatusOK,
			contentType: "text/html; charset=utf-8",
			body: []string{
				`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"><link rel="stylesheet" href="/static/css/bootstrap.5.2.2.min.css"><link rel="stylesheet" href="/static/css/main.min.4.css"><script>var hasSecondary=true;</script><script src="/static/js/bootstrap.bundle.5.2.2.min.js"></script><script src="/static/js/main.min.4.js"></script><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content="Trezor Fake Coin Explorer"><title>Trezor Fake Coin Explorer</title></head><body><header id="header"><nav class="navbar navbar-expand-lg"><div class="container"><a class="navbar-brand" href="/" title="Home"><span class="trezor-logo"></span><span style="padding-left: 140px;">Fake Coin Explorer</span></a><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarSupportedContent"><ul class="navbar-nav m-md-auto"><li class="nav-item pe-xl-4"><a href="/blocks" class="nav-link">Blocks</a></li><li class="nav-item"><a href="/" class="nav-link">Status</a></li></ul><span class="navbar-form"><form class="d-flex" id="search" action="/search" method="get"><input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address or xpub" focus="true"><button class="btn" type="submit"><span class="search-icon"></span></button></form></span><div class="bb-group ms-lg-2 mt-2 mt-lg-0" role="group" aria-label="Currency switch"><input type="radio" class="btn-check" name="btnradio" id="primary-coin" autocomplete="off" checked><label class="btn" for="primary-coin">FAKE</label><input type="radio" class="btn-check" name="btnradio" id="secondary-coin" autocomplete="off"><label class="btn" for="secondary-coin">USD</label><button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></button><div class="dropdown-menu row"><div class="col-3"><a href="?secondary=EUR&use_secondary=true">EUR</a></div><div class="col-3"><a href="?secondary=USD&use_secondary=true">USD</a></div></div></div></div></div></nav></header><main id="wrap"><div class="container"><div class="row g-0 ms-2 ms-lg-0"><div class="col-md-10 order-2 order-md-1"><h1>Address </h1><h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e</span></h5><h4 class="row"><div class="col-lg-6"><span class="copyable">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">000</span><span class="ns">123</span><span class="ns">450</span><span class="ns">093</span></span> FAKE</span></div><div class="col-lg-6"><span>0.<span class="amt-dec">00</span> USD</span></div></h4></div><div class="col-md-2 order-1 order-md-2 d-flex justify-content-center justify-content-md-end mb-3 mb-md-0"><div id="qrcode"></div><script type="text/javascript" src="/static/js/qrcode.min.js"></script><script type="text/javascript">new QRCode(document.getElementById("qrcode"), { text: "0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e", width: 120, height: 120 });</script></div></div><table class="table data-table info-table"><tbody><tr><td style="white-space: nowrap;"><h5>Confirmed</h5></td><td></td></tr><tr><td style="width: 25%;">Balance</td><td><span class="amt copyable" cc="0.000000000123450093 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">000</span><span class="ns">123</span><span class="ns">450</span><span class="ns">093</span></span> FAKE</span><span class="sec-amt">0.<span class="amt-dec">00</span> USD</span></span></td></tr><tr><td>Transactions</td><td>1</td></tr><tr><td>Non-contract Transactions</td><td>1</td></tr><tr><td>Internal Transactions</td><td>0</td></tr><tr><td>Nonce</td><td>93</td></tr></tbody></table><div class="accordion mt-2 mb-2" id="erc1155"><div class="accordion-item"><div class="accordion-header" id="erc1155Heading"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#erc1155Body" aria-expanded="false" aria-controls="erc1155Body"><div class="row g-0 w-100"><h5 class="col-12 mb-md-0">ERC1155 Tokens <span class="badge bg-secondary">1</span></h5></div></button></div><div id="erc1155Body" class="accordion-collapse collapse" aria-labelledby="erc1155Heading" data-bs-parent="#erc1155"><div class="accordion-body"><table class="table data-table mt-0 mb-0"><tbody><tr><th style="width: 25%;">Contract</th><th style="width: 65%;">Tokens</th><th class="text-end" style="width: 10%;"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th></tr><tr><td class="ellipsis"><a href="/address/0x6Fd712E3A5B556654044608F9129040A4839E36c"><span class="copyable" cc="0x6Fd712E3A5B556654044608F9129040A4839E36c" alias-type="Contract">Contract 111</span></a></td><td><span>1 S111</span> of ID <a href="/nft/0x6Fd712E3A5B556654044608F9129040A4839E36c/1776">1776</a>, <span>10 S111</span> of ID <a href="/nft/0x6Fd712E3A5B556654044608F9129040A4839E36c/1898">1898</a></td><td class="text-end">1</td></tr></tbody></table></div></div></div></div><div class="row pt-3 pb-1"><h3 class="col-sm-6 col-lg-3 m-0 align-self-center">Transactions</h3><div class="col-sm-6 col-lg-3 my-2 my-lg-0 align-self-center"><select  class="w-100" onchange="self.location='?filter='+options[selectedIndex].value"><option>All</option><option  value="inputs">Address on input side</option><option  value="outputs">Address on output side</option><option  value="0">Non-contract</option><option  value="1">Internal</option><option  value="2">Contract 111 (ERC1155)</option></select></div><div class="col-lg-6"></div></div><div><div class="tx-detail"><div class="row head"><div class="col-xs-7 col-md-8"><a href="/tx/0x6942c79c04ae981a2d194deb0ae5ae5e9d5d7a90fd9f52246b162fa645155e3a" class="ellipsis copyable txid">0x6942c79c04ae981a2d194deb0ae5ae5e9d5d7a90fd9f52246b162fa645155e3a</a><span class="ps-1" tt="Replace-by-Fee (RBF) transaction, could be overridden"> RBF</span></div><div class="col-12 small txvalue"><span tt="4-byte signature">0x78627919</span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-in"><div class="col-12 tx-own"><span class="ellipsis"><span class="copyable">0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e</span></span></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-out"><div class="col-12"><span class="ellipsis"><a href="/address/0x6Fd712E3A5B556654044608F9129040A4839E36c"><span class="copyable" cc="0x6Fd712E3A5B556654044608F9129040A4839E36c" alias-type="Contract">Contract 111</span></a></span></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div><div class="row subhead">ERC1155 Token Transfers</div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x0000000000000000000000000000000000000000"><span class="copyable">0x0000000000000000000000000000000000000000</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis tx-own"><span class="copyable">0x5Dc6288b35E0807A3d6fEB89b3a2Ff4aB773168e</span></div></div></div><div class="col-md-3 amt-out"><span>1 S111</span> of ID <a href="/nft/0x6Fd712E3A5B556654044608F9129040A4839E36c/1776">1776</a>, <span>10 S111</span> of ID <a href="/nft/0x6Fd712E3A5B556654044608F9129040A4839E36c/1898">1898</a></div></div><div class="row footer"><div class="col-sm-12 col-md-6">Fee <span class="amt txvalue copyable ms-3" cc="0.000081891755740665 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">081</span><span class="ns">891</span><span class="ns">755</span><span class="ns">740</span><span class="ns">665</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">16</span> USD</span><span class="csec-amt">0.<span class="amt-dec">73</span> USD</span></span> <span class="fw-normal small">(<span cc="1.110803355"><span>1.<span class="amt-dec">110<span class="ns">803</span><span class="ns">355</span></span></span></span> Gwei/gas)</span></div><div class="col-sm-12 col-md-6 text-end"><span class="me-4"><span class="txvalue unconfirmed">Unconfirmed Transaction!</span></span><span class="amt txvalue copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div></div></div></div></main><footer id="footer"><div class="container"><nav class="navbar navbar-dark"><span class="navbar-nav"><a class="nav-link" href="https://satoshilabs.com/" target="_blank" rel="noopener noreferrer">Created by SatoshiLabs</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="https://trezor.io/terms-of-use" target="_blank" rel="noopener noreferrer">Terms of Use</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/" target="_blank" rel="noopener noreferrer">Trezor</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/trezor-suite" target="_blank" rel="noopener noreferrer">Suite</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/support" target="_blank" rel="noopener noreferrer">Support</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="/sendtx">Send Transaction</a></span><span class="navbar-nav ml-md-auto d-lg-flex d-none"><a class="nav-link" href="https://trezor.io/compare" target="_blank" rel="noopener noreferrer">Don't have a Trezor? Get one!</a></span></nav></div></footer></body></html>`,
			},
		},
		{
			name:        "explorerTx " + dbtestdata.EthTxidB1T2,
			r:           newGetRequest(ts.URL + "/tx/0x" + dbtestdata.EthTxidB1T2),
			status:      http.StatusOK,
			contentType: "text/html; charset=utf-8",
			body: []string{
				`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"><link rel="stylesheet" href="/static/css/bootstrap.5.2.2.min.css"><link rel="stylesheet" href="/static/css/main.min.4.css"><script>var hasSecondary=true;</script><script src="/static/js/bootstrap.bundle.5.2.2.min.js"></script><script src="/static/js/main.min.4.js"></script><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content="Trezor Fake Coin Explorer"><title>Trezor Fake Coin Explorer</title></head><body><header id="header"><nav class="navbar navbar-expand-lg"><div class="container"><a class="navbar-brand" href="/" title="Home"><span class="trezor-logo"></span><span style="padding-left: 140px;">Fake Coin Explorer</span></a><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarSupportedContent"><ul class="navbar-nav m-md-auto"><li class="nav-item pe-xl-4"><a href="/blocks" class="nav-link">Blocks</a></li><li class="nav-item"><a href="/" class="nav-link">Status</a></li></ul><span class="navbar-form"><form class="d-flex" id="search" action="/search" method="get"><input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address or xpub" focus="true"><button class="btn" type="submit"><span class="search-icon"></span></button></form></span><div class="bb-group ms-lg-2 mt-2 mt-lg-0" role="group" aria-label="Currency switch"><input type="radio" class="btn-check" name="btnradio" id="primary-coin" autocomplete="off" checked><label class="btn" for="primary-coin">FAKE</label><input type="radio" class="btn-check" name="btnradio" id="secondary-coin" autocomplete="off"><label class="btn" for="secondary-coin">USD</label><button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></button><div class="dropdown-menu row"><div class="col-3"><a href="?secondary=EUR&use_secondary=true">EUR</a></div><div class="col-3"><a href="?secondary=USD&use_secondary=true">USD</a></div></div></div></div></div></nav></header><main id="wrap"><div class="container"><div class="row"><h1 class="col-12">Transaction</h1></div><div class="row pt-3"><h5 class="col-12 d-flex h-data"><span class="ellipsis copyable">0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101</span></h5></div><table class="table data-table info-table"><tbody><tr><td>In Block</td><td class="ellipsis" style="max-width: 280px"><span class="badge bg-danger">Unconfirmed</span></td></tr><tr><td>Status</td><td><span class="badge bg-success">Success</span></td></tr><tr><td>Value</td><td><span class="amt copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></td></tr><tr><td>Gas Used / Limit</td><td>52<span class="ns">025</span> / 78<span class="ns">037</span></td></tr><tr><td>Gas Price</td><td><span class="amt copyable" cc="0.00000004 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">04</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span> <span class="fw-normal ps-3">(<span class="copyable" cc="40"><span>40</span></span> Gwei)</span></td></tr><tr><td>Max Priority Fee Per Gas</td><td><span class="amt copyable" cc="0.000000040000000001 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">040</span><span class="ns">000</span><span class="ns">000</span><span class="ns">001</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span> <span class="fw-normal ps-3">(<span class="copyable" cc="40.000000001"><span>40.<span class="amt-dec">000<span class="ns">000</span><span class="ns">001</span></span></span></span> Gwei)</span></td></tr><tr><td>Max Fee Per Gas</td><td><span class="amt copyable" cc="0.000000040000000002 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">040</span><span class="ns">000</span><span class="ns">000</span><span class="ns">002</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span> <span class="fw-normal ps-3">(<span class="copyable" cc="40.000000002"><span>40.<span class="amt-dec">000<span class="ns">000</span><span class="ns">002</span></span></span></span> Gwei)</span></td></tr><tr><td>Base Fee Per Gas</td><td><span class="amt copyable" cc="0.000000040000000003 FAKE"><span class="prim-amt">0.<span class="amt-dec">000<span class="ns">000</span><span class="ns">040</span><span class="ns">000</span><span class="ns">000</span><span class="ns">003</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span> <span class="fw-normal ps-3">(<span class="copyable" cc="40.000000003"><span>40.<span class="amt-dec">000<span class="ns">000</span><span class="ns">003</span></span></span></span> Gwei)</span></td></tr><tr><td>Fees</td><td><span class="amt copyable" cc="0.002081 FAKE"><span class="prim-amt">0.<span class="amt-dec">002<span class="ns">081</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">4.<span class="amt-dec">16</span> USD</span><span class="csec-amt">18.<span class="amt-dec">55</span> USD</span></span></td></tr><tr><td><span tt="Replace by fee">RBF</span></td><td><span tt="Replace-by-Fee transaction, could be overridden by a new transaction">ON</span></td></tr><tr><td>Nonce</td><td>208</td></tr></tbody></table><div class="pt-1"><div class="tx-detail"><div class="row head"><div class="col-xs-7 col-md-8"><a href="/tx/0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101" class="ellipsis copyable txid">0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101</a><span class="ps-1" tt="Replace-by-Fee (RBF) transaction, could be overridden"> RBF</span></div><div class="col-12 small"><span class="txvalue">Transfer</span><span class="ms-1" tt="4-byte signature"> (0xa9059cbb)</span></div></div><div class="row body"><div class="col-md-4"><div class="row tx-in"><div class="col-12"><span class="ellipsis"><a href="/address/0x20cD153de35D469BA46127A0C8F18626b59a256A"><span class="copyable" cc="0x20cD153de35D469BA46127A0C8F18626b59a256A" alias-type="ENS">address20.eth</span></a></span></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-out"><div class="col-12"><span class="ellipsis"><a href="/address/0x4af4114F73d1c1C903aC9E0361b379D1291808A2"><span class="copyable" cc="0x4af4114F73d1c1C903aC9E0361b379D1291808A2" alias-type="Contract">Contract 74</span></a></span></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div><div class="row subhead">ERC20 Token Transfers</div><div class="row body"><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x20cD153de35D469BA46127A0C8F18626b59a256A"><span class="copyable" cc="0x20cD153de35D469BA46127A0C8F18626b59a256A" alias-type="ENS">address20.eth</span></a></div></div></div><div class="col-md-1 col-xs-12 text-center">&nbsp;<span class="octicon"></span></div><div class="col-md-4"><div class="row tx-addr"><div class="col-12 ellipsis"><a href="/address/0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f"><span class="copyable">0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f</span></a></div></div></div><div class="col-md-3 amt-out"><span class="amt tx-out copyable" cc="10000000000 S74"><span class="prim-amt">10<span class="nc">000</span><span class="nc">000</span><span class="nc">000</span> S74</span><span class="sec-amt">-</span></span></div></div><div class="row footer"><div class="col-sm-12 col-md-6">Fee <span class="amt txvalue copyable ms-3" cc="0.002081 FAKE"><span class="prim-amt">0.<span class="amt-dec">002<span class="ns">081</span></span> FAKE</span><span class="sec-amt" tm="1969-12-31">4.<span class="amt-dec">16</span> USD</span><span class="csec-amt">18.<span class="amt-dec">55</span> USD</span></span> <span class="fw-normal small">(<span cc="40"><span>40</span></span> Gwei/gas)</span></div><div class="col-sm-12 col-md-6 text-end"><span class="me-4"><span class="txvalue unconfirmed">Unconfirmed Transaction!</span></span><span class="amt txvalue copyable" cc="0 FAKE"><span class="prim-amt">0 FAKE</span><span class="sec-amt" tm="1969-12-31">0.<span class="amt-dec">00</span> USD</span><span class="csec-amt">0.<span class="amt-dec">00</span> USD</span></span></div></div></div></div><div class="pt-2"><h5>Input Data</h5><div class="accordion" id="inputData"><div class="accordion-item"><h2 class="accordion-header" id="inputDataHeading"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#inputDataBody" aria-expanded="false" aria-controls="inputDataBody"><h5 class="mb-0">Transfer  <span class="fw-normal small" tt="4-byte signature">0xa9059cbb</span></h5></button></h2><div id="inputDataBody" class="accordion-collapse collapse" aria-labelledby="inputDataHeading" data-bs-parent="#inputData"><div class="accordion-body"><div class="row"><div class="col-12 mx-1 mx-md-0"><span class="copyable" style="overflow-wrap: break-word;">0xa9059cbb000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f00000000000000000000000000000000000000000000021e19e0c9bab2400000</span></div><div class="col-12 mx-1 mx-md-0 pt-2"><span class="copyable">transfer(address, uint256)</span></div><div class="col-12"><table class="table data-table mt-2 mb-0"><thead><tr><th style="width: 5%;">#</th><th style="width: 20%;">Type</th><th>Data</th></tr></thead><tbody><tr><td>0</td><td>address</td><td><a href="/address/0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f"><span class="copyable">0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f</span></a></td></tr><tr><td>1</td><td>uint256</td><td><span class="copyable">10000000000000000000000</span></td></tr></tbody></table></div></div></div></div></div></div></div><div class="pt-4"><button style="color: black" class="btn btn-paging" id="raw-button">Raw Transaction</button><button style="color: black" class="btn btn-paging" id="raw-hex-button">Raw Transaction Hex</button><div class="json copyable"><pre id="raw" style="text-wrap: auto;"></pre></div><script>const rawData = {"tx":{"nonce":"0xd0","gasPrice":"0x9502f9000","maxPriorityFeePerGas":"0x9502f9001","maxFeePerGas":"0x9502f9002","baseFeePerGas":"0x9502f9003","gas":"0x130d5","to":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","value":"0x0","input":"0xa9059cbb000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f00000000000000000000000000000000000000000000021e19e0c9bab2400000","hash":"0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101","blockNumber":"0x41eee8","from":"0x20cD153de35D469BA46127A0C8F18626b59a256A","transactionIndex":"0x0"},"internalData":{"type":0,"transfers":[{"type":1,"from":"9f4981531fda132e83c44680787dfa7ee31e4f8d","to":"4af4114f73d1c1c903ac9e0361b379d1291808a2","value":1000000},{"type":0,"from":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","to":"9f4981531fda132e83c44680787dfa7ee31e4f8d","value":1000001},{"type":0,"from":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","to":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","value":1000002}],"Error":""},"receipt":{"gasUsed":"0xcb39","status":"0x1","logs":[{"address":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000020cd153de35d469ba46127a0c8f18626b59a256a","0x000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f"],"data":"0x00000000000000000000000000000000000000000000021e19e0c9bab2400000"}]}};const txId = "0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101";handleTxPage(rawData, txId);</script></div></div></main><footer id="footer"><div class="container"><nav class="navbar navbar-dark"><span class="navbar-nav"><a class="nav-link" href="https://satoshilabs.com/" target="_blank" rel="noopener noreferrer">Created by SatoshiLabs</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="https://trezor.io/terms-of-use" target="_blank" rel="noopener noreferrer">Terms of Use</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/" target="_blank" rel="noopener noreferrer">Trezor</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/trezor-suite" target="_blank" rel="noopener noreferrer">Suite</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/support" target="_blank" rel="noopener noreferrer">Support</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="/sendtx">Send Transaction</a></span><span class="navbar-nav ml-md-auto d-lg-flex d-none"><a class="nav-link" href="https://trezor.io/compare" target="_blank" rel="noopener noreferrer">Don't have a Trezor? Get one!</a></span></nav></div></footer></body></html>`,
			},
		}, {
			name:        "explorerTokenDetail " + dbtestdata.EthAddr7b,
			r:           newGetRequest(ts.URL + "/nft/" + dbtestdata.EthAddrContractCd + "/" + "1"),
			status:      http.StatusOK,
			contentType: "text/html; charset=utf-8",
			body:        []string{`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"><link rel="stylesheet" href="/static/css/bootstrap.5.2.2.min.css"><link rel="stylesheet" href="/static/css/main.min.4.css"><script>var hasSecondary=true;</script><script src="/static/js/bootstrap.bundle.5.2.2.min.js"></script><script src="/static/js/main.min.4.js"></script><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content="Trezor Fake Coin Explorer"><title>Trezor Fake Coin Explorer</title></head><body><header id="header"><nav class="navbar navbar-expand-lg"><div class="container"><a class="navbar-brand" href="/" title="Home"><span class="trezor-logo"></span><span style="padding-left: 140px;">Fake Coin Explorer</span></a><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarSupportedContent"><ul class="navbar-nav m-md-auto"><li class="nav-item pe-xl-4"><a href="/blocks" class="nav-link">Blocks</a></li><li class="nav-item"><a href="/" class="nav-link">Status</a></li></ul><span class="navbar-form"><form class="d-flex" id="search" action="/search" method="get"><input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address or xpub" focus="true"><button class="btn" type="submit"><span class="search-icon"></span></button></form></span><div class="bb-group ms-lg-2 mt-2 mt-lg-0" role="group" aria-label="Currency switch"><input type="radio" class="btn-check" name="btnradio" id="primary-coin" autocomplete="off" checked><label class="btn" for="primary-coin">FAKE</label><input type="radio" class="btn-check" name="btnradio" id="secondary-coin" autocomplete="off"><label class="btn" for="secondary-coin">USD</label><button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></button><div class="dropdown-menu row"><div class="col-3"><a href="?secondary=EUR&use_secondary=true">EUR</a></div><div class="col-3"><a href="?secondary=USD&use_secondary=true">USD</a></div></div></div></div></div></nav></header><main id="wrap"><div class="container"><h1>NFT Token Detail</h1><div class="row"><div class="col-md-6"><table class="table data-table info-table"><tbody><tr><td style="width: 25%;">Token ID</td><td><span class="copyable">1</span></td></tr><tr id="name" style="display: none;"><td>NTF Name</td><td class="copyable"></td></tr><tr id="description" style="display: none;"><td>NTF Description</td><td></td></tr><tr><td>Contract</td><td><a href="/address/0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9"><span class="copyable">0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9</span></a><br>Contract 205</td></tr><tr><td>Standard</td><td>ERC20</td></tr></tbody></table></div><div class="col-md-6 mt-4" id="image"></div></div><div id="metadatablock"><h5>Metadata</h5><div class="json"><pre id="raw">Loading metadata from <a href="https://ipfs.io/ipfs/cda9fc258358ecaa88845f19af595e908bb7efe9.json">https://ipfs.io/ipfs/cda9fc258358ecaa88845f19af595e908bb7efe9.json</a>...</pre></div></div><script type="text/javascript">function showImage(s) {const img = document.createElement("img");img.className="border w-100 bg-white";img.src = s;const src = document.getElementById("image");src.appendChild(img);src.style.display="block";}function nftInfo(id,text) {const src = document.getElementById(id);src.getElementsByTagName("td")[1].innerText=text;src.style.display='';}async function getMetadata(url) {try {const uri="https://ipfs.io/ipfs/cda9fc258358ecaa88845f19af595e908bb7efe9.json";if(uri) {const response = await fetch(uri);const contentType=response.headers.get('content-type');if(contentType&&contentType.toString().startsWith("image/")) {showImage(uri);document.getElementById("metadatablock").style.display='none';} else {const data = await response.json();document.getElementById("raw").innerHTML = syntaxHighlight(data);if (data.name) {nftInfo('name',data.name)}if (data.description) {nftInfo('description',data.description)}if (data.image||data.image_url) {let s=data.image?.toString();if(!s) {s=data.image_url;}if(s.startsWith("ipfs://")) {s=s.replace("ipfs://","https://ipfs.io/ipfs/");}if(s.startsWith("https://")) {showImage(s);}}}} else {document.getElementById("raw").innerText = "Error: cannot get metadata link from blockchain";}} catch(e) {document.getElementById("raw").innerText = "Error loading metadata: "+e;}}getMetadata();</script></div></main><footer id="footer"><div class="container"><nav class="navbar navbar-dark"><span class="navbar-nav"><a class="nav-link" href="https://satoshilabs.com/" target="_blank" rel="noopener noreferrer">Created by SatoshiLabs</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="https://trezor.io/terms-of-use" target="_blank" rel="noopener noreferrer">Terms of Use</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/" target="_blank" rel="noopener noreferrer">Trezor</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/trezor-suite" target="_blank" rel="noopener noreferrer">Suite</a></span><span class="navbar-nav ml-md-auto d-md-flex d-none"><a class="nav-link" href="https://trezor.io/support" target="_blank" rel="noopener noreferrer">Support</a></span><span class="navbar-nav ml-md-auto"><a class="nav-link" href="/sendtx">Send Transaction</a></span><span class="navbar-nav ml-md-auto d-lg-flex d-none"><a class="nav-link" href="https://trezor.io/compare" target="_blank" rel="noopener noreferrer">Don't have a Trezor? Get one!</a></span></nav></div></footer></body></html>`},
		},
		{
			name:        "apiIndex",
			r:           newGetRequest(ts.URL + "/api"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"blockbook":{"coin":"Fakecoin"`,
				`"bestHeight":4321001`,
				`"decimals":18`,
				`"backend":{"chain":"fakecoin","blocks":2,"headers":2,"bestBlockHash":"0x2b57e15e93a0ed197417a34c2498b7187df79099572c04a6b6e6ff418f74e6ee"`,
				`"version":"001001","subversion":"/Fakecoin:0.0.1/"`,
			},
		},
		{
			name:        "apiAddress EthAddr4b",
			r:           newGetRequest(ts.URL + "/api/v2/address/" + dbtestdata.EthAddr4b),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"page":1,"totalPages":1,"itemsOnPage":1000,"address":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","balance":"123450075","unconfirmedBalance":"0","unconfirmedTxs":0,"txs":1,"nonTokenTxs":1,"internalTxs":1,"txids":["0xc92919ad24ffd58f760b18df7949f06e1190cf54a50a0e3745a385608ed3cbf2"],"nonce":"75","tokens":[{"type":"ERC20","standard":"ERC20","name":"Contract 13","contract":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","transfers":2,"symbol":"S13","decimals":18,"balance":"1000075013"},{"type":"ERC20","standard":"ERC20","name":"Contract 74","contract":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","transfers":2,"symbol":"S74","decimals":12,"balance":"1000075074"}]}`,
			},
		},
		{
			name:        "apiAddress EthAddr7b details=txs",
			r:           newGetRequest(ts.URL + "/api/v2/address/" + dbtestdata.EthAddr7b + "?details=txs"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"page":1,"totalPages":1,"itemsOnPage":1000,"address":"0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b","balance":"123450123","unconfirmedBalance":"0","unconfirmedTxs":0,"txs":2,"transactions":[{"txid":"0xca7628be5c80cda77163729ec63d218ee868a399d827a4682a478c6f48a6e22a","vin":[{"n":0,"addresses":["0x837E3f699d85a4b0B99894567e9233dFB1DcB081"],"isAddress":true}],"vout":[{"value":"0","n":0,"addresses":["0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9"],"isAddress":true}],"blockHeight":-1,"confirmations":0,"blockTime":0,"value":"0","fees":"87945000410410","rbf":true,"coinSpecificData":{"tx":{"nonce":"0x2","gasPrice":"0x59682f07","gas":"0x173a9","to":"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9","value":"0x0","input":"0x23b872dd000000000000000000000000837e3f699d85a4b0b99894567e9233dfb1dcb0810000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b0000000000000000000000000000000000000000000000000000000000000001","hash":"0xca7628be5c80cda77163729ec63d218ee868a399d827a4682a478c6f48a6e22a","blockNumber":"0xb33b9f","from":"0x837E3f699d85a4b0B99894567e9233dFB1DcB081","transactionIndex":"0x1"},"receipt":{"gasUsed":"0xe506","status":"0x1","logs":[{"address":"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9","topics":["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x000000000000000000000000837e3f699d85a4b0b99894567e9233dfb1dcb081","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000001"],"data":"0x"},{"address":"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000837e3f699d85a4b0b99894567e9233dfb1dcb081","0x0000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b","0x0000000000000000000000000000000000000000000000000000000000000001"],"data":"0x"}]}},"tokenTransfers":[{"type":"ERC721","standard":"ERC721","from":"0x837E3f699d85a4b0B99894567e9233dFB1DcB081","to":"0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b","contract":"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9","name":"Contract 205","symbol":"S205","decimals":18,"value":"1"}],"ethereumSpecific":{"status":1,"nonce":2,"gasLimit":95145,"gasUsed":58630,"gasPrice":"1500000007","data":"0x23b872dd000000000000000000000000837e3f699d85a4b0b99894567e9233dfb1dcb0810000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b0000000000000000000000000000000000000000000000000000000000000001","parsedData":{"methodId":"0x23b872dd","name":""}}},{"txid":"0xc92919ad24ffd58f760b18df7949f06e1190cf54a50a0e3745a385608ed3cbf2","vin":[{"n":0,"addresses":["0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D"],"isAddress":true}],"vout":[{"value":"0","n":0,"addresses":["0x479CC461fEcd078F766eCc58533D6F69580CF3AC"],"isAddress":true}],"blockHeight":-1,"confirmations":0,"blockTime":0,"value":"0","fees":"216368000000000","rbf":true,"coinSpecificData":{"tx":{"nonce":"0x1df76","gasPrice":"0x3b9aca00","gas":"0x3d090","to":"0x479CC461fEcd078F766eCc58533D6F69580CF3AC","value":"0x0","input":"0x4f15078700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f110000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a200000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a20000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000a5ef5a7656bfb0000000000000000000000000000000000000000000000000000004ba78398d5c5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000166cfe0b9579b4ecf7a2801880f644009a324671a79754ea57c3a103c6e70d3dbef6ba69a08000000000000000000000000000000000000000000000000004f937d86afb90000000000000000000000000000000000000000000000000ab280fd8037d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000166cfb784b7c1f3fbe8b75484603ab8adc58aaee3a46245a6579fac7077b5570018b4e0d4eb0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000308fd0e798ac00000000000000000000000000000000000000000000000006a8313d60b1f606b0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001b00000000000000000000000000000000000000000000000000000000000000029de0ccec59e8948e3d905b40e5542335ebc1eb4674db517d2f6392ec7fdeb3d45f3449d313ee2589819c6c79eb1c1b047adae68565c1608e3a1d1d70823febb0000000000000000000000000000000000000000000000000000000000000000234d06fe17f1202e8b07177a30eb64d14adc08cdb3fa1b3e3e0bea0f9672c02175b77c01c51d3c7e460723b27ecbc7801fd6482559a8c9999593f9a4d149c7384","hash":"0xc92919ad24ffd58f760b18df7949f06e1190cf54a50a0e3745a385608ed3cbf2","blockNumber":"0x41eee9","from":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","transactionIndex":"0x24"},"internalData":{"type":1,"contract":"0d0f936ee4c93e25944694d6c121de94d9760f11","transfers":[{"type":0,"from":"4bda106325c335df99eab7fe363cac8a0ba2a24d","to":"9f4981531fda132e83c44680787dfa7ee31e4f8d","value":1000010},{"type":2,"from":"4af4114f73d1c1c903ac9e0361b379d1291808a2","to":"9f4981531fda132e83c44680787dfa7ee31e4f8d","value":1000011}],"Error":""},"receipt":{"gasUsed":"0x34d30","status":"0x1","logs":[{"address":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f","0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d"],"data":"0x0000000000000000000000000000000000000000000000006a8313d60b1f8001"},{"address":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d","0x000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f"],"data":"0x000000000000000000000000000000000000000000000000000308fd0e798ac0"},{"address":"0x479CC461fEcd078F766eCc58533D6F69580CF3AC","topics":["0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3","0x000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f","0x0000000000000000000000000000000000000000000000000000000000000000","0x5af266c0a89a07c1917deaa024414577e6c3c31c8907d079e13eb448c082594f"],"data":"0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f110000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a20000000000000000000000000000000000000000000000006a8313d60b1f8001000000000000000000000000000000000000000000000000000308fd0e798ac0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005e083a16f4b092c5729a49f9c3ed3cc171bb3d3d0c22e20b1de6063c32f399ac"},{"address":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b","0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d"],"data":"0x00000000000000000000000000000000000000000000000000031855667df7a8"},{"address":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d","0x0000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b"],"data":"0x0000000000000000000000000000000000000000000000006a8313d60b1f606b"},{"address":"0x479CC461fEcd078F766eCc58533D6F69580CF3AC","topics":["0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3","0x0000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b","0x0000000000000000000000000000000000000000000000000000000000000000","0xb0b69dad58df6032c3b266e19b1045b19c87acd2c06fb0c598090f44b8e263aa"],"data":"0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a20000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f1100000000000000000000000000000000000000000000000000031855667df7a80000000000000000000000000000000000000000000000006a8313d60b1f606b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f2b0d62c44ed08f2a5adef40c875d20310a42a9d4f488bd26323256fe01c7f48"}]}},"tokenTransfers":[{"type":"ERC20","standard":"ERC20","from":"0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f","to":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","contract":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","name":"Contract 13","symbol":"S13","decimals":18,"value":"7675000000000000001"},{"type":"ERC20","standard":"ERC20","from":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","to":"0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f","contract":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","name":"Contract 74","symbol":"S74","decimals":12,"value":"854307892726464"},{"type":"ERC20","standard":"ERC20","from":"0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b","to":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","contract":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","name":"Contract 74","symbol":"S74","decimals":12,"value":"871180000950184"},{"type":"ERC20","standard":"ERC20","from":"0x4Bda106325C335dF99eab7fE363cAC8A0ba2a24D","to":"0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b","contract":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","name":"Contract 13","symbol":"S13","decimals":18,"value":"7674999999999991915"}],"ethereumSpecific":{"status":1,"nonce":122742,"gasLimit":250000,"gasUsed":216368,"gasPrice":"1000000000","data":"0x4f15078700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f110000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a200000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b62eb7fe80350dc7ec945c0b73242cb9877fb1b0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000000000000004af4114f73d1c1c903ac9e0361b379d1291808a20000000000000000000000000d0f936ee4c93e25944694d6c121de94d9760f110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000a5ef5a7656bfb0000000000000000000000000000000000000000000000000000004ba78398d5c5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000166cfe0b9579b4ecf7a2801880f644009a324671a79754ea57c3a103c6e70d3dbef6ba69a08000000000000000000000000000000000000000000000000004f937d86afb90000000000000000000000000000000000000000000000000ab280fd8037d500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000166cfb784b7c1f3fbe8b75484603ab8adc58aaee3a46245a6579fac7077b5570018b4e0d4eb0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000308fd0e798ac00000000000000000000000000000000000000000000000006a8313d60b1f606b0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001b00000000000000000000000000000000000000000000000000000000000000029de0ccec59e8948e3d905b40e5542335ebc1eb4674db517d2f6392ec7fdeb3d45f3449d313ee2589819c6c79eb1c1b047adae68565c1608e3a1d1d70823febb0000000000000000000000000000000000000000000000000000000000000000234d06fe17f1202e8b07177a30eb64d14adc08cdb3fa1b3e3e0bea0f9672c02175b77c01c51d3c7e460723b27ecbc7801fd6482559a8c9999593f9a4d149c7384","parsedData":{"methodId":"0x4f150787","name":""}}}],"nonce":"123","tokens":[{"type":"ERC20","standard":"ERC20","name":"Contract 13","contract":"0x0d0F936Ee4c93e25944694D6C121de94D9760F11","transfers":1,"symbol":"S13","decimals":18,"balance":"1000123013"},{"type":"ERC721","standard":"ERC721","name":"Contract 205","contract":"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9","transfers":1,"symbol":"S205","decimals":18,"ids":["1"]},{"type":"ERC20","standard":"ERC20","name":"Contract 74","contract":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","transfers":1,"symbol":"S74","decimals":12,"balance":"1000123074"}],"addressAliases":{"0x7B62EB7fe80350DC7EC945C0B73242cb9877FB1b":{"Type":"ENS","Alias":"address7b.eth"},"0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9":{"Type":"Contract","Alias":"Contract 205"}}}`,
			},
		},
		{
			name:        "apiTx EthTxidB1T2",
			r:           newGetRequest(ts.URL + "/api/v2/tx/0x" + dbtestdata.EthTxidB1T2),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"txid":"0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101","vin":[{"n":0,"addresses":["0x20cD153de35D469BA46127A0C8F18626b59a256A"],"isAddress":true}],"vout":[{"value":"0","n":0,"addresses":["0x4af4114F73d1c1C903aC9E0361b379D1291808A2"],"isAddress":true}],"blockHeight":-1,"confirmations":0,"blockTime":0,"value":"0","fees":"2081000000000000","rbf":true,"coinSpecificData":{"tx":{"nonce":"0xd0","gasPrice":"0x9502f9000","maxPriorityFeePerGas":"0x9502f9001","maxFeePerGas":"0x9502f9002","baseFeePerGas":"0x9502f9003","gas":"0x130d5","to":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","value":"0x0","input":"0xa9059cbb000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f00000000000000000000000000000000000000000000021e19e0c9bab2400000","hash":"0xa9cd088aba2131000da6f38a33c20169baee476218deea6b78720700b895b101","blockNumber":"0x41eee8","from":"0x20cD153de35D469BA46127A0C8F18626b59a256A","transactionIndex":"0x0"},"internalData":{"type":0,"transfers":[{"type":1,"from":"9f4981531fda132e83c44680787dfa7ee31e4f8d","to":"4af4114f73d1c1c903ac9e0361b379d1291808a2","value":1000000},{"type":0,"from":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","to":"9f4981531fda132e83c44680787dfa7ee31e4f8d","value":1000001},{"type":0,"from":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","to":"3e3a3d69dc66ba10737f531ed088954a9ec89d97","value":1000002}],"Error":""},"receipt":{"gasUsed":"0xcb39","status":"0x1","logs":[{"address":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000020cd153de35d469ba46127a0c8f18626b59a256a","0x000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f"],"data":"0x00000000000000000000000000000000000000000000021e19e0c9bab2400000"}]}},"tokenTransfers":[{"type":"ERC20","standard":"ERC20","from":"0x20cD153de35D469BA46127A0C8F18626b59a256A","to":"0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f","contract":"0x4af4114F73d1c1C903aC9E0361b379D1291808A2","name":"Contract 74","symbol":"S74","decimals":12,"value":"10000000000000000000000"}],"ethereumSpecific":{"status":1,"nonce":208,"gasLimit":78037,"gasUsed":52025,"gasPrice":"40000000000","maxPriorityFeePerGas":"40000000001","maxFeePerGas":"40000000002","baseFeePerGas":"40000000003","data":"0xa9059cbb000000000000000000000000555ee11fbddc0e49a9bab358a8941ad95ffdb48f00000000000000000000000000000000000000000000021e19e0c9bab2400000","parsedData":{"methodId":"0xa9059cbb","name":"Transfer","function":"transfer(address, uint256)","params":[{"type":"address","values":["0x555Ee11FBDDc0E49A9bAB358A8941AD95fFDB48f"]},{"type":"uint256","values":["10000000000000000000000"]}]}},"addressAliases":{"0x20cD153de35D469BA46127A0C8F18626b59a256A":{"Type":"ENS","Alias":"address20.eth"},"0x4af4114F73d1c1C903aC9E0361b379D1291808A2":{"Type":"Contract","Alias":"Contract 74"}}}`,
			},
		},
		{
			name:        "apiFiatRates get rate by timestamp",
			r:           newGetRequest(ts.URL + "/api/v2/tickers?currency=usd&timestamp=1574340000"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"ts":1574380800,"rates":{"usd":7914.5}}`,
			},
		},
		{
			name:        "apiFiatRates get token rate by timestamp",
			r:           newGetRequest(ts.URL + "/api/v2/tickers?currency=usd&timestamp=1574340000&token=0xA4DD6Bc15Be95Af55f0447555c8b6aA3088562f3"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"ts":1574380800,"rates":{"usd":1.2}}`,
			},
		},
		{
			name:        "apiFiatRates get token rate by timestamp for all currencies",
			r:           newGetRequest(ts.URL + "/api/v2/tickers?timestamp=1574340000&token=0xA4DD6Bc15Be95Af55f0447555c8b6aA3088562f3"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"ts":1574380800,"rates":{"eur":1.0816754,"usd":1.2}}`,
			},
		},
		{
			name:        "apiFiatRates get token rate for unknown token by timestamp",
			r:           newGetRequest(ts.URL + "/api/v2/tickers?currency=usd&timestamp=1574340000&token=0xFFFFFFFFFFe95Af55f0447555c8b6aA3088562f3"),
			status:      http.StatusOK,
			contentType: "application/json; charset=utf-8",
			body: []string{
				`{"ts":1574340000,"rates":{"usd":-1}}`,
			},
		},
	}

	performHttpTests(tests, t, ts)
}

var websocketTestsEthereumType = []websocketTest{
	{
		name: "websocket getInfo",
		req: websocketReq{
			Method: "getInfo",
		},
		want: `{"id":"0","data":{"name":"Fakecoin","shortcut":"FAKE","network":"FAKE","decimals":18,"version":"unknown","bestHeight":4321001,"bestHash":"0x2b57e15e93a0ed197417a34c2498b7187df79099572c04a6b6e6ff418f74e6ee","block0Hash":"","testnet":true,"backend":{"version":"001001","subversion":"/Fakecoin:0.0.1/"}}}`,
	},
	{
		name: "websocket rpcCall",
		req: websocketReq{
			Method: "rpcCall",
			Params: WsRpcCallReq{
				To:   "0xcdA9FC258358EcaA88845f19Af595e908bb7EfE9",
				Data: "0x4567",
			},
		},
		want: `{"id":"1","data":{"data":"0x4567abcd"}}`,
	},
	{
		name: "websocket sendTransaction hex format",
		req: websocketReq{
			Method: "sendTransaction",
			Params: WsSendTransactionReq{
				Hex:                   "123456",
				DisableAlternativeRPC: true,
			},
		},
		want: `{"id":"2","data":{"result":"9876"}}`,
	},
}

func initEthereumTypeDB(d *db.RocksDB) error {
	// add 0xa9059cbb transfer(address,uint256)	signature
	wb := grocksdb.NewWriteBatch()
	defer wb.Destroy()
	if err := d.StoreFourByteSignature(wb, 2835717307, 145, &bchain.FourByteSignature{
		Name:       "transfer",
		Parameters: []string{"address", "uint256"},
	}); err != nil {
		return err
	}
	return d.WriteBatch(wb)
}

// initTestFiatRatesEthereumType initializes test data for /api/v2/tickers endpoint
func initTestFiatRatesEthereumType(d *db.RocksDB) error {
	if err := insertFiatRate("20180320000000", map[string]float32{
		"usd": 2000.0,
		"eur": 1300.0,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 2000.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 123.0,
	}, d); err != nil {
		return err
	}
	if err := insertFiatRate("20180321000000", map[string]float32{
		"usd": 2001.0,
		"eur": 1301.0,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 2001.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 199.0,
	}, d); err != nil {
		return err
	}
	if err := insertFiatRate("20180322000000", map[string]float32{
		"usd": 2002.0,
		"eur": 1302.0,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 2002.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 99.0,
	}, d); err != nil {
		return err
	}
	if err := insertFiatRate("20180323000000", map[string]float32{
		"usd": 2003.0,
		"eur": 1303.0,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 2003.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 101.0,
	}, d); err != nil {
		return err
	}
	if err := insertFiatRate("20190321000000", map[string]float32{
		"usd": 7814.5,
		"eur": 7100.0,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 7814.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 499.0,
		"0xa4dd6bc15be95af55f0447555c8b6aa3088562f3": 0.8,
	}, d); err != nil {
		return err
	}
	if err := insertFiatRate("20191122000000", map[string]float32{
		"usd": 7914.5,
		"eur": 7134.1,
	}, map[string]float32{
		"0xdac17f958d2ee523a2206206994597c13d831ec7": 7914.1,
		"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 599.0,
		"0xa4dd6bc15be95af55f0447555c8b6aa3088562f3": 1.2,
	}, d); err != nil {
		return err
	}

	return d.FiatRatesStoreSpecialTickers("CurrentTickers", &[]common.CurrencyRatesTicker{
		{
			Timestamp: time.Unix(1592821931, 0),
			Rates: map[string]float32{
				"usd": 8914.5,
				"eur": 8134.1,
			},
			TokenRates: map[string]float32{
				"0xdac17f958d2ee523a2206206994597c13d831ec7": 8914.1,
				"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": 899.0,
				"0xa4dd6bc15be95af55f0447555c8b6aa3088562f3": 8.2,
			},
		},
	})
}

func Test_PublicServer_EthereumType(t *testing.T) {
	timeNow = fixedTimeNow
	parser := eth.NewEthereumParser(1, true)
	chain, err := dbtestdata.NewFakeBlockChainEthereumType(parser)
	if err != nil {
		glog.Fatal("fakechain: ", err)
	}

	s, dbpath := setupPublicHTTPServer(parser, chain, t, false)
	defer closeAndDestroyPublicServer(t, s, dbpath)
	s.ConnectFullPublicInterface()
	// take the handler of the public server and pass it to the test server
	ts := httptest.NewServer(s.https.Handler)
	defer ts.Close()

	httpTestsEthereumType(t, ts)
	runWebsocketTests(t, ts, websocketTestsEthereumType)
}
