diff --git a/shyftBlockExplorerUI/src/components/nav/accountHeaders/accountDetailHeader.js b/shyftBlockExplorerUI/src/components/nav/accountHeaders/accountDetailHeader.js
index 097c84d2ea..3f6de31bad 100644
--- a/shyftBlockExplorerUI/src/components/nav/accountHeaders/accountDetailHeader.js
+++ b/shyftBlockExplorerUI/src/components/nav/accountHeaders/accountDetailHeader.js
@@ -2,11 +2,15 @@ import React from 'react';
import classes from '../nav.css';
const accountsDetailHeader = (props) => {
+ const total = props.data
+ .map(num => Number(num.Amount) / 10000000000000000000)
+ .reduce((acc, cur) => acc + cur ,0);
return (
Account# {props.addr}
+ Total Value: {total}
)
-}
+};
export default accountsDetailHeader;
\ No newline at end of file
diff --git a/shyftBlockExplorerUI/src/components/nav/blockHeaders/blockCoinbaseHeader.js b/shyftBlockExplorerUI/src/components/nav/blockHeaders/blockCoinbaseHeader.js
new file mode 100644
index 0000000000..7c629ba580
--- /dev/null
+++ b/shyftBlockExplorerUI/src/components/nav/blockHeaders/blockCoinbaseHeader.js
@@ -0,0 +1,12 @@
+import React from 'react';
+import classes from '../nav.css';
+
+const blocksCoinbaseHeader = (props) => {
+ return (
+
+ Coinbase: {props.coinbase}
+
+ )
+};
+
+export default blocksCoinbaseHeader;
\ No newline at end of file
diff --git a/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js b/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js
index 99db9d6dbe..ecb160a04b 100644
--- a/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js
+++ b/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js
@@ -21,15 +21,27 @@ class AccountTable extends Component {
}
render() {
- const table = this.state.data.map((data, i) => {
+
+ let startNum = 1;
+ const sorted = [...this.state.data];
+ sorted.sort((a, b) => Number(a.Balance) > Number(b.Balance));
+ console.log(sorted);
+ const table = sorted.reverse().map((data, i) => {
+ const conversion = Number(data.Balance) / 10000000000000000000;
+ const total = sorted
+ .map(num => Number(num.Balance) / 10000000000000000000)
+ .reduce((acc, cur) => acc + cur ,0);
+ const percentage = ( (conversion / total) *100);
return
- })
+ });
let combinedClasses = ['responsive-table', classes.table];
return (
diff --git a/shyftBlockExplorerUI/src/components/table/accounts/accountsTable.js b/shyftBlockExplorerUI/src/components/table/accounts/accountsTable.js
index 152dde6c42..62451059dd 100644
--- a/shyftBlockExplorerUI/src/components/table/accounts/accountsTable.js
+++ b/shyftBlockExplorerUI/src/components/table/accounts/accountsTable.js
@@ -6,16 +6,16 @@ const AccountsTable = (props) => {
return (
- | 1 |
+ {props.Rank} |
props.detailAccountHandler(props.Addr)}>
{props.Addr}
|
{props.Balance} |
- 12.01% |
+ {props.Percentage}% |
{props.TxCountAccount} |
)
-}
+};
export default AccountsTable;
diff --git a/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsRow.js b/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsRow.js
index cec0b9e8de..98ccdf8d27 100644
--- a/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsRow.js
+++ b/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsRow.js
@@ -10,6 +10,8 @@ class AccountTransactionTable extends Component {
return
}else {
table = this.props.data.map((data, i) => {
+ const costConversion = data.Cost / 10000000000000000000;
+ const amountConversion = data.Amount / 10000000000000000000;
return
diff --git a/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsTable.js b/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsTable.js
index 4b7cedb9d1..3164b7c164 100644
--- a/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsTable.js
+++ b/shyftBlockExplorerUI/src/components/table/accounts/detailAccountsTable.js
@@ -9,11 +9,17 @@ const DetailAccountsTable = (props) => {
}else {
flag = false
}
+ let genFlag;
+ if(props.txHash.indexOf("GENESIS") !== -1) {
+ genFlag = false
+ }else {
+ genFlag = true
+ }
return (
|
- props.detailTransactionHandler(props.txHash)}>
+ props.detailTransactionHandler(props.txHash)}>
{props.txHash}
|
{props.blockNumber} |
@@ -26,6 +32,6 @@ const DetailAccountsTable = (props) => {
)
-}
+};
export default DetailAccountsTable;
diff --git a/shyftBlockExplorerUI/src/components/table/accounts/table.css b/shyftBlockExplorerUI/src/components/table/accounts/table.css
index 0dd7b521e7..e191b21ee3 100644
--- a/shyftBlockExplorerUI/src/components/table/accounts/table.css
+++ b/shyftBlockExplorerUI/src/components/table/accounts/table.css
@@ -77,4 +77,9 @@ th {
text-transform: uppercase;
text-align: center;
vertical-align: middle;
+}
+
+.disabled {
+ pointer-events: none;
+ color: black;
}
\ No newline at end of file
diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js
index 900f3cf1d5..378e48ecfb 100644
--- a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js
+++ b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import BlockTable from './blockTable';
+import Loading from '../../UI materials/loading'
import classes from './table.css';
import axios from "axios/index";
@@ -13,7 +14,7 @@ class BlocksTable extends Component {
async componentDidMount() {
try {
- const response = await axios.get("http://localhost:8080/api/get_all_blocks")
+ const response = await axios.get("http://localhost:8080/api/get_all_blocks");
await this.setState({data: response.data});
} catch (err) {
console.log(err);
@@ -23,6 +24,7 @@ class BlocksTable extends Component {
render() {
const table = this.state.data.map((data, i) => {
+ const conversion = data.Rewards / 10000000000000000000;
return
- })
+ });
let combinedClasses = ['responsive-table', classes.table];
return (
@@ -54,7 +58,7 @@ class BlocksTable extends Component {
Reward |
- {table}
+ {table}
);
}
diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js b/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js
index aa66bee9f2..0f0a025832 100644
--- a/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js
+++ b/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js
@@ -13,11 +13,11 @@ const BlockTable = (props) => {
{props.Age} |
{props.TxCount} |
{props.UncleCount} |
-
{props.Coinbase} |
+
props.getBlocksMined(props.Coinbase)}>{props.Coinbase} |
{props.GasUsed} |
{props.GasLimit} |
-
12.01 |
-
3.2 |
+
TBD |
+
{props.Reward} |
)
diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js
index dc881a5b9c..12d06bc0b6 100644
--- a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js
+++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js
@@ -1,10 +1,11 @@
import React, { Component } from 'react';
import classes from './table.css';
+import { Link } from 'react-router-dom'
class DetailBlockTable extends Component {
render() {
- let data = this.props.data
+ let data = this.props.data;
let combinedClasses = ['responsive-table', classes.table];
return (
@@ -19,7 +20,7 @@ class DetailBlockTable extends Component {
| Txn: |
- {data.TxCount} transactions |
+ this.props.getBlockTransactions(data.Number)}>{data.TxCount} transactions |
| Block Hash: |
@@ -67,7 +68,7 @@ class DetailBlockTable extends Component {
| Reward: |
- TBD |
+ {data.Rewards} |
diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksMined.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksMined.js
new file mode 100644
index 0000000000..782da7fe42
--- /dev/null
+++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksMined.js
@@ -0,0 +1,55 @@
+import React, { Component } from 'react';
+import MinedBlockTable from './blocksMinedTable';
+import Loading from '../../UI materials/loading'
+import classes from './table.css';
+
+class BlocksMinedTable extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: []
+ };
+ }
+
+ render() {
+ const table = this.props.data.map((data, i) => {
+ const conversion = data.Rewards / 10000000000000000000;
+ return
+ });
+
+ let combinedClasses = ['responsive-table', classes.table];
+ return (
+
+
+
+ | Height |
+ Block Hash |
+ Age |
+ Txn |
+ Uncles |
+ Coinbase |
+ GasUsed |
+ GasLimit |
+ Avg.GasPrice |
+ Reward |
+
+
+ {table}
+
+ );
+ }
+}
+export default BlocksMinedTable;
diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksMinedTable.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksMinedTable.js
new file mode 100644
index 0000000000..503dc9322c
--- /dev/null
+++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksMinedTable.js
@@ -0,0 +1,26 @@
+import React from 'react';
+import classes from './table.css';
+import { Link } from 'react-router-dom'
+
+const MinedBlockTable = (props) => {
+ return (
+
+
+ | props.detailBlockHandler(props.Number)}>
+ {props.Number}
+ |
+ {props.Hash} |
+ {props.Age} |
+ {props.TxCount} |
+ {props.UncleCount} |
+ {props.Coinbase} |
+ {props.GasUsed} |
+ {props.GasLimit} |
+ TBD |
+ {props.Reward} |
+
+
+ )
+};
+
+export default MinedBlockTable;
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js b/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js
new file mode 100644
index 0000000000..afdfd709b7
--- /dev/null
+++ b/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js
@@ -0,0 +1,51 @@
+import React, { Component } from 'react';
+import TransactionsTable from './transactionTable';
+import classes from './table.css';
+
+class BlockTransactionTable extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: []
+ };
+ }
+
+ render() {
+ const table = this.props.data.map((data, i) => {
+ const conversion = data.Cost / 10000000000000000000;
+ return
+ })
+
+ let combinedClasses = ['responsive-table', classes.table];
+ return (
+
+
+
+ | TxHash |
+ Block |
+ Age |
+ From |
+ |
+ To |
+ Value |
+ TxFee |
+
+
+ {table}
+
+ );
+ }
+}
+export default BlockTransactionTable;
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js
index 889bb3e33f..e130feb577 100644
--- a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js
+++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js
@@ -6,6 +6,7 @@ class DetailTransactionTable extends Component {
render() {
let data = this.props.data
let combinedClasses = ['responsive-table', classes.table];
+ const conversion = data.Cost / 10000000000000000000;
return (
@@ -51,7 +52,7 @@ class DetailTransactionTable extends Component {
| Actual Tx Cost/Fee: |
- {data.Cost} |
+ {conversion} |
| Nonce: |
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js
index 76bd341d5c..af3f4f0b94 100644
--- a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js
+++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js
@@ -25,6 +25,7 @@ class TransactionTable extends Component {
render() {
const table = this.state.data.map((data, i) => {
+ const conversion = data.Cost / 10000000000000000000;
return
})
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js
index a4b399efc5..71ea807e01 100644
--- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js
+++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js
@@ -5,7 +5,7 @@ import { Link } from 'react-router-dom'
const TransactionTable = (props) => {
let flag;
- if(props.txHash.indexOf("GENESIS") != -1) {
+ if(props.txHash.indexOf("GENESIS") !== -1) {
flag = false
}else {
flag = true
@@ -18,11 +18,11 @@ const TransactionTable = (props) => {
props.detailTransactionHandler(props.txHash)}>
{props.txHash}
- {props.blockNumber} |
+ props.getBlockTransactions(props.blockNumber)}>{props.blockNumber} |
{props.age} |
- {props.from} |
+ props.detailAccountHandler(props.from)}>{props.from} |
 |
- {props.to} |
+ props.detailAccountHandler(props.to)}>{props.to} |
{props.value} |
{props.cost} |
diff --git a/shyftBlockExplorerUI/src/containers/App.js b/shyftBlockExplorerUI/src/containers/App.js
index f1561f6f63..043f430d14 100644
--- a/shyftBlockExplorerUI/src/containers/App.js
+++ b/shyftBlockExplorerUI/src/containers/App.js
@@ -11,12 +11,15 @@ import TransactionRow from '../components/table/transactions/transactionRow';
import TransactionHeader from "../components/nav/transactionHeader/transactionHeader";
import TransactionDetailHeader from "../components/nav/transactionHeader/transactionDetailHeader";
import DetailTransactionTable from "../components/table/transactions/transactionDetailsRow";
+import BlockTxs from "../components/table/transactions/blockTx";
+
///**BLOCKS**///
import BlocksRow from '../components/table/blocks/blockRows';
import DetailBlockTable from '../components/table/blocks/blocksDetailsRow';
import BlockDetailHeader from "../components/nav/blockHeaders/blockDetailHeader";
import BlockHeader from "../components/nav/blockHeaders/blockHeader";
-
+import BlocksMinedTable from "../components/table/blocks/blocksMined";
+import BlockCoinbaseHeader from "../components/nav/blockHeaders/blockCoinbaseHeader";
///**ACCOUNTS**///
import AccountsRow from '../components/table/accounts/accountRows';
import DetailAccountsTable from "../components/table/accounts/detailAccountsRow";
@@ -31,6 +34,8 @@ class App extends Component {
blockDetailData: [],
transactionDetailData: [],
accountDetailData: [],
+ blocksMined: [],
+ blockTransactions: [],
reqAccount: ''
};
}
@@ -43,7 +48,7 @@ class App extends Component {
catch(error) {
console.log(error)
}
- }
+ };
detailTransactionHandler = async(txHash) => {
try {
@@ -53,7 +58,7 @@ class App extends Component {
catch(error) {
console.log(error)
}
- }
+ };
detailAccountHandler = async(addr) => {
try {
@@ -63,7 +68,27 @@ class App extends Component {
catch(error) {
console.log(error)
}
- }
+ };
+
+ getBlockTransactions = async(blockNumber) => {
+ try {
+ const response = await axios.get(`http://localhost:8080/api/get_all_transactions_from_block/${blockNumber}`)
+ await this.setState({ blockTransactions: response.data, reqBlockNum: blockNumber })
+ }
+ catch(error) {
+ console.log(error)
+ }
+ };
+
+ getBlocksMined = async(coinbase) => {
+ try {
+ const response = await axios.get(`http://localhost:8080/api/get_blocks_mined/${coinbase}`)
+ await this.setState({ blocksMined: response.data, reqCoinbase: coinbase })
+ }
+ catch(error) {
+ console.log(error)
+ }
+ };
render() {
return (
@@ -78,14 +103,20 @@ class App extends Component {
-
+
}
/>
-
+
}
/>
@@ -110,14 +141,40 @@ class App extends Component {
}
/>
+
+
+
+
+
+
}
+ />
+
+
+
+
+
+
}
+ />
+
+ addr={this.state.reqAccount}
+ data={this.state.accountDetailData}/>
0 {
for _, tx := range block.Transactions() {
- //WriteMinerRewards(sqldb, block)
WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit)
if block.Transactions()[0].To() != nil {
WriteFromBalance(sqldb, tx)
@@ -411,7 +406,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
// uncle blocks, account balance updates based on reorgs, diverges that get dropped.
// Reason for this is because the accounts are not deterministic like the block and tx hashes.
// @TODO: Calculate reorg
-func WriteMinerRewards(sqldb *sql.DB, block *types.Block) {
+func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string {
minerAddr := block.Coinbase().String()
shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String()
// Calculate the total gas used in the block
@@ -443,9 +438,18 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) {
StoreReward(sqldb, minerAddr, totalMinerReward)
StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward)
+ var uncRewards = new(big.Int)
for i := 0; i < len(uncleAddrs); i++ {
+ uncRewards := uncleRewards[i]
+ fmt.Println(uncRewards)
StoreReward(sqldb, uncleAddrs[i], uncleRewards[i])
}
+
+ fullRewardValue := new(big.Int)
+ fullRewardValue.Add(totalMinerReward, Rewards.ShyftNetworkBlockReward)
+ fullRewardValue.Add(fullRewardValue, uncRewards)
+
+ return fullRewardValue.String()
}
func StoreReward(sqldb *sql.DB, address string, reward *big.Int) {
@@ -497,16 +501,7 @@ func GetAllBlocks(sqldb *sql.DB) string {
var arr blockRes
var blockArr string
rows, err := sqldb.Query(`
- SELECT
- hash,
- coinbase,
- gasused,
- gaslimit,
- txcount,
- unclecount,
- age,
- number
- FROM blocks`)
+ SELECT * FROM blocks`)
if err != nil {
fmt.Println("err")
}
@@ -520,6 +515,12 @@ func GetAllBlocks(sqldb *sql.DB) string {
var txCount string
var uncleCount string
var age string
+ var parentHash string
+ var uncleHash string
+ var difficulty string
+ var size string
+ var nonce string
+ var rewards string
var num string
err = rows.Scan(
@@ -530,8 +531,13 @@ func GetAllBlocks(sqldb *sql.DB) string {
&txCount,
&uncleCount,
&age,
- &num,
- )
+ &parentHash,
+ &uncleHash,
+ &difficulty,
+ &size,
+ &nonce,
+ &rewards,
+ &num,)
arr.Blocks = append(arr.Blocks, SBlock{
Hash: hash,
@@ -541,6 +547,12 @@ func GetAllBlocks(sqldb *sql.DB) string {
TxCount: txCount,
UncleCount: uncleCount,
Age: age,
+ ParentHash:parentHash,
+ UncleHash:uncleHash,
+ Difficulty:difficulty,
+ Size: size,
+ Nonce:nonce,
+ Rewards: rewards,
Number: num,
})
@@ -568,6 +580,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
var difficulty string
var size string
var nonce string
+ var rewards string
var num string
row.Scan(
&hash,
@@ -582,6 +595,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
&difficulty,
&size,
&nonce,
+ &rewards,
&num,)
block := SBlock{
@@ -597,6 +611,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string {
Difficulty:difficulty,
Size: size,
Nonce:nonce,
+ Rewards: rewards,
Number: num,
}
json, _ := json.Marshal(block)
@@ -618,6 +633,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
var difficulty string
var size string
var nonce string
+ var rewards string
var num string
row.Scan(
&hash,
@@ -632,6 +648,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
&difficulty,
&size,
&nonce,
+ &rewards,
&num,)
block := SBlock{
@@ -647,6 +664,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
Difficulty:difficulty,
Size: size,
Nonce:nonce,
+ Rewards: rewards,
Number: num,
}
json, _ := json.Marshal(block)
@@ -656,7 +674,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
var arr txRes
var txx string
- sqlStatement := `SELECT * FROM txs WHERE blockNumber=$1`
+ sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1`
rows, err := sqldb.Query(sqlStatement, blockNumber)
if err != nil {
fmt.Println("err")
@@ -668,10 +686,10 @@ func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
var from_addr string
var blockhash string
var blocknumber string
- var amount uint64
+ var amount string
var gasprice uint64
var gas uint64
- var gasLimit uint64
+ var gasLimit string
var txfee uint64
var nonce uint64
var status string
@@ -721,6 +739,72 @@ func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
return txx
}
+func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
+ var arr blockRes
+ var blockArr string
+ sqlStatement := `SELECT * FROM blocks WHERE coinbase=$1`
+ rows, err := sqldb.Query(sqlStatement, coinbase)
+ if err != nil {
+ fmt.Println("err")
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var hash string
+ var coinbase string
+ var gasUsed string
+ var gasLimit string
+ var txCount string
+ var uncleCount string
+ var age string
+ var parentHash string
+ var uncleHash string
+ var difficulty string
+ var size string
+ var nonce string
+ var rewards string
+ var num string
+
+ err = rows.Scan(
+ &hash,
+ &coinbase,
+ &gasUsed,
+ &gasLimit,
+ &txCount,
+ &uncleCount,
+ &age,
+ &parentHash,
+ &uncleHash,
+ &difficulty,
+ &size,
+ &nonce,
+ &rewards,
+ &num,)
+
+ arr.Blocks = append(arr.Blocks, SBlock{
+ Hash: hash,
+ Coinbase: coinbase,
+ GasUsed: gasUsed,
+ GasLimit: gasLimit,
+ TxCount: txCount,
+ UncleCount: uncleCount,
+ Age: age,
+ ParentHash:parentHash,
+ UncleHash:uncleHash,
+ Difficulty:difficulty,
+ Size: size,
+ Nonce:nonce,
+ Rewards: rewards,
+ Number: num,
+ })
+
+ blocks, _ := json.Marshal(arr.Blocks)
+ blocksFmt := string(blocks)
+ blockArr = blocksFmt
+ }
+ return blockArr
+}
+
//GetAllTransactions getter fn for API
func GetAllTransactions(sqldb *sql.DB) string {
var arr txRes
@@ -737,10 +821,10 @@ func GetAllTransactions(sqldb *sql.DB) string {
var from_addr string
var blockhash string
var blocknumber string
- var amount uint64
+ var amount string
var gasprice uint64
var gas uint64
- var gasLimit uint64
+ var gasLimit string
var txfee uint64
var nonce uint64
var status string
@@ -799,10 +883,10 @@ func GetTransaction(sqldb *sql.DB, txHash string) string {
var from_addr string
var blockhash string
var blocknumber string
- var amount uint64
+ var amount string
var gasprice uint64
var gas uint64
- var gasLimit uint64
+ var gasLimit string
var txfee uint64
var nonce uint64
var status string
@@ -924,10 +1008,10 @@ func GetAccountTxs(sqldb *sql.DB, address string) string {
var from_addr string
var blockhash string
var blocknumber string
- var amount uint64
+ var amount string
var gasprice uint64
var gas uint64
- var gasLimit uint64
+ var gasLimit string
var txfee uint64
var nonce uint64
var status string
diff --git a/simulations/token_test/README.md b/simulations/token_test/README.md
new file mode 100644
index 0000000000..1160be7a88
--- /dev/null
+++ b/simulations/token_test/README.md
@@ -0,0 +1,9 @@
+`npm install`
+run `node deploy.js` to deploy the contract.
+
+this will log out a contract in the geth logs.
+
+set the ADDR environment variable to this contract address.
+ie `export ADDR=`
+
+then run `node calltx.js`
diff --git a/simulations/token_test/calltx.js b/simulations/token_test/calltx.js
new file mode 100644
index 0000000000..f5b5896bd9
--- /dev/null
+++ b/simulations/token_test/calltx.js
@@ -0,0 +1,9 @@
+var Web3 = require('web3')
+var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
+var contract_address = process.env.ADDR
+
+var mytokenContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]).at(contract_address)
+
+console.log(mytokenContract.balanceOf('0x43EC6d0942f7fAeF069F7F63D0384a27f529B062'))
+
+mytokenContract.transfer.sendTransaction('0x9e602164C5826ebb5A6B68E4AFD9Cd466043dc4A', 3, {from: '0x43EC6d0942f7fAeF069F7F63D0384a27f529B062', gas: 3000000})
diff --git a/simulations/token_test/deploy.js b/simulations/token_test/deploy.js
new file mode 100644
index 0000000000..65290fec83
--- /dev/null
+++ b/simulations/token_test/deploy.js
@@ -0,0 +1,17 @@
+var Web3 = require('web3')
+var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
+
+var initialSupply = 50000
+var mytokenContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);
+var mytoken = mytokenContract.new(
+ initialSupply,
+ {
+ from: web3.eth.accounts[0],
+ data: '0x608060405234801561001057600080fd5b5060405160208061033583398101806040528101908080519060200190929190505050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550506102af806100866000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806370a0823114610051578063a9059cbb146100a8575b600080fd5b34801561005d57600080fd5b50610092600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100f5565b6040518082815260200191505060405180910390f35b3480156100b457600080fd5b506100f3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061010d565b005b60006020528060005260406000206000915090505481565b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561015a57600080fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156101e757600080fd5b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555050505600a165627a7a72305820c12ed9899b0830fb3b1c8938b12a5e3ee651fb5e6febea7863ea990d72ab04420029',
+ gas: '4700000'
+ }, function (e, contract){
+ console.log(e, contract);
+ if (typeof contract.address !== 'undefined') {
+ console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
+ }
+ })
diff --git a/simulations/token_test/package.json b/simulations/token_test/package.json
new file mode 100644
index 0000000000..f91a027ade
--- /dev/null
+++ b/simulations/token_test/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "token_contract",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "web3": "^0.20.5"
+ }
+}
diff --git a/simulations/token_test/token.sol b/simulations/token_test/token.sol
new file mode 100644
index 0000000000..704e809d2a
--- /dev/null
+++ b/simulations/token_test/token.sol
@@ -0,0 +1,21 @@
+pragma solidity ^0.4.20;
+
+contract MyToken {
+ /* This creates an array with all balances */
+ mapping (address => uint256) public balanceOf;
+
+ /* Initializes contract with initial supply tokens to the creator of the contract */
+ function MyToken(
+ uint256 initialSupply
+ ) public {
+ balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
+ }
+
+ /* Send coins */
+ function transfer(address _to, uint256 _value) public {
+ require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
+ require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
+ balanceOf[msg.sender] -= _value; // Subtract from the sender
+ balanceOf[_to] += _value; // Add the same to the recipient
+ }
+}