### Setup Theta Backend API Application Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Sets up and starts the backend API microservice for the Theta explorer. This involves navigating to the API directory, installing Node.js dependencies, creating a configuration file, and running the application. The API typically runs on https://localhost:8443. ```shell cd backend/explorer-api npm install mv config.cfg.template config.cfg node run ``` -------------------------------- ### Setup Theta Frontend Web Application Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Prepares the frontend web application for development. This includes installing Node.js dependencies and creating a configuration file from a template. The frontend requires Node.js and npm. ```shell cd frontend npm install mv src/config.js.template src/config.js ``` -------------------------------- ### Start MongoDB Service Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Starts the MongoDB daemon service on Ubuntu Linux. This command is used after installing MongoDB to ensure the database is running and accessible for the crawler. ```shell sudo systemctl start mongod ``` -------------------------------- ### Setup Theta Blockchain Data Crawler Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Configures and prepares the blockchain data crawler. This includes navigating to the crawler directory, installing Node.js dependencies, and creating a configuration file from a template. The crawler requires Node.js and npm. ```shell cd backend/crawler npm install mv config.cfg.template config.cfg ``` -------------------------------- ### Smart Contract Verification Request Example Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Example of a cURL request to verify a smart contract, demonstrating the required parameters and data format. ```shell curl -X POST https://explorer-api.thetatoken.org/api/smartcontract/verify/0xb464bcdc89570eb7fac1f546703396f49a6ba24d \ -H "Content-Type: application/json" \ -d '{ "abi": "", "evm": "default", "optimizer": "0", "optimizerRuns": "200", "sourceCode": "pragma solidity ^0.7.4;\n\ncontract SquareCalculator {\n event SetValue(uint val);\n \n uint public value;\n \n function setValue(uint val) public {\n value = val;\n emit SetValue(val);\n }\n \n function CalculateSquare() view public returns (uint) {\n uint sqr = value * value;\n assert(sqr / value == value); // overflow protection\n return sqr;\n }\n}", "version": "0.7.4", "versionFullName": "soljson-v0.7.4+commit.3f05b770.js", "viaIR": "false" }' ``` -------------------------------- ### Install MongoDB on Ubuntu Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Installs MongoDB version 4.4 on Ubuntu Linux. This involves adding the MongoDB repository, updating the package list, and installing the mongodb-org package. It's a prerequisite for the blockchain data crawler. ```bash wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list sudo apt-get update sudo apt-get install -y mongodb-org ``` -------------------------------- ### Develop Theta Frontend with Live Reloading Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Starts the frontend development server with live reloading enabled. This command, along with 'gulp', allows for automatic browser refreshes upon changes to SCSS or JS files. The application is typically accessible at https://localhost:3000. ```javascript npm run dev gulp (in a new console window) ``` -------------------------------- ### Get Account Details API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Fetches detailed information for a given account address. Returns account address, balance, reserved funds, sequence number, and transaction counters. ```APIDOC APIDOC REST Uri: /account/:address Query Parameters: - address: The address of the account to query. Returns: - address: The account address. - balance: Native token balance (e.g., thetawei, tfuelwei). - reserved_funds: Funds reserved for off-chain micropayments. - sequence: The current sequence number of the account. - txs_counter: A map of transaction types and their counts involving this account. ``` ```bash curl https://explorer-api.thetatoken.org/api/account/0x3c6D5ED0353c22c31c5F91688A9D10E7Af2DF636 ``` -------------------------------- ### Run Theta Blockchain Data Crawler Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Executes the blockchain data crawler using Node.js. The crawler reads data from the blockchain, transforms it, and stores it in MongoDB. Ensure the config.cfg file is updated with the correct blockchain start height before running. ```shell node run.js ``` -------------------------------- ### Get Smart Contract Details Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves detailed information for a smart contract based on its blockchain address. This includes ABI, bytecode, compiler details, source code, and more. The API is accessed via a RESTful URI. ```APIDOC GetSmartContract API REST Uri: /smartContract/:address This API returns the details of the smart contract being queried with address. Query Parameters: - address (string): The smart contract address. Returns: - abi (array): The Application Binary Interface (ABI) of the smart contract. - address (string): The unique blockchain address where the smart contract is deployed. - bytecode (string): The compiled bytecode of the smart contract. - compiler_version (string): The version of the compiler used to compile the smart contract's source code into bytecode. - constructor_arguments (string): The arguments passed to the smart contract’s constructor during deployment. - function_hash (object): The hash of a specific function within the smart contract, e.g., {"CalculateSquare()": "b5a0241a"}. - name (string): The name of the smart contract as specified in the source code. - optimizer (string): Indicates whether optimization was used during the compilation process (e.g., "disabled"). - optimizerRuns (integer): The number of optimization runs configured for the compiler. - source_code (string): The original source code of the smart contract written in Solidity. - verification_date (integer): The date (timestamp) when the smart contract’s source code was verified on the blockchain explorer. - evm (string): The Ethereum Virtual Machine (EVM) version that the smart contract is compatible with. - viaIR (boolean): Indicates whether the smart contract was compiled using an intermediate representation (IR). Example: // Request curl https://explorer-api.thetatoken.org/api/smartcontract/0xb464bcdc89570eb7fac1f546703396f49a6ba24d // Result { "type": "token_info", "body": { "abi": [ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "val", "type": "uint256" } ], "name": "SetValue", "type": "event" }, { "inputs": [], "name": "CalculateSquare", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" },... ], "address": "0xb464bcdc89570eb7fac1f546703396f49a6ba24d", "bytecode": "YIBgQFI0gBVhABBXYACA/VtQYQFWgGEAIGAAOWAA8/5ggGBAUjSAFWEAEFdgAID9W1BgBDYQYQBBV2AANWDgHIBjP6TyRRRhAEZXgGNVJBB3FGEAZFeAY7WgJBoUYQCSV1tgAID9W2EATmEAsFZbYEBRgIKBUmAgAZFQUGBAUYCRA5DzW2EAkGAEgDYDYCCBEBVhAHpXYACA/VuBAZCAgDWQYCABkJKRkFBQUGEAtlZbAFthAJphAPdWW2BAUYCCgVJgIAGRUFBgQFGAkQOQ81tgAFSBVluAYACBkFVQf+2LBwZe8HN8DPsb8eI8zIgdeX7JgE90Iwo2C4SYKTirgWBAUYCCgVJgIAGRUFBgQFGAkQOQoVBWW2AAgGAAVGAAVAKQUGAAVGAAVIKBYQERV/5bBBRhARlX/luAkVBQkFb+omRpcGZzWCISIJ+8GVNMCLRKEZ1Wb0J8Ad5UjUomo7wv9aDzGTh69fRvZHNvbGNDAAcEADM=", "compiler_version": "v0.7.4+commit.3f05b770", "constructor_arguments": "", "function_hash": { "CalculateSquare()": "b5a0241a", "setValue(uint256)": "55241077", "value()": "3fa4f245" }, "name": "SquareCalculator", "optimizer": "disabled", "source_code": "/**\n *Submitted for verification at thetatoken.org on 2020-12-16\n */\npragma solidity ^0.7.4;\n\ncontract SquareCalculator {\n event SetValue(uint val);\n \n uint public value;\n \n function setValue(uint val) public {\n value = val;\n emit SetValue(val);\n }\n \n function CalculateSquare() view public returns (uint) {\n uint sqr = value * value;\n assert(sqr / value == value); // overflow protection\n return sqr;\n }\n}", "verification_date": 1608159599911 } } ``` -------------------------------- ### Get Transactions by Block Range API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves a list of transactions within a specified block range. Requires start and end block heights. Returns a transaction list similar to GetTransaction API. ```APIDOC APIDOC REST Uri: /trancastions/blockRange Query Parameters: - blockStart: The lowest block height to query. - blockEnd: The highest block height to query. Returns: A list of transactions, structured similarly to the GetTransaction API response. ``` ```bash curl https://explorer-api.thetatoken.org/api/transactions/blockRange?blockStart=1&blockEnd=10 ``` -------------------------------- ### Get Token Summary API - APIDOC Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves summary information for a specific token, including its contract address, holder count, total supply, name, total transfers, and type. Requires the token's smart contract address as a path parameter. ```APIDOC GetTokenSummary: Description: This API returns the summary info of one token. REST Uri: /tokenSummary/:address Parameters: address: Type: string Description: The token's smart contract address. Returns: contract_address: The contract address of the token holders: The total number of the token holders max_total_supply: The total supply of the token name: The name of the token total_transfers: The total transactions number of the token type: The type of the token (TNT-20/TNT-721) Example: Request: curl https://explorer-api.thetatoken.org/api/tokenSummary/0x5d0004fe2e0ec6d002678c7fa01026cabde9e793 Result: { "type": "token_info", "body": { contract_address: "0x5d0004fe2e0ec6d002678c7fa01026cabde9e793", holders: 837, max_total_supply: "2903", name: "TPMC Egg", total_transfers: 3207, type: "TNT-721" } } ``` -------------------------------- ### Get Account Transaction History API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves the transaction history for a specified account address, with options to filter by transaction type. Supports pagination. ```APIDOC APIDOC REST Uri: /accountTx/:address Query Parameters: - address: The address of the account. - type: Type of the transaction (refer to Transaction Types). - isEqualType: `true` to include only the specified type, `false` to exclude. - pageNumber: The page number for pagination. - limitNumber: The number of items per page. Returns: - currentPageNumber: The current page number. - totalPageNumber: The total number of pages. - body: A list of transactions, similar to GetTransaction API. ``` ```bash curl "https://explorer-api.thetatoken.org/api/accounttx/0x3c6D5ED0353c22c31c5F91688A9D10E7Af2DF636?type=2&pageNumber=1&limitNumber=50&isEqualType=true" ``` -------------------------------- ### Get Top Token Holders API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Fetches a list of top token holders for a specified token type (Theta or TFuel). The size of the returned list is determined by the limit parameter. ```APIDOC APIDOC REST Uri: /account/top/:tokenType/:limit Query Parameters: - tokenType: The type of token to query (e.g., 'theta', 'tfuel'). - limit: The maximum number of top holders to return. Returns: A list of accounts, with details similar to the GetAccount API. ``` ```bash curl "https://explorer-api.thetatoken.org/api/account/top/theta/5" ``` -------------------------------- ### Handle Copy Event in JavaScript Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/frontend/index.html This JavaScript code attaches a 'copy' event listener to the document. It captures selected text, cleans it by removing specific characters, and sets the clipboard data to the processed text, but only if the text matches a hexadecimal pattern starting with '0x'. This is useful for ensuring clean data is copied from the explorer. ```javascript document.addEventListener('copy', function (e) { let text = window.getSelection().toString().trim(); if (!text.match(/^0x.*$/)) { return; } text = text.replace(/[ ]+/g, ''); e.clipboardData.setData('text/plain', text); e.preventDefault(); }); ``` -------------------------------- ### Get Token Transactions API - APIDOC Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Fetches a paginated list of transactions for a given token address. Supports filtering by page number and limit. Optionally filters for specific token IDs for TNT-721 tokens. Returns transaction details including sender, receiver, hash, timestamp, and value. ```APIDOC GetTokenTransactions: Description: This API returns a list of token transactions of given the token address, page number and limit number. REST Uri: /token/:address Parameters: address: Type: string Description: The token's smart contract address. pageNumber: Type: integer Description: The page number, 0 stands for the latest. limit: Type: integer Description: The limit size of each page. token_id: Type: string (optional) Description: The token id (only applied for TNT-721 tokens). Returns: currentPageNumber: The number of current page. totalPageNumber: The total number of pages. tokenTransaction: JSON representation of the token transaction. contract_address: The contract address of the token. from: The sender's account address of the transaction. hash: The hash of the transaction. name: The name of the token. timestamp: The timestamp of the transaction. to: The receiver's account address of the transaction. token_id: The token id. type: The type of the token (TNT-20/TNT-721). value: The number of tokens included in the transaction. Example: Request: curl https://explorer-api.thetatoken.org/api/token/0x5d0004fe2e0ec6d002678c7fa01026cabde9e793?pageNumber=1&limit=20 Result: { "type": "token_info", currentPageNumber: 1, totalPageNumber: 161, "body": [ { contract_address: "0x5d0004fe2e0ec6d002678c7fa01026cabde9e793", from: "0x70dea7940584a2f62476e2dc0b9a017e7287a945", hash: "0xd28ac9d57b01d9f8c7586a9efd13bcbfc68775a789b2222dbc16fb6a5983b346", name: null, timestamp: "1660853966", to: "0x501077f68d8261495f8f179f75d52a9c0f39ae94", token_id: "1001", type: "TNT-721", value: 1 }, { contract_address: "0x5d0004fe2e0ec6d002678c7fa01026cabde9e793", from: "0x4e97bf49b538a9469d6ad0576f46543fd4b16c2e", hash: "0xf5671192e6d5b7f67538af90a59571f4ac3f47ff557fc279575a2920049df5e6", name: null, timestamp: "1660820162", to: "0x20ae1265e06163d1bd197824170d62a458ebf273", token_id: "531", type: "TNT-721", value: 1 } ] } ``` -------------------------------- ### Other Theta Frontend Gulp Tasks Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Lists common Gulp tasks available for managing the frontend project. These include building JavaScript and Sass files, cleaning the project, and watching for file changes. ```javascript gulp build-js gulp build-sass gulp clean gulp watch ``` -------------------------------- ### Smart Contract APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Interact with smart contract data, including retrieving contract details and verifying contract source code. ```APIDOC Smart Contract APIs: GetSmartContract: GET /api/v2/smart-contract/{address} Retrieves details of a deployed smart contract. Parameters: - address (string): The address of the smart contract. Returns: - SmartContract object with ABI, bytecode, etc. VerifySmartContract: POST /api/v2/smart-contract/verify Verifies the source code of a deployed smart contract. Parameters: - address (string): The address of the smart contract. - source_code (string): The source code of the contract. - compiler_version (string): The version of the compiler used. - optimization_runs (integer): Number of optimization runs. Returns: - Verification status and message. ``` -------------------------------- ### Supply APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Query the total supply of Theta (THETA) and TFuel (TFUEL) tokens. ```APIDOC Supply APIs: GetThetaAmount: GET /api/v2/supply/theta Retrieves the current total supply of THETA tokens. Returns: - Object containing the THETA supply amount. GetTFuelAmount: GET /api/v2/supply/tfuel Retrieves the current total supply of TFUEL tokens. Returns: - Object containing the TFUEL supply amount. ``` -------------------------------- ### Stake APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Query staking information, including all stakes, total staked amount, and stakes by address. ```APIDOC Stake APIs: GetAllStakes: GET /api/v2/stakes Retrieves all active stakes on the network. Returns: - Array of Stake objects. GetTotalStakedAmount: GET /api/v2/total-staked Retrieves the total amount of Theta staked on the network. Returns: - Object containing the total staked amount. GetStakeByAddress: GET /api/v2/account/{address}/stakes Retrieves staking information for a specific account address. Parameters: - address (string): The Theta account address. Returns: - Array of Stake objects associated with the account. ``` -------------------------------- ### Account APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Query account-specific information, including balance, transaction history, and token holdings. ```APIDOC Account APIs: GetAccount: GET /api/v2/account/{address} Retrieves the balance and basic information for a given account address. Parameters: - address (string): The Theta account address. Returns: - Account object with balance and other details. GetAccountTxHistory: GET /api/v2/account/{address}/transactions Retrieves the transaction history for a given account address. Parameters: - address (string): The Theta account address. Returns: - Array of Transaction objects associated with the account. GetTopTokenHolders: GET /api/v2/token/{token_address}/holders Retrieves a list of top token holders for a specific token contract. Parameters: - token_address (string): The address of the token contract. Returns: - Array of token holder objects, typically including address and balance. ``` -------------------------------- ### Block APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieve information about blocks on the Theta ledger. Supports fetching a single block by height or a range of blocks. ```APIDOC Block APIs: GetBlock: GET /api/v2/block/{height} Retrieves a specific block by its height. Parameters: - height (integer): The block height to retrieve. Returns: - Block object containing block details. GetBlocksByRange: GET /api/v2/blocks/{startHeight}/{endHeight} Retrieves a range of blocks. Parameters: - startHeight (integer): The starting block height (inclusive). - endHeight (integer): The ending block height (inclusive). Returns: - Array of Block objects. ``` -------------------------------- ### GetBlock API Endpoint Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves detailed information for a specific block by its height. The API returns block metadata, transaction hashes, state hashes, proposer information, and a list of transactions with their types and statuses. Supports querying by block height. ```APIDOC API: GetBlock REST Uri: /block/:height Description: This API returns the details of the block being queried with height. Parameters: - height: The block height to query (integer). Returns: - epoch: epoch of the block (string) - height: height of the block (integer) - parent: hash of the parent block (string) - transactions_hash: root hash of the transaction Merkle-Patricia trie (string) - state_hash: root hash of the state Merkle-Patricia trie (string) - timestamp: timestamp when the block was proposed (string) - proposer: address of the proposer validator (string) - hash: the block hash (string) - transactions: json representation of the transactions contained in the block (array of objects) - raw: transaction details (object) - type: type of the transaction (see Transaction Types below) (integer) - hash: hash of the transaction (string) - status: status of the block (see Block Status below) (integer) Transaction Types: 0: coinbase transaction, for validator/guardian reward 1: slash transaction, for slashing malicious actors 2: send transaction, for sending tokens among accounts 3: reserve fund transaction, for off-chain micropayment 4: release fund transaction, for off-chain micropayment 5: service payment transaction, for off-chain micropayment 6: split rule transaction, for the "split rule" special smart contract 7: smart contract transaction, for general purpose smart contract 8: deposit stake transaction, for depositing stake to validators/guardians 9: withdraw stake transaction, for withdrawing stake from validators/guardians Block Status: 0: pending 1: valid 2: invalid 3: committed 4: directly finalized 5: indirectly finalized 6: trusted (the first block in a verified snapshot is marked as trusted) A block and all the transactions included in the block are considered Finalized by the validators if the block status is either 4, 5, or 6. Block status transitions: +-------+ +-------+ +-------------------+ |Pending+---+------>Invalid| +----->IndirectlyFinalized| +-------+ | +-------+ | +-------------------+ | | | | +-----+ +---------+ | +-----------------| +------>Valid+-------->Committed+---+----->DirectlyFinalized| +-----+ +---------+ +-----------------+ Example: // Request curl https://explorer-api.thetatoken.org/api/block/1 // Result { "type":"block", "body":{ "epoch":"1", "status":5, "height":1, "timestamp":"1550089775", "hash":"0x705b74cde1ad4afefb8cae883327b216dd11c3a4b592b4487a40337e5e27a7bd", "parent_hash":"0x8ce72f57b6ef53c7d5d144a40d6faacc444e9cd60d79043ea5ab978f44c120c6", "proposer":"0x9f1233798e905e173560071255140b4a8abd3ec6", "state_hash":"0xcb9b1641ecb9f1fb372a9ac9184c811c07bda3d061ce63b2c2e2f1fafc42c789", "transactions_hash":"0x36449d6d0523379a6799843cea98c0a4d708a7c314d0536496a78dee57fcb672", "num_txs":1, "txs":[ { "raw":{ "proposer":{ "address":"0x9f1233798e905e173560071255140b4a8abd3ec6", "coins":{ "thetawei":"0", "tfuelwei":"0" }, "sequence":"0", "signature":"0xe54784005c1c321092d24ba50a32228b7b7b6d4e5ad41aa968e96123f1996f623aa609ab7414995aaa25eb8897ca2bb3809695e31829d5de2ee94eead3907eda00" }, "outputs":[ { "address":"0x2e833968e5bb786ae419c4d13189fb081cc43bab", "coins":{ "thetawei":"0", "tfuelwei":"0" } }, { "address":"0x350ddef232565b32e66a9fb69780e85b686a9e1d", "coins":{ "thetawei":"0", "tfuelwei":"0" } }, { "address":"0x5f74e3d5cc77b66f0030c5501cfbd39dcb8ff5b6", "coins":{ "thetawei":"0", "tfuelwei":"0" } }, { "address":"0x7631958d57cf6a5605635a5f06aa2ae2e000820e", "coins":{ "thetawei":"0", "tfuelwei":"0" } }, { "address":"0x9f1233798e905e173560071255140b4a8abd3ec6", "coins":{ "thetawei":"0", "tfuelwei":"0" } }, { "address":"0xc15e24083152dd76ae6fc2aeb5269ff23d70330b", "coins":{ "thetawei":"0", "tfuelwei":"0" } } ] } } ] } } ``` -------------------------------- ### Theta Supply APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Provides endpoints to retrieve the total and circulating supply amounts for Theta (THETA) and TFuel (TFUEL) tokens. These APIs offer insights into tokenomics and circulation. ```APIDOC Supply APIs: GET /supply/theta Description: Returns the total supply and circulation amount of Theta (THETA). Returns: - total_supply: the total amount of theta supplied - circulation_supply: the circulation amount of theta supplied Example Response: { "total_supply": 1000000000, "circulation_supply": 1000000000 } GET /supply/tfuel Description: Returns the circulation amount of TFuel (TFUEL). Returns: - circulation_supply: the circulation amount of tfuel supplied Example Response: { "circulation_supply": 5000000000 } Related APIs: /stake/all, /stake/totalAmount, /stake/:address ``` -------------------------------- ### Token APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieve information and transaction history for specific Theta-based tokens. ```APIDOC Token APIs: GetTokenSummary: GET /api/v2/token/{token_address} Retrieves summary information for a specific token contract. Parameters: - token_address (string): The address of the token contract. Returns: - Token object with details like name, symbol, total supply. GetTokenTransactions: GET /api/v2/token/{token_address}/transactions Retrieves all transactions involving a specific token contract. Parameters: - token_address (string): The address of the token contract. Returns: - Array of Transaction objects related to the token. ``` -------------------------------- ### Verify Smart Contract API Endpoint Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md API endpoint to verify and validate a smart contract on the blockchain. It requires the contract address and details about its source code, compiler version, and compilation settings. ```APIDOC POST /smartContract/verify/:address Verifies and validates a smart contract deployed on a blockchain. Parameters: - address (path, string): The smart contract address. Request Body: - sourceCode (string): The original source code of the smart contract written in Solidity. - abi (string, optional): The Application Binary Interface (ABI) of the smart contract. - version (string): The version of the compiler used (e.g., "0.7.4"). - optimizer (string): Indicates whether optimization was used ('0' for disabled, '1' for enabled). - versionFullName (string): The full version name of the compiler (e.g., "soljson-v0.7.4+commit.3f05b770.js"). - optimizerRuns (string, optional): The number of optimization runs configured for the compiler. - evm (string, optional): The Ethereum Virtual Machine (EVM) version the smart contract is compatible with (e.g., "default"). - viaIR (string, optional): Indicates if the smart contract was compiled using an intermediate representation ('true' or 'false'). Example: ```shell curl -X POST https://explorer-api.thetatoken.org/api/smartcontract/verify/0xb464bcdc89570eb7fac1f546703396f49a6ba24d \ -H "Content-Type: application/json" \ -d '{ "abi": "", "evm": "default", "optimizer": "0", "optimizerRuns": "200", "sourceCode": "pragma solidity ^0.7.4;\n\ncontract SquareCalculator {\n event SetValue(uint val);\n \n uint public value;\n \n function setValue(uint val) public {\n value = val;\n emit SetValue(val);\n }\n \n function CalculateSquare() view public returns (uint) {\n uint sqr = value * value;\n assert(sqr / value == value); // overflow protection\n return sqr;\n }\n}", "version": "0.7.4", "versionFullName": "soljson-v0.7.4+commit.3f05b770.js", "viaIR": "false" }' ``` Result: ```json { "result": { "verified": true }, "warning_msg": [] } ``` ``` -------------------------------- ### Theta Stake APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Provides endpoints to retrieve stake records, total staked amounts, and stakes filtered by address from the Theta ledger explorer. These APIs allow querying the state of staking on the Theta network. ```APIDOC Stake APIs: GET /stake/all Description: Returns all stake records. Returns: - stakes: json representation of the stakes - _id: the ID for the stake record - type: indicates if the stake is in the validator candidate pool ('vcp') or the guardian candidate pool ('gcp') - holder: the account's address holding the stake - source: the source account's address of the stake - amount: the staked thetawei amount - withdrawn: boolean, true if the stake is withdrawn, false otherwise - return_height: the expected block height for tokens to return to the staking wallet if a node withdraws its stake Example Response: { "type": "stake", "body": [ { "_id": "5eb9f45d38696f556cc3334d", "type": "vcp", "holder": "0x80eab22e27d4b94511f5906484369b868d6552d2", "source": "0x4aefa39caeadd662ae31ab0ce7c8c2c9c0a013e8", "amount": "20000000000000000000000000", "withdrawn": false, "return_height": "18446744073709551615" } ] } GET /stake/totalAmount Description: Returns the total amount of stakes and the total number of stake nodes. Returns: - totalAmount: the total amount of staked thetawei - totalNodes: the total count of stake nodes Example Response: { "totalAmount": "317702156000000000000000000", "totalNodes": 12 } GET /stake/:address Description: Returns stake records associated with a specific address. The structure of returned stakes is similar to the /stake/all endpoint. Parameters: - address: The account address to query stakes for. Returns: - Similar to /stake/all, but filtered by the provided address. Example Response: { "type": "stake", "body": { "holderRecords": [], "sourceRecords": [ { "_id": "5eb9f60638696f556cc33aa3", "type": "vcp", "holder": "0xe2408dff7a1f9bc247c803e43efa2f0a37b10ba6", "source": "0xc15149236229bd13f0aec783a9cc8e8059fb28da", "amount": "30000000000000000000000000", "withdrawn": false, "return_height": "18446744073709551615" } ] } } Related APIs: /supply/theta, /supply/tfuel ``` -------------------------------- ### Transaction APIs Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Access transaction data on the Theta ledger. Allows fetching individual transactions, transactions within a height range, or transactions within a block range. ```APIDOC Transaction APIs: GetTransaction: GET /api/v2/transaction/{hash} Retrieves a specific transaction by its hash. Parameters: - hash (string): The transaction hash. Returns: - Transaction object. GetTransactionsByRange: GET /api/v2/transactions/{startHeight}/{endHeight} Retrieves transactions within a specified block height range. Parameters: - startHeight (integer): The starting block height (inclusive). - endHeight (integer): The ending block height (inclusive). Returns: - Array of Transaction objects. GetTransactionsByBlockRange: GET /api/v2/block/{height}/transactions Retrieves all transactions within a specific block. Parameters: - height (integer): The block height. Returns: - Array of Transaction objects. ``` -------------------------------- ### GetBlocksByRange API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md This API endpoint retrieves a paginated list of blockchain blocks. It accepts `pageNumber` and `limit` as query parameters to specify the desired range. The response includes the current page number and details for each block, similar to the GetBlock API. ```APIDOC GET /blocks/top_blocks Description: Retrieves a list of blocks based on page number and limit. Query Parameters: - pageNumber (integer): The page number. 1 stands for the latest page. - limit (integer): The limit size of each page. Returns: - currentPageNumber (integer): The number of the current page. - body (array): A list of block objects. Each block object contains: - epoch (string): The epoch number. - status (integer): The status of the block. - height (integer): The block height. - timestamp (string): The block timestamp. - hash (string): The block hash. - parent_hash (string): The hash of the parent block. - proposer (string): The address of the block proposer. - state_hash (string): The state hash of the block. - transactions_hash (string): The hash of the transactions in the block. - num_txs (integer): The number of transactions in the block. - txs (array): A list of transactions (details omitted for brevity). Example: curl https://explorer-api.thetatoken.org/api/blocks/top_blocks?pageNumber=1&limit=10 ``` ```curl // Request curl https://explorer-api.thetatoken.org/api/blocks/top_blocks?pageNumber=1&limit=10 // Result { "type":"block_list", "body":[ { "epoch":"17475", "status":4, "height":17449, "timestamp":"1550199501", "hash":"0x4756f30fa538769e4dcaae9fcbd19f6612b05abc843aa9c07a28983121fb3b1d", "parent_hash":"0xdd3fde69f68d8b9522adab25f04459f84072a160c2ab3ceeb086777550378e7f", "proposer":"0xc15e24083152dd76ae6fc2aeb5269ff23d70330b", "state_hash":"0x9711aadb58db9b33ac2f8e29584d772184b01b8406bc2c7cda52a024eeabba8a", "transactions_hash":"0xa90c99ab4a3861cfd2a71280a2f74f4aadda5727b72f046687681adfe31c3b5e", "num_txs":7, "txs":[ // ... transaction details ] }, { "epoch":"17476", "status":4, "height":17450, "timestamp":"1550199507", "hash":"0xb5997adcd3daf6c249b2e4ae79945d36fc1aa262fc344a5c665193460c4c2fec", "parent_hash":"0x4756f30fa538769e4dcaae9fcbd19f6612b05abc843aa9c07a28983121fb3b1d", "proposer":"0x9f1233798e905e173560071255140b4a8abd3ec6", "state_hash":"0x69407583b370cbc8c27c63f975e0a3145f05068f8a488d7411ed634f1544fefc", "transactions_hash":"0x1ff24e55b5c2e1a9e01ced5d7f92fe2dde90511e7b5cb28e93ed8751df721bda", "num_txs":5, "txs":[ // ... transaction details ] } // ... more blocks ] } ``` -------------------------------- ### Skip Live Reloading in Theta Frontend Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/README.md Disables the live reloading feature for the frontend development server. This allows browsing the node server directly, typically at https://localhost:4000, without automatic refreshes. ```javascript gulp nosync ``` -------------------------------- ### GetTransaction API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves detailed information for a specific transaction using its unique hash. It returns fields such as block height, transaction hash, data payload, type, total transactions count, timestamp, and sequence number. ```APIDOC GetTransaction: Description: This API returns the details of the transaction being queried with hash. REST Uri: /transaction/:hash Query Parameters: - hash: The transaction hash (string). Returns: - block_height: Height of the block that contains the transaction (integer). - hash: The hash of the transaction itself (string). - data: The details of the transaction (object). - type: Transaction type (string). - totalTxsNumber: Total number of transactions in database (integer). - timestamp: The time stamp of the block contains this block (string). - number: The sequence number of the transaction in database (integer). Example: { "type": "transaction", "body": { "hash": "0XF16402022FFFADA96C4BA9A78F79730903F8D99EF44D221FC5869EC4191260EC", "type": 5, "data": { "fee": { "thetawei": "0", "tfuelwei": "1000000000000" }, "source": { "address": "0x02990c3f7f75865bcd2fb28450f01065754f9372", "coins": { "thetawei": "0", "tfuelwei": "1150000000000000" }, "sequence": "0", "signature": "0x66cb200ad7def6a0b4e9d377fd6a54cf19f952d089772b2dda8bd0f0927434825acec09e5c2c7aaaf9c4d18a2730786ee619a593fd49395913785aa4255e164001" }, "target": { "address": "0x49e2268b8962a7b5680512173f2b320418003082", "coins": { "thetawei": "0", "tfuelwei": "0" }, "sequence": "126", "signature": "0xdd6aecdf642a001b9ae299cf44aa5c142dac45dd58666d326870dc53670dc204548951880ebce343afb27c968bb99488c23bc9af43a60c4de6299c6242cf07ac00" }, "payment_sequence": "1550282279177", "reserve_sequence": "178", "resource_id": "vidivz187ttu9eck65d" }, "number": 196771, "block_height": "30615", "timestamp": "1550282330" }, "totalTxsNumber": 196771 } ``` -------------------------------- ### GetTransactionsByRange API Source: https://github.com/thetatoken/theta-infrastructure-ledger-explorer/blob/master/docs/api.md Retrieves a paginated list of transactions based on the provided page number and limit. The 'pageNumber' 0 signifies the latest transactions. Returns pagination details and an array of transaction objects similar to the GetTransaction response. ```APIDOC GetTransactionsByRange: Description: This API returns a list of transactions given the page number and limit number. REST Uri: /trancastions/range Query Parameters: - pageNumber: The page number, 0 stands for the latest (integer). - limit: The limit size of each page (integer). Returns: - currentPageNumber: The number of current page (string). - totalPageNumber: The total number of pages (integer). - body: An array of transaction objects, each similar to the returns of the GetTransaction API. Example: // Request curl https://explorer-api.thetatoken.org/api/transactions/range?pageNumber=1&limit=10 // Result { "type": "transaction_list", "body": [ {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...} ], "totalPageNumber": 20354, "currentPageNumber": "1" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.