/*
Navicat MySQL Data Transfer

Source Server         : 123.56.5.114.master
Source Server Version : 50731
Source Host           : 123.56.5.114:13306
Source Database       : tron-explore

Target Server Type    : MYSQL
Target Server Version : 50731
File Encoding         : 65001

Date: 2020-11-11 16:22:22
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for `tron_address`
-- ----------------------------
DROP TABLE IF EXISTS `tron_address`;
CREATE TABLE `tron_address` (
  `address` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '账户地址',
  `balance` bigint(20) DEFAULT NULL COMMENT '余额',
  `frozen_balance` bigint(20) DEFAULT NULL COMMENT '冻结余额',
  PRIMARY KEY (`address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='账户地址表';

-- ----------------------------
-- Records of tron_address
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_block_day_census`
-- ----------------------------
DROP TABLE IF EXISTS `tron_block_day_census`;
CREATE TABLE `tron_block_day_census` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `gen_block_aver_time` bigint(20) NOT NULL COMMENT '生成区块的平均时间',
  `gen_block_total_num` int(11) NOT NULL COMMENT '生成区块总量',
  `total_volume` int(11) NOT NULL COMMENT '总交易量',
  `census_date` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '统计日期',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `total_block_bytes` int(11) NOT NULL COMMENT '总块大小',
  `aver_block_bytes` int(11) NOT NULL COMMENT '平均块大小',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='按天统计区块表';

-- ----------------------------
-- Records of tron_block_day_census
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_block_header`
-- ----------------------------
DROP TABLE IF EXISTS `tron_block_header`;
CREATE TABLE `tron_block_header` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `block_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '区块ID',
  `number` bigint(20) DEFAULT NULL COMMENT '区块高度',
  `tx_trie_root` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `witness_address` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parentHash` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父hash',
  `version` int(4) DEFAULT NULL COMMENT '版本号',
  `timestamp` bigint(20) DEFAULT NULL COMMENT '区块时间戳',
  `witness_signature` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transaction_volume` int(11) DEFAULT NULL COMMENT '交易量',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `block_bytes` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '块大小',
  PRIMARY KEY (`id`),
  KEY `block_id_idx` (`block_id`) USING BTREE,
  KEY `ts_idx` (`timestamp`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=21689 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='区块头信息表';

-- ----------------------------
-- Records of tron_block_header
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_last_block`
-- ----------------------------
DROP TABLE IF EXISTS `tron_last_block`;
CREATE TABLE `tron_last_block` (
  `id` bigint(20) NOT NULL,
  `cur_block_num` bigint(20) DEFAULT NULL COMMENT '已更新的区块高度',
  `last_block_num` bigint(20) DEFAULT NULL COMMENT '最新的区块高度',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of tron_last_block
-- ----------------------------
INSERT INTO `tron_last_block` VALUES ('1', '1', '1');

-- ----------------------------
-- Table structure for `tron_transaction`
-- ----------------------------
DROP TABLE IF EXISTS `tron_transaction`;
CREATE TABLE `tron_transaction` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `block_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '区块ID',
  `tx_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易ID',
  `contract_ret` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易结果',
  `owner_address` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易地址FROM',
  `data` text COLLATE utf8mb4_unicode_ci COMMENT '合约数据',
  `contract_address` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '合约地址',
  `amount` bigint(20) DEFAULT NULL COMMENT '交易额',
  `to_address` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易地址TO',
  `type_url` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ref_block_bytes` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ref_block_hash` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `expiration` bigint(20) DEFAULT NULL,
  `fee_limit` bigint(20) DEFAULT NULL,
  `timestamp` bigint(20) DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `number` bigint(20) DEFAULT NULL COMMENT '区块高度',
  PRIMARY KEY (`id`),
  KEY `block_id_idx` (`block_id`) USING BTREE,
  KEY `tx_id_idx` (`tx_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=23386 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='区块交易信息表';

-- ----------------------------
-- Records of tron_transaction
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_transaction_hex`
-- ----------------------------
DROP TABLE IF EXISTS `tron_transaction_hex`;
CREATE TABLE `tron_transaction_hex` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `hex` longtext COLLATE utf8mb4_unicode_ci,
  `block_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '区块ID',
  `tx_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易ID',
  `signature` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `tx_id_idx` (`tx_id`) USING BTREE,
  KEY `block_id_idx` (`block_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=23325 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='区块交易hex表';

-- ----------------------------
-- Records of tron_transaction_hex
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_census`
-- ----------------------------
DROP TABLE IF EXISTS `tron_census`;
CREATE TABLE `tron_census` (
                             `id` bigint(20) NOT NULL AUTO_INCREMENT,
                             `total_trans` bigint(20) DEFAULT NULL COMMENT '总交易数',
                             `total_block_size` bigint(20) DEFAULT NULL COMMENT '总区块大小',
                             `total_account` bigint(20) DEFAULT NULL COMMENT '总账户数',
                             PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='区块、交易、账户统计表';

-- ----------------------------
-- Records of tron_census
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_contract`
-- ----------------------------
DROP TABLE IF EXISTS `tron_contract`;
CREATE TABLE `tron_contract` (
                               `id` bigint(20) NOT NULL,
                               `bytecode` longtext,
                               `name` varchar(50) DEFAULT NULL COMMENT '名称',
                               `origin_address` varchar(64) DEFAULT NULL,
                               `abi` longtext,
                               `origin_energy_limit` bigint(20) DEFAULT NULL,
                               `contract_address` varchar(64) DEFAULT NULL COMMENT '合约地址',
                               `code_hash` varchar(100) DEFAULT NULL,
                               PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='合约表';

-- ----------------------------
-- Records of tron_contract
-- ----------------------------

-- ----------------------------
-- Table structure for `tron_solidity_version`
-- ----------------------------
DROP TABLE IF EXISTS `tron_solidity_version`;
CREATE TABLE `tron_solidity_version` (
                                       `id` bigint(20) NOT NULL,
                                       `version` varchar(50) DEFAULT NULL,
                                       PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='solidity版本号';

-- ----------------------------
-- Records of tron_solidity_version
-- ----------------------------
INSERT INTO `tron_solidity_version` VALUES ('1', 'solidity0.4.25+commit');
INSERT INTO `tron_solidity_version` VALUES ('2', 'solidity0.5.14+commit');
INSERT INTO `tron_solidity_version` VALUES ('3', 'solidity0.6.12+commit');
INSERT INTO `tron_solidity_version` VALUES ('4', 'solidity0.7.4+commit');
INSERT INTO `tron_solidity_version` VALUES ('5', 'solidity0.8.0-nightly');

-- ----------------------------
-- Table structure for `tron_contract_event`
-- ----------------------------
DROP TABLE IF EXISTS `tron_contract_event`;
CREATE TABLE `tron_contract_event` (
                                     `id` bigint(20) NOT NULL AUTO_INCREMENT,
                                     `caller_contract_address` varchar(36) DEFAULT NULL,
                                     `result` varchar(500) DEFAULT NULL,
                                     `transaction_id` varchar(100) DEFAULT NULL,
                                     `result_type` varchar(500) DEFAULT NULL,
                                     `block_timestamp` bigint(20) DEFAULT NULL,
                                     `block_number` int(11) DEFAULT NULL,
                                     `event_name` varchar(50) DEFAULT NULL,
                                     `contract_address` varchar(36) DEFAULT NULL,
                                     `event_index` int(11) DEFAULT NULL,
                                     PRIMARY KEY (`id`),
                                     KEY `con_addr_idx` (`contract_address`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=18391 DEFAULT CHARSET=utf8mb4 COMMENT='合约事件表';

-- ----------------------------
-- Records of tron_contract_event
-- ----------------------------
