Tron Sdk Py: The TRON GRPC API SDK in Python

tron-sdk-py

The TRON gRPC API SDK in Python.

Demo

from tron.proto.core.contract_pb2 import TransferContract
from tron.client import TronClient
from tron.types import HEX, ADDR

client = TronClient.nile(
    private_key=HEX('3333333333333333333333333333333333333333333333333333333333333333')
)


print(client.solidity_stub.GetNowBlock2(EmptyMessage()))


req = TransferContract()
req.owner_address = ADDR("TJRabPrwbZy45sbavfcjinPJC18kjpRTv8")
req.to_address = ADDR("TRsbuxREXKJKonexpejWhacE4sYHt1BSHV")
req.amount = 1_100_000
txn = client.wallet_stub.CreateTransaction2(req)

print("TXID:", HEX(txn.txid))

signed_txn = client.sign(txn)
print(signed_txn)
resp = client.wallet_stub.BroadcastTransaction(signed_txn)
print(resp)

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/tron-sdk-py
License:

#tron  #blockchain  #smartcontract 

Tron Sdk Py: The TRON GRPC API SDK in Python

Project Management: TRON Core Devs Meetings and SR Meetings

Purpose

The TRON core devs meeting is a technical meeting intended to bring together all the TRON developers who play major roles in determining the direction of the TRON protocol. TRON developers provide updates to their projects, discuss various TIPs to improve the protocol, and support each other.

Previous Meetings

DateAdgendaNotesRecording
1Wed, 15 Jan, 2020 07:00 UTCagendanotesvideo
2Mon, 17 Feb, 2020 07:00 UTCagendanotesvideo
3Mon, 02 Mar, 2020 07:00 UTCagendanotesvideo
4Mon, 16 Mar, 2020 09:00 UTCagendanotesvideo
5Mon, 13 Apr, 2020 09:00 UTCagendanotesvideo
6Thur, 30 Apr, 2020 09:00 UTCagendanotesvideo
7Tues, 16 Jun, 2020 09:00 UTCagendanotesvideo
8Tues, 11 Aug, 2020 09:00 UTCagendanotesvideo
9Thu, 24 Sep, 2020 09:00 UTCagendanotesvideo
10Wed, 20 Jan. 2021 09:00 UTCagendanotesNA
11Thu, 20 May. 2021 09:00 UTCagendanotesNA
12Thu, 11 Aug. 2021 09:00 UTCagendanotesNA

Who Can Attend

These meetings are held by TRON core devs. The following groups are invited to attend the meetings:

  • core java-tron developers
  • client developers
  • core TRON researchers

Sometimes a non-core java-tron developer with particular expertise on a topic is invited on to discuss a specific agenda item. If you feel you would contribute to the meetings please contact coredevs@tron.network.

Agenda Items

Agenda's are posted to https://github.com/tronprotocol/pm/issues. Anyone is welcome to add an item to the agenda as long as it follows these guidelines:

  • The topic is technical in nature
  • The topic involves the TRON protocol

Please note:

  • Dapp are generally not allowed as topics
  • The topic should not be philosophical

The core devs meetings are not meant to decide philosophical contentious issues that should be decided by the community.

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/pm
License: View license

#tron  #blockchain  #smartcontract 

Project Management: TRON Core Devs Meetings and SR Meetings

Chainbase: A Decentralized Database for Blockchain

chainbase

A decentralized database for blockchain.

Dependencies

The lastest version is 1.0.0.

GRADLE

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
      }
}

Step 2. Add the dependency.

dependencies {
    implementation 'com.github.tronprotocol:chainbase:${version}'
}

MAVEN

Step 1. Add the JitPack repository to your build file.

<repositories>
      <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
      </repository>
</repositories>

Step 2. Add the dependency.

<dependency>
    <groupId>com.github.tronprotocol</groupId>
      <artifactId>chainbase</artifactId>
      <version>${version}</version>
</dependency>
    

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/chainbase
License: LGPL-3.0 license

#tron  #blockchain  #smartcontract 

Chainbase: A Decentralized Database for Blockchain

Tron Event Subscribe Plugin

This is an implementation of Tron eventsubscribe model.

  • api module defines IPluginEventListener, a protocol between Java-tron and event plugin.
  • app module is an example for loading plugin, developers could use it for debugging.
  • kafkaplugin module is the implementation for kafka, it implements IPluginEventListener, it receives events subscribed from Java-tron and relay events to kafka server.
  • mongodbplugin mongodbplugin module is the implementation for mongodb.

Setup/Build

  1. Clone the repo
  2. Go to eventplugin cd eventplugin
  3. run ./gradlew build
  • This will produce plugin zips, named plugin-kafka-1.0.0.zip and plugin-mongodb-1.0.0.zip, located in the eventplugin/build/plugins/ directory.

Edit config.conf of Java-tron, add the following fileds:

event.subscribe = {
    path = "" // absolute path of plugin
    server = "" // target server address to receive event triggers
    dbconfig = "" // dbname|username|password, if you want to create indexes for collections when the collections are not exist, you can add version and set it to 2, as dbname|username|password|version
    topics = [
        {
          triggerName = "block" // block trigger, the value can't be modified
          enable = false
          topic = "block" // plugin topic, the value could be modified
          solidified = true // if set true, just need solidified block, default is false
        },
        {
          triggerName = "transaction"
          enable = false
          topic = "transaction"
          solidified = true
          ethCompatible = true // if set true, add transactionIndex, cumulativeEnergyUsed, preCumulativeLogCount, logList, energyUnitPrice, default is false
        },
        {
          triggerName = "contractevent"
          enable = true
          topic = "contractevent"
        },
        {
          triggerName = "contractlog"
          enable = true
          topic = "contractlog"
          redundancy = true // if set true, contractevent will also be regarded as contractlog
        },
        {
          triggerName = "solidity" // solidity block trigger(just include solidity block number and timestamp), the value can't be modified
          enable = true            // the default value is true
          topic = "solidity"
        },
        {
          triggerName = "solidityevent"
          enable = false
          topic = "solidityevent"
        },
        {
          triggerName = "soliditylog"
          enable = false
          topic = "soliditylog"
          redundancy = true // if set true, solidityevent will also be regarded as soliditylog
        }
    ]

    filter = {
       fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
       toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
       contractAddress = [
           "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
       ]

       contractTopic = [
           "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
       ]
    }
}

path: is the absolute path of "plugin-kafka-1.0.0.zip" or "plugin-mongodb-1.0.0.zip"

server: Kafka(or MongoDB) server address, the default port is 9092(MongoDB is 27017)

dbconfig: db configuration information for mongodb, if using kafka, delete this one; if using Mongodb, add like that dbname|username|password or dbname|username|password|version if you want to create indexes when init

topics: each event type maps to one Kafka topic(or MongoDB collection), we support seven event types subscribing, block, transaction, contractlog, contractevent, solidity, soliditylog and solidityevent.
triggerName: the trigger type, the value can't be modified.
enable: plugin can receive nothing if the value is false.
topic: the value is the kafka topic to receive events. Make sure it has been created and Kafka process is running
solidified: if just need solidified data, just works for block and transaction
redundancy: if will also trigger event as log, just works for contractlog and soliditylog
ethCompatible: if set to true, will add some fields to transaction: transactionIndex, cumulativeEnergyUsed, preCumulativeLogCount, logList, energyUnitPrice

filter: filter condition for process trigger.

note: if the server is not 127.0.0.1, pls set some properties in config/server.properties file
remove comment and set listeners=PLAINTEXT://:9092
remove comment and set advertised.listeners to PLAINTEXT://host_ip:9092

Install Kafka

On Mac:

brew install kafka

On Linux:

cd /usr/local
wget http://archive.apache.org/dist/kafka/0.10.2.2/kafka_2.10-0.10.2.2.tgz
tar -xzvf kafka_2.10-0.10.2.2.tgz 
mv kafka_2.10-0.10.2.2 kafka

add "export PATH=$PATH:/usr/local/kafka/bin" to end of /etc/profile
source /etc/profile

Note: make sure the version of Kafka is the same as the version set in build.gradle of eventplugin project.(kafka_2.10-0.10.2.2 kafka)

Run Kafka

On Mac:

zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties

On Linux:

zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &
Sleep about 3 seconds 
kafka-server-start.sh /usr/local/kafka/config/server.properties &

Create topics to receive events, the topic is defined in config.conf

On Mac:

kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic block
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic transaction
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractlog
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractevent
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidity
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidityevent
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic soliditylog

On Linux:

kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic block
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic transaction
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractlog
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic contractevent
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidity
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic solidityevent
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic soliditylog

Kafka consumer

On Mac:

kafka-console-consumer --bootstrap-server localhost:9092  --topic block
kafka-console-consumer --bootstrap-server localhost:9092  --topic transaction
kafka-console-consumer --bootstrap-server localhost:9092  --topic contractlog
kafka-console-consumer --bootstrap-server localhost:9092  --topic contractevent
kafka-console-consumer --bootstrap-server localhost:9092  --topic solidity
kafka-console-consumer --bootstrap-server localhost:9092  --topic solidityevent
kafka-console-consumer --bootstrap-server localhost:9092  --topic soliditylog

On Linux:

kafka-console-consumer.sh --zookeeper localhost:2181 --topic block
kafka-console-consumer.sh --zookeeper localhost:2181 --topic transaction
kafka-console-consumer.sh --zookeeper localhost:2181 --topic contractlog
kafka-console-consumer.sh --zookeeper localhost:2181 --topic contractevent
kafka-console-consumer.sh --zookeeper localhost:2181 --topic solidity
kafka-console-consumer.sh --zookeeper localhost:2181 --topic solidityevent
kafka-console-consumer.sh --zookeeper localhost:2181 --topic soliditylog

Load plugin in Java-tron

  • add --es to command line, for example:
 java -jar FullNode.jar -c config.conf --es 

Event filter

which is defined in config.conf, path: event.subscribe

filter = {
       fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
       toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
       contractAddress = [
           "TVkNuE1BYxECWq85d8UR9zsv6WppBns9iH" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
       ]

       contractTopic = [
           "f0f1e23ddce8a520eaa7502e02fa767cb24152e9a86a4bf02529637c4e57504b" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
       ]
    }

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/event-plugin
License:

#tron  #blockchain  #smartcontract 

Tron Event Subscribe Plugin

How to Build & Use A Tron Node Supporting Rosetta Blockchain Spec

tron-rosetta-api

A rosetta api for java-tron.

Overview

In this article, we will illustrate how to build and use a Tron node supporting Rosetta blockchain specifications. We hope this set of specifications will make our TRON API architecture more standard and flexible

Before Deployment

Please make sure you have installed the latest version of docker before deployment Execute the following command to download tron-rosetta-api:

$ git clone https://github.com/tronprotocol/tron-rosetta-api.git

Build rosetta image using tronprotocol base images

You can use the base images published on docker hub. This is a more convenient way to build rosetta image.

Build a centos rosetta docker image by default:

$ cd tron-rosetta-api
$ docker build -t --no-cache tron-rosetta-api .

Or build a ubuntu rosetta docker image:

$ cd tron-rosetta-api
$ docker build -f Dockerfile.ubuntu -t tron-rosetta-api .

Build rosetta image using self-build base images

Centos rosetta docker image

  1. Build a centos base image

Dockerfile.centos7-jdk8

FROM centos:centos7

ADD jdk-8u301-linux-x64.tar.gz  /usr/local/
ADD unzip-6.0-21.el7.x86_64.rpm /tmp
RUN yum -y install git \
  && yum clean all
RUN rpm -ivh /tmp/unzip-6.0-21.el7.x86_64.rpm \
  && rm /tmp/unzip-6.0-21.el7.x86_64.rpm
ENV JAVA_HOME /usr/local/jdk1.8.0_301
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin

The jdk Linux x64 Compressed Archive can be found from the official download page. Build the base image:

$ docker build -f Dockerfile.centos7-jdk8 -t centos7jdk8 .

2.   Build a centos rosetta image

Replace the base image name in the Dockerfile

#FROM tronprotocol/centos7-jdk8
FROM centos7jdk8

Build a centos rosetta docker image

$ docker build -t --no-cache tron-rosetta-api .

Ubuntu rosetta docker image

  1. Build a ubuntu base image

Dockerfile.ubuntu-jdk8

FROM ubuntu:18.04

WORKDIR /usr
RUN mkdir /usr/local/java
ADD jdk-8u301-linux-x64.tar.gz /usr/local/java/
ENV JAVA_HOME /usr/local/java/jdk1.8.0_301
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
ENV PATH $JAVA_HOME/bin:$PATH
$ docker build -f Dockerfile.ubuntu-jdk8 -t ubuntujdk8 .

2.   Build a ubuntu rosetta image

Replace the base image name in the Dockerfile.ubuntu

#FROM tronprotocol/ubuntu18-jdk8
FROM ubuntujdk8

Build a ubuntu rosetta docker image

$ docker build -f Dockerfile.ubuntu -t --no-cache tron-rosetta-api .

Node Deployment

Start in Docker

$ docker run --name tron-rosetta-api -d -p 8080:8080 tron-rosetta-api:latest

Start the node offline

$ docker run --name tron-rosetta-api -d --env RUN_MODE="offline" -p 8080:8080 tron-rosetta-api:latest

You can also customize a data or log directory

$ docker run --name tron-rosetta-api -d -p 8080:8080 -v ${realpath data}:/data -v ${realpath logs}:/logs tron-rosetta-api:latest

In case you wish to connect to the test net or setup a private net, set the NET_TYPE as such:

# test net
$ docker run --name tron-rosetta-api -d --env NET_TYPE="testnet" -p 8080:8080 -v ${realpath data}:/data -v ${realpath logs}:/logs tron-rosetta-api:latest

# private net
$ docker run --name tron-rosetta-api -d --env NET_TYPE="privatenet" -p 8080:8080 -v ${realpath data}:/data -v ${realpath logs}:/logs tron-rosetta-api:latest

TRON_OPTIONS

You can change the TRON_OPTIONS parameter, the default value is

TRON_OPTIONS=""

e.g. If the node is a SR node to produce blocks.

docker run --name tron-rosetta-api -d --env TRON_OPTIONS="--witness" --env NET_TYPE="privatenet" -p 8080:8080 tron-rosetta-api:latest

JVM OPTIONS

You can change the JVM_OPTIONS parameter, the default value is

JVM_OPTIONS="-Xms8G -Xmx8G -XX:NewRatio=7 \
-XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./logs/gc.log \
-XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m \
-XX:+CMSScavengeBeforeRemark"

e.g.

$ docker run --name tron-rosetta-api -d --env JVM_OPTIONS="-Xms8G -Xmx12G -XX:NewRatio=7 \
                                                         -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./logs/gc.log \
                                                         -XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m \
                                                         -XX:+CMSScavengeBeforeRemark" -p 8080:8080 -p 50051:50051 -v `pwd`/data:/data -v `pwd`/logs:/logs tron-rosetta-api:latest

API Reference

Based on Rosetta blockchain specifications, we have implemented the following interfaces:

Network

/network/list

Sample Request:

{
    "metadata": {
    }
}

Sample Response:

{
    "network_identifiers": [
         {
            "blockchain":"tron",
            "network":"mainnet"
        }
    ]
}

/network/options

Sample Request:

{
    "network_identifier": {
        "blockchain":"tron",
        "network":"mainnet"
    },
    "metadata": {
    }
}

Sample Response:

 {
    "version": {
        "rosetta_version":"1.4.0",
        "node_version":"4.0.0",
        "middleware_version":"1.0.2",
        "metadata":null
    },
    "allow": {
        "operation_statuses": [
             {
                "status":"SUCCESS",
                "successful":true
            },
             {
                "status":"REVERTED",
                "successful":false
            }
        ],
        "operation_types": [
            "TRANSFER"
        ],
        "errors": [
             {
                "code":12,
                "message":"Invalid account format",
                "retriable":true,
                "details":null
            },
             {
                "code":100,
                "message":"Invalid transaction format",
                "retriable":false,
                "details":null
            }
        ],
        "historical_balance_lookup":false
    }
}

/network/status

Sample Request:

{
    "network_identifier": {
        "blockchain":"tron",
        "network":"mainnet"
    },
    "metadata": {
    }
}

Sample Response:

  {
    "current_block_identifier": {
        "index":154,
        "hash":"000000000000009a4cefda5e311a42fd22038fb0178993e68daee29b0b3fdbe9"
    },
    "current_block_timestamp":1529891988000,
    "genesis_block_identifier": {
        "index":0,
        "hash":"00000000000000001ebf88508a03865c71d452e25f4d51194196a1d22b6653dc"
    },
    "oldest_block_identifier": {
        "index":154,
        "hash":"000000000000009a4cefda5e311a42fd22038fb0178993e68daee29b0b3fdbe9"
    },
    "peers": [
         {
            "peer_id":"d9ad9f981fa340b730b0af8fed18d4cec976af68c5458adbb01f2c38030d3590e96576751178ec0530abcde62920fe04533584571b6d2d5fee35be1486be4cac",
            "metadata": {
                "address":"127.0.0.1",
                "port":18888
            }
        },
         {
            "peer_id":"60f87819e8ae8fd9b89a9db197f953455b69f85d09438c34a02de4b05b2ff7bc591b491892a619e5a943dc867ee70efbff540ee7944a998f9dcac3cb9d98fac4",
            "metadata": {
                "address":"127.0.0.2",
                "port":18888
            }
        }
    ]
}

Account

/account/balance

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "account_identifier": {
        "address": "TRXnA3LdY5LqFatpLPpyYFYmKyJJCB3ZzR"
    }
}

Sample Response:

{
    "block_identifier": {
        "index": 72423,
        "hash": "0000000000011ae76ce0775746cd87f3b934324d5a29ffefc913319d66a02bd4"
    },
    "balances": [
        {
            "value": "986373520",
            "currency": {
                "symbol": "TRX",
                "decimals": 6
            }
        }
    ]
}

Block

/block

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "block_identifier": {
        "index":1644001,
        "hash": "00000000001915e180e90b50e1ca88265cecc33d8582392c3a78170685b7a060"
    }
}

Sample Response:

{
    "block": {
        "block_identifier": {
            "index": 1644001,
            "hash": "00000000001915e180e90b50e1ca88265cecc33d8582392c3a78170685b7a060"
        },
        "parent_block_identifier": {
            "index": 1644000,
            "hash": "00000000001915e04b2def6ff986aecea81a792508f1c341a982f9eca1d90c2d"
        },
        "timestamp": 1534834407000,
        "transactions": [
            {
                "transaction_identifier": {
                    "hash": "a6865d2b059e2be293c49af8a45e64292b7315323873a66e2f68ccceec4baed5"
                },
                "operations": [
                    {
                        "operation_identifier": {
                            "index": 0
                        },
                        "type": "TransferContract",
                        "status": "SUCCESS"
                    }
                ]
            }
        ]
    }
}

/block/transaction

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "block_identifier": {
        "index": 1402605,
        "hash": "00000000001566ed34ee7c02d076522b97bda6e4033aaeb1b8968e194d3ef0f1"
    },
    "transaction_identifier": {
        "hash": "7d5c61fc86fd6cb416f1675986b5c8b393586ad48fb57415d23b2b9cb465aabd"
    }
} 

Sample Response:

{
    "transaction": {
        "transaction_identifier": {
            "hash": "7d5c61fc86fd6cb416f1675986b5c8b393586ad48fb57415d23b2b9cb465aabd"
        },
        "operations": [
            {
                "operation_identifier": {
                    "index": 0
                },
                "type": "TransferAssetContract",
                "status": "SUCCESS"
            }
        ]
    }
}

Construction API

/construction/combine

Sample Request:

{
  "network_identifier": {
    "blockchain": "tron",
    "network": "mainnet"
  },
  "signatures": [
    {
      "hex_bytes": "c06c6fdec32480953e727b04915030ae85348a63cb75a48495eea8a3ba8a82723574fda3bc24310faab60508eb39e0b26a26843ae17c417ca68a189884c5b1e301",
      "public_key": {
        "curve_type": "secp256k1",
        "hex_bytes": "0483e4f38072fa59975fc796f220f4c07a7a6a3af1ad7fc091cbd6b8ebe78bac6a959da3587e6e761daf93693d4d2dc6b349fbc44dac5a9fcc5f809a59e93818ea"
      },
      "signature_type": "ecdsa",
      "signing_payload": {
        "address": "415624c12e308b03a1a6b21d9b86e3942fac1ab92b",
        "hex_bytes": "18015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e",
        "signature_type": "ecdsa"
      }
    }
  ],
  "unsigned_transaction": "0a5018015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e"
}

Sample Response:

{
  "signed_transaction": "0a5018015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e1241c06c6fdec32480953e727b04915030ae85348a63cb75a48495eea8a3ba8a82723574fda3bc24310faab60508eb39e0b26a26843ae17c417ca68a189884c5b1e301"
}

/construction/hash

Sample Request:

{
  "network_identifier": {
    "blockchain": "tron",
    "network": "mainnet"
  },
  "signed_transaction": "0a5018015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e1241c06c6fdec32480953e727b04915030ae85348a63cb75a48495eea8a3ba8a82723574fda3bc24310faab60508eb39e0b26a26843ae17c417ca68a189884c5b1e301"
}

Sample Response:

{
  "transaction_hash": "c82ddffde6f114b897405d9c49e42ee1804730d6b4200191d00cc32fd8aabc92"
}

/construction/submit

Sample Request:

{
  "network_identifier": {
    "blockchain": "tron",
    "network": "mainnet"
  },
  "signed_transaction": "0a5018015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e1241c06c6fdec32480953e727b04915030ae85348a63cb75a48495eea8a3ba8a82723574fda3bc24310faab60508eb39e0b26a26843ae17c417ca68a189884c5b1e301"
}

Sample Response:

{
  "transaction_identifier": {
    "hash": "c82ddffde6f114b897405d9c49e42ee1804730d6b4200191d00cc32fd8aabc92"
  },
  "metadata": null
}

/construction/parse

Sample Request:

{
  "network_identifier": {
    "blockchain": "tron",
    "network": "mainnet"
  },
  "signed": true,
  "transaction": "0a5018015a45080112410a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412100a05121212a9cf1205232323a9cf180a709cb3dfd5b82e1241c06c6fdec32480953e727b04915030ae85348a63cb75a48495eea8a3ba8a82723574fda3bc24310faab60508eb39e0b26a26843ae17c417ca68a189884c5b1e301"
}

Sample Response:

{
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "Transfer",
            "status": "Reverted"
        }
    ],
    "signers": [
        "415624c12e308b03a1a6b21d9b86e3942fac1ab92b"
    ]
}

/construction/derive

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "public_key": {
        "hex_bytes": "04e3ef13a7b6a3ac44fe1dc278122174319214b3d5bea701c0ae97a6b5c63d376248742ce3fa2d73731a4785b5446a53b7f3d6997a1c7f14aebd8c74b987d76458",
        "curve_type": "secp256k1"
    }
}

Sample Response:

{
    "address": "TZJS19RBxK2TnfnF2gLheDL3U464meqwhi"
}

/construction/metadata

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "options": {}
}

Sample Response:

{
    "metadata": {
        "expiration": 1530571284000,
        "reference_block_hash": "00000000015093a6efd83b53a0a5ee32c54b4bb71434855ea20bb1c5c31b3821",
        "reference_block_num": 22057894,
        "timestamp": 1596188062880
    }
}

/construction/payloads

Sample Request:

{
    "network_identifier": {
        "blockchain": "tron",
        "network": "mainnet"
    },
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "TransferContract",
            "status": "SUCCESS",
            "account": {
                "address": "TRXnA3LdY5LqFatpLPpyYFYmKyJJCB3ZzR"
            },
            "amount": {
                "value": "-3000000",
                "currency": {
                    "symbol": "TRX",
                    "decimals": 6
                }
            }
        },
        {
            "operation_identifier": {
                "index": 1
            },
            "type": "TransferContract",
            "status": "SUCCESS",
            "account": {
                "address": "TGo9Me13BSagSHXmKZDbZrLaFW9PXYYs3T"
            },
            "amount": {
                "value": "3000000",
                "currency": {
                    "symbol": "TRX",
                    "decimals": 6
                }
            }
        }
    ],
    "metadata": {
        "expiration": 1530571284000,
        "reference_block_hash": "00000000015093a6efd83b53a0a5ee32c54b4bb71434855ea20bb1c5c31b3821",
        "reference_block_num": 22057894,
        "timestamp": 1596188062880
    }
}

Sample Response:

{
    "unsigned_transaction": "0a86010a0207b52208a6b2effe4fc1656f408597d6a9c32c5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541aab2dfb2baeaf2dcaa757207ccdd6dc3e8dfb8db1215414ae1ad9344d1e393a4d733e03b2ec48f3909002e18c08db70170d988fba7c32c124137af6f9954cad06b1bb51d65408836184424d7c217834c2ca0734a6c7ba6298e7063beac7cef9cfb05467a981cda6534bcf8d0d6b0138447a9e763f409c75ba900",
    "payloads": [
        {
            "address": "TRXnA3LdY5LqFatpLPpyYFYmKyJJCB3ZzR",
            "hex_bytes": "0a0207b52208a6b2effe4fc1656f408597d6a9c32c5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541aab2dfb2baeaf2dcaa757207ccdd6dc3e8dfb8db1215414ae1ad9344d1e393a4d733e03b2ec48f3909002e18c08db70170d988fba7c32c"
        }
    ]
}

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/tron-rosetta-api
License: GPL-2.1 license

#tron  #blockchain  #smartcontract #java #api 

How to Build & Use A Tron Node Supporting Rosetta Blockchain Spec

Trident: A SDK That includes Libraries for Working with TRON

trident

trident is a SDK that includes libraries for working with TRON, it makes it easy to build TRON applications with multi-language.

Contribution

We're very glad and appreciate to have contributions from the community.

Refer to our contributing guide for more information.

Join our Telegram group

trident-java

trident-java is a lightweight SDK that includes libraries for working with TRON network.

Functions include:

  • Offline address generation
  • Offline transaction signature
  • java-tron full node API support

For more informations refer to : trident-java document

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/trident
License:

#tron #java  #blockchain  #smartcontract 

Trident: A SDK That includes Libraries for Working with TRON

TRON Improvement Proposals

TIPs

TRON Improvement Proposals (TIPs) describe standards for the TRON platform, including core protocol specifications, client APIs, and contract standards.

TIPs Guide

IDTitleAuthorTypeCategoryHard forkStatus
TIP 10TRON Token Standardzhaohong229@gmail.comStandards TrackCorefalseFinal
TIP 12TRON Event Subscription Modeljiangyangyang@tron.networkInformationalTRCfalseFinal
TIP 13Design of TRON accountjustin@tron.networkStandards TrackCorefalseFinal
TIP 16TRON Account Multi-Signaturezhaohong229@gmail.comStandards TrackCoretrueFinal
TIP 17TRON Adaptive Energy Limit Modelnanfengpo@hotmail.comStandards TrackCoretrueFinal
TIP 19TRC-19 Deferred transactionjiangyangyang@tron.networkStandards TrackCoretrueDeferred
TIP 20TRC-20 Token Standardzhaohong2292@gmail.comStandards TrackTRCtrueFinal
TIP 23Add the account world status tree root to the block headerliangzhiyan@tron.networkStandards TrackCoretrueAccepted
TIP 24Implement of DB storage with RocksDBshydesky@gmail.comStandards TrackCorefalseFinal
TIP 26Create2jiangxinjian@tron.networkStandards TrackVMfalseFinal
TIP 28Built-in Message Queue in Event Subscription Modeljiangyangyang@tron.networkInformational falseFinal
TIP 29Bitwise shifting instructions in Tronjiangxinjian@tron.networkStandards TrackVMtrueFinal
TIP 30Code hash instructionsllwslc@gmail.comStandards TrackVMtrueFinal
TIP 31Trigger constant contractllwslc@gmail.comStandards TrackVMtrueFinal
TIP 32Clear the ABI of contractllwslc@gmail.comStandards TrackVMtrueFinal
TIP 37Forbid using TransferContract & TransferAssetContract for contract accounttaihao.fu@gmail.comStandards TrackVMtrueFinal
TIP 41Optimize transactionHistoryStore occupancy spacewubin1@tron.networkStandards TrackCorefalseFinal
TIP 43Precompiled contract function for signature parallel verificationksl2945@gmail.comStandards TrackVMtrueFinal
TIP 44Address.isContract instructionsllwslc@gmail.comStandards TrackVMtrueFinal
TIP 51Rate limit of API trafficshydesky@gmail.comStandards TrackInterfacefalseFinal
TIP 53Optimize the current TRON delegation mechanismliangzhiyan@tron.networkStandards TrackCoretrueFinal
TIP 54Automatically active non-existent account when transferring TRX/TRC10 asset in a smart contractjiangxinjian@tron.networkStandards TrackVMtrueFinal
TIP 60Precompiled contract function for multi-signature verificationksl2945@gmail.comStandards TrackVMtrueAccepted
TIP 62Tron consensus algorithm introductionxing@tron.networkStandards TrackCorefalseFinal
TIP 64Tron tron mix consensus Analyticsxing@tron.networkStandards TrackCorefalseDraft
TIP 101Wallet Keystore Specificationfederico.zhen@tron.networkStandards TrackTRCfalseLast Call
TIP 102Hierarchical Deterministic Walletfederico.zhen@tron.networkStandards TrackTRCfalseLast Call
TIP 104Data Signing Specificationfederico.zhen@tron.networkStandards TrackTRCfalseLast Call
TIP 105Multi-signature Permission Operationfederico.zhen@tron.networkStandards TrackTRCtrueFinal
TIP 120ECDSA Signature Encoding Specificationfederico.zhen@tron.networkStandards TrackTRCfalseFinal
TIP 127Support Tron-DEX based on system contractsliu.sean@tron.networkStandards TrackCOREfalseDraft
TIP 128TIP128 Lite Fullnode supportray.wu@tron.networkStandards TrackCOREfalseDraft
TIP 135Shielded TRC-20 Contractfederico.zhen@tron.networkStandards TrackTRCfalseFinal
TIP 137Zero-knowledge Proof Verification functionsfederico.zhen@tron.networkStandards TrackVMtrueFinal
TIP 138Pedersen hash functionfederico.zhen@tron.networkStandards TrackVMtrueFinal
TIP 156Vote instructions in TVMtaihao.fu@gmail.comStandards TrackVMtrueWithdrawn
TIP 157Freeze instructions in TVMtaihao.fu@gmail.comStandards TrackVMtrueFinal
TIP 165TRC-165 Standard Interface Detection In Contracttimothychungkitwai@gmail.comStandards TrackTRCtrueFinal
TIP 171STAKE instructions in TVMtaihao.fu@gmail.comStandards TrackVMtrueWithdrawn
TIP 174CHAINID instructions in TVMtaihao.fu@gmail.comStandards TrackVMtrueFinal
TIP 175SELFBALANCE instructions in TVMtaihao.fu@gmail.comStandards TrackVMtrueFinal
TIP 176altbn128 operation energy reduction in TVMtaihao.fu@gmail.comStandards TrackVMtrueFinal
TIP 178TOKENISSUE and UPDATEASSET Instruction in TVMtaihao.fu@gmail.comStandards TrackVMtrueWithdrawn
TIP 196Reward SRs with the transaction fees charged for bandwidth and Energyliu.sean@tron.networkStandards TrackCoretrueFinal
TIP 204Make MAX_FEE_LIMIT configurable as a chain propertyyanghang8612@163.comStandards TrackVMfalseFinal
TIP 207A proposal to improve network resources modelliu.sean@tron.networkStandards TrackCoretrueDraft
TIP 209Adapt to Solidity 0.6.0neo.hong@tron.networkStandards TrackVMfalseFinal
TIP 250Include transaction results on the chainandy.zhang@tron.networkStandards TrackCoretrueFinal
TIP 268SmartContract ABI optimizationyanghang8612@163.comStandards TrackVMfalseFinal
TIP 269Optimize the performance of block processingforfreeday@163.comStandards TrackCorefalseFinal
TIP 271Vote for SR in Smart Contractyanghang8612@163.comStandards TrackVMtrueFinal
TIP 272Compatible with EVMyanghang8612@163.comStandards TrackVMtrueFinal
TIP 276Optimize block verification logiclucas.wu@tron.networkStandards TrackCorefalseFinal
TIP 281Optimize the query of databaseforfreeday@163.comStandards TrackCorefalseFinal
TIP 285Node startup optimizationlucas.wu@tron.networkStandards TrackCorefalseFinal
TIP 289Block Broadcast Optimizationlucas.wu@tron.networkStandards TrackCoretrueFinal
TIP 290Dynamic store optimizationlucas.wu@tron.networkStandards TrackCoretrueFinal
TIP 292Add a proposal to adjust the free net limit in an accountfederico.zhen@tron.networkStandards TrackTRCtrueFinal
TIP 293Add a proposal to adjust the total net limitfederico.zhen@tron.networkStandards TrackTRCtrueFinal
TIP 295Optimize assets of accountforfreeday@163.comStandards TrackCorefalseFinal
TIP 298Reformat manifesthalibobo1205@gmail.comStandards TrackCorefalseFinal
TIP 306Adapt to solidity_0.8.4neo.hong@tron.networkStandards TrackVMfalseFinal
TIP 318Adapt to Ethereum London Upgradeneo.hong@tron.networkStandards TrackVMfalseFinal
TIP 343DB params optimizationhalibobo1205@gmail.comStandards TrackCorefalseDraft
TIP 344Optimize instruction execution for TVMyanghang8612@163.comStandards TrackVMfalseFinal
TIP 362Optimized node broadcast data cachingforfreeday@163.comStandards TrackCorefalseFinal
TIP 366Node startup optimizationhalibobo1205@gmail.comStandards TrackCorefalseFinal
TIP 721TRC-721 Non-Fungible Token Standardtimothychungkitwai@gmail.comStandards TrackTRCtrueFinal

To Submit a TIP

Before you submit a TIP, you need to create an issue for comment and add the issue URL to your TIP header.

1. Fork the repository by clicking "Fork" in the top right.

2. Add your TIP to your fork of the repository. There is a TIP template here.

3. Submit a Pull Request to TRON's TIPs repository.

Your first PR should be a first draft of the final TIP. It must meet the formatting criteria enforced by the build (largely, correct metadata in the header). An editor will manually review the first PR for a new TIP and assign it a number before merging it.

Make sure you include a discussions-to header with the URL to a discussion forum or open GitHub issue where people can discuss the TIP as a whole. If a TIP is about the feature development of java-tron, and a PR of the development exists, in your TIP and your java-tron's PR you need to refer each other's github link.

When you believe your TIP is mature and ready to progress past the draft phase, you should do one of two things:

For a Standards Track TIP of type Core, ask to have your issue added to the agenda of an upcoming All Core Devs meeting, where it can be discussed for inclusion in a future hard fork. If implementers agree to include it, the TIP editors will update the state of your TIP to 'Accepted'.

For all other TIPs, open a PR changing the state of your TIP to 'Final'. An editor will review your draft and ask if anyone objects to its being finalized. If the editor decides there is no rough consensus, they may close the PR and request you fix the issues in the draft before trying again.

TIP Status

TIPs are separated into several statuses.

Draft: A TIP that is undergoing rapid iteration and changes.

Last Call: A TIP that is done with its initial iteration and ready for review by a wide audience.

Accepted: A core TIP that has been in the Last Call for at least 2 weeks and any technical changes that were requested have been addressed by the author. The process for Core Devs to decide whether to encode a TIP into their clients as part of a hard fork is not part of the TIP process. If such a decision is made, the TIP will move to the final.

Final (non-Core): A TIP that has been in the Last Call for at least 2 weeks and any technical changes that were requested have been addressed by the author.

Final (Core): A TIP that the Core Devs have decided to implement and release in a future version or has already been released.

Active: If the TIPs are never meant to be completed, the TIPs may have a status of “Active”.

Abandoned: If a TIP is no longer pursued by the original authors or it may not be a (technically) preferred option anymore.

Rejected: A TIP that is fundamentally broken or a Core TIP that was rejected by the Core Devs and will not be implemented.

Superseded: A TIP which was previously Final but is no longer considered state-of-the-art. Another TIP will be in the Final status and cite the Superseded TIP.

Deferred: A TIP which isn't accepted now, it may be accepted in the future.

TIP Types

TIPs are separated into several types, and each has its list of TIPs.

Standard Track: Describes any change that affects most or all TRON implementations, such as a change in block or transaction validity rules, proposed application standards/conventions, or any change or addition that affects the interoperability of applications using TRON. Furthermore, Standard TIPs can be broken down into the following categories.

1.Core: Improvements requiring a consensus fork, as well as changes that are not necessarily consensus critical but may be relevant to "core dev" discussions.

2.Networking: Includes improvements around network protocol.

3.Interface: Includes improvements around client API/RPC specifications and standards.

4.TRC: Application-level standards and conventions, including contract standards such as token standards (TRC-20).

5.VM: Includes improvements around TRON Virtual Machine.

Informational: Describes a TRON design issue, or provides general guidelines or information to the TRON community, but does not propose a new feature.

For further discussion, please enter Telegram

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/tips
License:

#tron  #blockchain  #smartcontract 

TRON Improvement Proposals

Wallet Cli for Tron Protocol

wallet-cli

Welcome to use the Wallet-CLI.

If you need any help, please join the Telegram

Get started

Download wallet-cli

git clone https://github.com/tronprotocol/wallet-cli.git

Edit config.conf in src/main/resources

net {
  type = mainnet
  # type = testnet
}

fullnode = {
  ip.list = [
    "fullnode ip : port"
  ]
}

soliditynode = {
  // the IPs in this list can only be totally set to solidity or pBFT.
  ip.list = [
    "ip : solidity port" // default solidity
  ]
#  ip.list = [
#    "ip : pBFT port" // or pBFT
#  ]
} // NOTE: solidity node is optional

blockNumberStartToScan = 22690588 // NOTE: this field is optional

Run a web wallet

  • connect to fullNode and solidityNode

Take a look at: java-tron deployment Run both fullNode and solidity node in either your local PC or remote server.

NOTE: These nodes would consume a lot of memory and CPU. Please be aware if you do not use wallet, just kill them.

  • compile and run web wallet
$ cd wallet-cli
$ ./gradlew build
$ cd build/libs
$ java -jar wallet-cli.jar

Connect to java-tron

Wallet-cli connect to java-tron via gRPC protocol, which can be deployed locally or remotely. Check Run a web Wallet section. We can configure java-tron node IP and port in src/main/resources/config.conf, so that wallet-cli server can successfully talk to java-tron nodes.

Wallet-cli supported command list

Following is a list of Tron Wallet-cli commands: For more information on a specific command, just type the command on terminal when you start your Wallet.

AddTransactionSignApproveProposalAssetIssue
BackupShieldedTRC20WalletBackupWalletBackupWallet2Base64
BroadcastTransactionChangePasswordCreateProposal
DeleteProposalDeployContractExchangeCreate
ExchangeInjectExchangeTransactionExchangeWithdraw
FreezeBalanceGenerateAddressGenerateShieldedTRC20Address
GetAccountGetAccountNetGetAccountResource
GetAddressGetAkFromAskGetAssetIssueByAccount
GetAssetIssueByIdGetAssetIssueByNameGetAssetIssueListByName
GetBalanceGetBlockGetBlockById
GetBlockByLatestNumGetBlockByLimitNextGetBrokerage
GetContractGetDelegatedResourceGetDelegatedResourceAccountIndex
GetDiversifierGetExpandedSpendingKeyGetIncomingViewingKey
GetMarketOrderByAccountGetMarketOrderByIdGetMarketOrderListByPair
GetMarketPairListGetMarketPriceByPairGetNextMaintenanceTime
GetNkFromNskGetProposalGetShieldedPaymentAddress
GetSpendingKeyGetRewardGetTransactionApprovedList
GetTransactionByIdGetTransactionCountByBlockNumGetTransactionInfoByBlockNum
GetTransactionInfoByIdGetTransactionSignWeightImportShieldedTRC20Wallet
ImportWalletImportWalletByBase64ListAssetIssue
ListExchangesListExchangesPaginatedListNodes
ListShieldedTRC20AddressListShieldedTRC20NoteListProposals
ListProposalsPaginatedListWitnessesLoadShieldedTRC20Wallet
LoginMarketCancelOrderMarketSellAsset
ParticipateAssetIssueRegisterWalletResetShieldedTRC20Note
ScanShieldedTRC20NoteByIvkScanShieldedTRC20NoteByOvkSendCoin
SendShieldedTRC20CoinSendShieldedTRC20CoinWithoutAskSetShieldedTRC20ContractAddress
ShowShieldedTRC20AddressInfoTransferAssetTriggerContract
UnfreezeAssetUnfreezeBalanceUpdateAsset
UpdateBrokerageUpdateEnergyLimitUpdateSetting
UpdateAccountPermissionVoteWitness 

Type any one of the listed commands, to display how-to tips.

How to freeze/unfreeze balance

After the funds are frozen, the corresponding number of shares and bandwidth will be obtained. Shares can be used for voting and bandwidth can be used for trading. The rules for the use and calculation of share and bandwidth are described later in this article.

Freeze operation is as follows:

> freezeBalance [OwnerAddress] frozen_balance frozen_duration [ResourceCode:0 BANDWIDTH, 1 ENERGY] [receiverAddress]

OwnerAddress

The address of the account that initiated the transaction, optional, default is the address of the login account.

frozen_balance

The amount of frozen funds, the unit is Sun. The minimum value is 1000000 Sun(1TRX).

frozen_duration

Freeze time, this value is currently only allowed for 3 days.

For example:

> freezeBalance 100000000 3 1 address

After the freeze operation, frozen funds will be transferred from Account Balance to Frozen, You can view frozen funds from your account information. After being unfrozen, it is transferred back to Balance by Frozen, and the frozen funds cannot be used for trading.

When more share or bandwidth is needed temporarily, additional funds may be frozen to obtain additional share and bandwidth. The unfrozen time is postponed until 3 days after the last freeze operation

After the freezing time expires, funds can be unfroze.

Unfreeze operation is as follows:

> unfreezeBalance [OwnerAddress] ResourceCode(0 BANDWIDTH, 1 CPU) [receiverAddress]

How to vote

Voting requires share. Share can be obtained by freezing funds.

  • The share calculation method is: 1 unit of share can be obtained for every 1TRX frozen.
  • After unfreezing, previous vote will expire. You can avoid the invalidation of the vote by re-freezing and voting.

NOTE The Tron Network only records the status of your last vote, which means that each of your votes will overwrite all previous voting results.

For example:

> freezeBalance 100000000 3 1 address  # Freeze 10TRX and acquire 10 units of shares

> votewitness 123455 witness1 4 witness2 6  # Cast 4 votes for witness1 and 6 votes for witness2 at the same time

> votewitness 123455 witness1 10  # Voted 10 votes for witness1

The final result of the above command was 10 votes for witness1 and 0 vote for witness2.

Brokerage

After voting for the witness, you will receive the rewards. The witness has the right to decide the ratio of brokerage. The default ratio is 20%, and the witness can adjust it.

By default, if a witness is rewarded, he will receive 20% of the whole rewards, and 80% of the rewards will be distributed to his voters.

GetBrokerage

View the ratio of brokerage of the witness.

> getbrokerage OwnerAddress

OwnerAddress

The address of the witness's account, it is a base58check type address.

GetReward

Query unclaimed reward.

> getreward OwnerAddress

OwnerAddress

The address of the voter's account, it is a base58check type address.

UpdateBrokerage

Update the ratio of brokerage, this command is usually used by a witness account.

> updateBrokerage OwnerAddress brokerage

OwnerAddress

The address of the witness's account, it is a base58check type address.

brokerage

The ratio of brokerage you want to update to, the limit of it: 0-100.

For example:

> getbrokerage TZ7U1WVBRLZ2umjizxqz3XfearEHhXKX7h  

> getreward  TNfu3u8jo1LDWerHGbzs2Pv88Biqd85wEY

> updateBrokerage TZ7U1WVBRLZ2umjizxqz3XfearEHhXKX7h 30

How to calculate bandwidth

The bandwidth calculation rule is:

constant * FrozenFunds * days

Assuming freeze 1TRX(1_000_000 Sun), 3 days, bandwidth obtained = 1 * 1_000_000 * 3 = 3_000_000.

All contracts consume bandwidth, including transferring, transferring of assets, voting, freezing, etc. Querying does not consume bandwidth. Each contract needs to consume 100_000 bandwidth.

If a contract exceeds a certain time (10s), this operation does not consume bandwidth.

When the unfreezing operation occurs, the bandwidth is not cleared. The next time the freeze is performed, the newly added bandwidth is accumulated.

How to withdraw balance

After each block is produced, the block award is sent to the account's allowance, and a withdraw operation is allowed every 24 hours from allowance to balance. The funds in allowance cannot be locked or traded.

How to create witness

Applying to become a witness account needs to consume 100_000TRX. This part of the funds will be burned directly.

How to create account

It is not allowed to create accounts directly. You can only create accounts by transferring funds to non-existing accounts. Transferring to a non-existent account has minimum restriction amount of 1TRX.

Command line operation flow example

$ cd wallet-cli
$ ./gradlew build
$ ./gradlew run
> RegisterWallet 123456      (password = 123456)
> login 123456
> getAddress
address = TRfwwLDpr4excH4V4QzghLEsdYwkapTxnm'  # backup it!
> BackupWallet 123456
priKey = 075725cf903fc1f6d6267b8076fc2c6adece0cfd18626c33427d9b2504ea3cef'  # backup it!!! (BackupWallet2Base64 option)
> getbalance
Balance = 0
> AssetIssue TestTRX TRX 75000000000000000 1 1 2 "2019-10-02 15:10:00" "2020-07-11" "just for test121212" www.test.com 100 100000 10000 10 10000 1
> getaccount TRfwwLDpr4excH4V4QzghLEsdYwkapTxnm
(Print balance: 9999900000
"assetV2": [
    {
        "key": "1000001",
        "value": 74999999999980000
    }
],)
  # (cost trx 1000 trx for assetIssue)
  # (You can query the trx balance and other asset balances for any account )
> TransferAsset TWzrEZYtwzkAxXJ8PatVrGuoSNsexejRiM 1000001 10000

How to issue a TRC10 token

Each account can only issue ONE TRC10 token.

Issue TRC10 tokens

> AssetIssue [OwnerAddress] AssetName AbbrName TotalSupply TrxNum AssetNum Precision StartDate EndDate Description Url FreeNetLimitPerAccount PublicFreeNetLimit FrozenAmount0 FrozenDays0 [...] FrozenAmountN FrozenDaysN

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

AssetName

The name of the issued TRC10 token

AbbrName

The abbreviation of TRC10 token

TotalSupply

TotalSupply = Account Balance of Issuer + All Frozen Token Amount TotalSupply: Total Issuing Amount Account Balance Of Issuer: At the time of issuance All Frozen Token Amount: Before asset transfer and the issuance

TrxNum, AssetNum

These two parameters determine the exchange rate when the token is issued. Exchange Rate = TrxNum / AssetNum AssetNum: Unit in base unit of the issued token TrxNum: Unit in SUN (0.000001 TRX)

Precision

Precision to how many decimal places

FreeNetLimitPerAccount

The maximum amount of bandwidth each account is allowed to use. Token issuers can freeze TRX to obtain bandwidth (TransferAssetContract only)

PublicFreeNetLimit

The maximum total amount of bandwidth which is allowed to use for all accounts. Token issuers can freeze TRX to obtain bandwidth (TransferAssetContract only)

StartDate, EndDate

The start and end date of token issuance. Within this period time, other users can participate in token issuance.

FrozenAmount0 FrozenDays0

Amount and days of token freeze. FrozenAmount0: Must be bigger than 0 FrozenDays0: Must between 1 and 3653.

Example:

> AssetIssue TestTRX TRX 75000000000000000 1 1 2 "2019-10-02 15:10:00" "2020-07-11" "just for test121212" www.test.com 100 100000 10000 10 10000 1
> GetAssetIssueByAccount TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ  # View published information
{
    "assetIssue": [
        {
            "owner_address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
            "name": "TestTRX",
            "abbr": "TRX",
            "total_supply": 75000000000000000,
            "frozen_supply": [
                {
                    "frozen_amount": 10000,
                    "frozen_days": 1
                },
                {
                    "frozen_amount": 10000,
                    "frozen_days": 10
                }
            ],
            "trx_num": 1,
            "precision": 2,
            "num": 1,
            "start_time": 1570000200000,
            "end_time": 1594396800000,
            "description": "just for test121212",
            "url": "www.test.com",
            "free_asset_net_limit": 100,
            "public_free_asset_net_limit": 100000,
            "id": "1000001"
        }
    ]
}

Update parameters of TRC10 token

> UpdateAsset [OwnerAddress] newLimit newPublicLimit description url

Specific meaning of the parameters is the same as that of AssetIssue.

Example:

> UpdateAsset 1000 1000000 "change description" www.changetest.com
> GetAssetIssueByAccount TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ  # View the modified information
{
    "assetIssue": [
        {
            "owner_address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
            "name": "TestTRX",
            "abbr": "TRX",
            "total_supply": 75000000000000000,
            "frozen_supply": [
                {
                    "frozen_amount": 10000,
                    "frozen_days": 1
                },
                {
                    "frozen_amount": 10000,
                    "frozen_days": 10
                }
            ],
            "trx_num": 1,
            "precision": 2,
            "num": 1,
            "start_time": 1570000200000,
            "end_time": 1594396800000,
            "description": "change description",
            "url": "www.changetest.com",
            "free_asset_net_limit": 1000,
            "public_free_asset_net_limit": 1000000,
            "id": "1000001"
        }
    ]
}

TRC10 token transfer

> TransferAsset [OwnerAddress] ToAddress AssertID Amount

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

ToAddress

Address of the target account

AssertName

TRC10 token ID Example: 1000001

Amount

The number of TRC10 token to transfer

Example:

> TransferAsset TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz 1000001 1000
> getaccount TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz  # View target account information after the transfer
address: TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz
    assetV2
    {
    id: 1000001
    balance: 1000
    latest_asset_operation_timeV2: null
    free_asset_net_usageV2: 0
    }

Participating in the issue of TRC10 token

> ParticipateAssetIssue [OwnerAddress] ToAddress AssetID Amount

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

ToAddress

Account address of TRC10 issuers

AssertName

TRC10 token ID Example: 1000001

Amount

The number of TRC10 token to transfers

The participation process must happen during the release of TRC10, otherwise an error may occur.

Example:

> ParticipateAssetIssue TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ 1000001 1000
> getaccount TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW  # View remaining balance
address: TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW
assetV2
    {
    id: 1000001
    balance: 1000
    latest_asset_operation_timeV2: null
    free_asset_net_usageV2: 0
    }

Unfreeze TRC10 token

To unfreeze all TRC10 token which are supposed to be unfrozen after the freezing period.

> unfreezeasset [OwnerAddress]

How to obtain TRC10 token information

ListAssetIssue

Obtain all of the published TRC10 token information

GetAssetIssueByAccount

Obtain TRC10 token information based on issuing address

GetAssetIssueById

Obtain TRC10 token Information based on ID

GetAssetIssueByName

Obtain TRC10 token Information based on names

GetAssetIssueListByName

Obtain a list of TRC10 token information based on names

How to operate with proposal

Any proposal-related operations, except for viewing operations, must be performed by committee members.

Initiate a proposal

> createProposal [OwnerAddress] id0 value0 ... idN valueN

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

id0

The serial number of the parameter. Every parameter of TRON network has a serial number. Please refer to "http://tronscan.org/#/sr/committee"

Value0

The modified value

In the example, modification No.4 (modifying token issuance fee) costs 1000TRX as follows:

> createProposal 4 1000
> listproposals  # View initiated proposal
{
    "proposals": [
        {
            "proposal_id": 1,
            "proposer_address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
            "parameters": [
                {
                    "key": 4,
                    "value": 1000
                }
            ],
            "expiration_time": 1567498800000,
            "create_time": 1567498308000
        }
    ]
}

The corresponding id is 1.

Approve / Disapprove a proposal

> approveProposal [OwnerAddress] id is_or_not_add_approval

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

id

ID of the initiated proposal Example: 1

is_or_not_add_approval

true for approve; false for disapprove

Example:

> ApproveProposal 1 true  # in favor of the offer
> ApproveProposal 1 false  # Cancel the approved proposal

Delete an existed proposal

> deleteProposal [OwnerAddress] proposalId

proposalId

ID of the initiated proposal Example: 1

The proposal must be canceled by the supernode that initiated the proposal.

Example:

> DeleteProposal 1

Obtain proposal information

ListProposals

Obtain a list of initiated proposals

ListProposalsPaginated

Use the paging mode to obtain the initiated proposal

GetProposal

Obtain proposal information based on the proposal ID

How to trade on the exchange

The trading and price fluctuations of trading pairs are in accordance with the Bancor Agreement, which can be found in TRON's related documents.

Create a trading pair

> exchangeCreate [OwnerAddress] first_token_id first_token_balance second_token_id second_token_balance

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

First_token_id, first_token_balance

ID and amount of the first token

second_token_id, second_token_balance

ID and amount of the second token

The ID is the ID of the issued TRC10 token. If it is TRX, the ID is "_". The amount must be greater than 0, and less than 1,000,000,000,000,000.

Example:

> exchangeCreate 1000001 10000 _ 10000
# Create trading pairs with the IDs of 1000001 and TRX, with amount 10000 for both.

Capital injection

> exchangeInject [OwnerAddress] exchange_id token_id quant

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

exchange_id

The ID of the trading pair to be funded

token_id, quant

TokenId and quantity (unit in base unit) of capital injection

When conducting a capital injection, depending on its quantity (quant), a proportion of each token in the trading pair will be withdrawn from the account, and injected into the trading pair. Depending on the difference in the balance of the transaction, the same amount of money for the same token would vary.

Transactions

> exchangeTransaction [OwnerAddress] exchange_id token_id quant expected

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

exchange_id

ID of the trading pair

token_id, quant

The ID and quantity of tokens being exchanged, equivalent to selling

expected

Expected quantity of another token

expected must be less than quant, or an error will be reported.

Example:

> ExchangeTransaction 1 1000001 100 80

It is expected to acquire the 80 TRX by exchanging 1000001 from the trading pair ID of 1, and the amount is 100.(Equivalent to selling an amount of 100 tokenID - 1000001, at a price of 80 TRX, in trading pair ID - 1).

Capital Withdrawal

> exchangeWithdraw [OwnerAddress] exchange_id token_id quant

OwnerAddress (optional)

The address of the account which initiated the transaction. Default: the address of the login account.

Exchange_id

The ID of the trading pair to be withdrawn

Token_id, quant

TokenId and quantity (unit in base unit) of capital withdrawal

When conducting a capital withdrawal, depending on its quantity (quant), a proportion of each token in the transaction pair is withdrawn from the trading pair, and injected into the account. Depending on the difference in the balance of the transaction, the same amount of money for the same token would vary.

Obtain information on trading pairs

ListExchanges

List trading pairs

ListExchangesPaginated

List trading pairs by page

How to use the multi-signature feature of wallet-cli?

Multi-signature allows other users to access the account in order to better manage it. There are three types of accesses:

  • owner: access to the owner of account
  • active: access to other features of accounts, and access that authorizes a certain feature. Block production authorization is not included if it's for witness purposes.
  • witness: only for witness, block production authorization will be granted to one of the other users.

The rest of the users will be granted

> Updateaccountpermission TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ \
{
  "owner_permission": {
    "type": 0,
    "permission_name": "owner",
    "threshold": 1,
    "keys": [
      {
        "address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
        "weight": 1
      }
    ]
  },
  "witness_permission": {
    "type": 1,
    "permission_name": "owner",
    "threshold": 1,
    "keys": [
      {
        "address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
        "weight": 1
      }
    ]
  },
  "active_permissions": [
    {
      "type": 2,
      "permission_name": "active12323",
      "threshold": 2,
      "operations": "7fff1fc0033e0000000000000000000000000000000000000000000000000000",
      "keys": [
        {
          "address": "TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR",
          "weight": 1
        },
        {
          "address": "TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP",
          "weight": 1
        }
      ]
    }
  ]
}

The account TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ gives the owner access to itself, active access to TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR and TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP. Active access will need signatures from both accounts in order to take effect.

If the account is not a witness, it's not necessary to set witness_permission, otherwise an error will occur.

Signed transaction

> SendCoin TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW 10000000000000000

Will show "Please confirm and input your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction."

This will require the transfer authorization of active access. Enter: 2

Then select accounts and put in local password, i.e. TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR needs a private key TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR to sign a transaction.

Select another account and enter the local password. i.e. TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP will need a private key of TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP to sign a transaction.

The weight of each account is 1, threshold of access is 2. When the requirements are met, users will be notified with “Send 10000000000000000 Sun to TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW successful !!”.

This is how multiple accounts user multi-signature when using the same cli. Use the instruction addTransactionSign according to the obtained transaction hex string if signing at multiple cli. After signing, the users will need to broadcast final transactions manually.

Obtain weight information according to transaction

> getTransactionSignWeight
0a8c010a020318220860e195d3609c86614096eadec79d2d5a6e080112680a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412370a1541a7d8a35b260395c14aa456297662092ba3b76fc01215415a523b449890854c8fc460ab602df9f31fe4293f18808084fea6dee11128027094bcb8bd9d2d1241c18ca91f1533ecdd83041eb0005683c4a39a2310ec60456b1f0075b4517443cf4f601a69788f001d4bc03872e892a5e25c618e38e7b81b8b1e69d07823625c2b0112413d61eb0f8868990cfa138b19878e607af957c37b51961d8be16168d7796675384e24043d121d01569895fcc7deb37648c59f538a8909115e64da167ff659c26101

The information displays as follows:

{
    "result":{
        "code":"PERMISSION_ERROR",
        "message":"Signature count is 2 more than key counts of permission : 1"
    },
    "permission":{
        "operations":"7fff1fc0033e0100000000000000000000000000000000000000000000000000",
        "keys":[
            {
                "address":"TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
                "weight":1
            }
        ],
        "threshold":1,
        "id":2,
        "type":"Active",
        "permission_name":"active"
    },
    "transaction":{
        "result":{
            "result":true
        },
        "txid":"7da63b6a1f008d03ef86fa871b24a56a501a8bbf15effd7aca635de6c738df4b",
        "transaction":{
            "signature":[
                "c18ca91f1533ecdd83041eb0005683c4a39a2310ec60456b1f0075b4517443cf4f601a69788f001d4bc03872e892a5e25c618e38e7b81b8b1e69d07823625c2b01",
                "3d61eb0f8868990cfa138b19878e607af957c37b51961d8be16168d7796675384e24043d121d01569895fcc7deb37648c59f538a8909115e64da167ff659c26101"
            ],
            "txID":"7da63b6a1f008d03ef86fa871b24a56a501a8bbf15effd7aca635de6c738df4b",
            "raw_data":{
                "contract":[
                    {
                        "parameter":{
                            "value":{
                                "amount":10000000000000000,
                                "owner_address":"TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
                                "to_address":"TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW"
                            },
                            "type_url":"type.googleapis.com/protocol.TransferContract"
                        },
                        "type":"TransferContract",
                        "Permission_id":2
                    }
                ],
                "ref_block_bytes":"0318",
                "ref_block_hash":"60e195d3609c8661",
                "expiration":1554123306262,
                "timestamp":1554101706260
            },
            "raw_data_hex":"0a020318220860e195d3609c86614096eadec79d2d5a6e080112680a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412370a1541a7d8a35b260395c14aa456297662092ba3b76fc01215415a523b449890854c8fc460ab602df9f31fe4293f18808084fea6dee11128027094bcb8bd9d2d"
        }
    }
}

Get signature information according to transactions

> getTransactionApprovedList
0a8c010a020318220860e195d3609c86614096eadec79d2d5a6e080112680a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412370a1541a7d8a35b260395c14aa456297662092ba3b76fc01215415a523b449890854c8fc460ab602df9f31fe4293f18808084fea6dee11128027094bcb8bd9d2d1241c18ca91f1533ecdd83041eb0005683c4a39a2310ec60456b1f0075b4517443cf4f601a69788f001d4bc03872e892a5e25c618e38e7b81b8b1e69d07823625c2b0112413d61eb0f8868990cfa138b19878e607af957c37b51961d8be16168d7796675384e24043d121d01569895fcc7deb37648c59f538a8909115e64da167ff659c26101
{
    "result":{

    },
    "approved_list":[
        "TKwhcDup8L2PH5r6hxp5CQvQzZqJLmKvZP",
        "TNhXo1GbRNCuorvYu5JFWN3m2NYr9QQpVR"
    ],
    "transaction":{
        "result":{
            "result":true
        },
        "txid":"7da63b6a1f008d03ef86fa871b24a56a501a8bbf15effd7aca635de6c738df4b",
        "transaction":{
            "signature":[
                "c18ca91f1533ecdd83041eb0005683c4a39a2310ec60456b1f0075b4517443cf4f601a69788f001d4bc03872e892a5e25c618e38e7b81b8b1e69d07823625c2b01",
                "3d61eb0f8868990cfa138b19878e607af957c37b51961d8be16168d7796675384e24043d121d01569895fcc7deb37648c59f538a8909115e64da167ff659c26101"
            ],
            "txID":"7da63b6a1f008d03ef86fa871b24a56a501a8bbf15effd7aca635de6c738df4b",
            "raw_data":{
                "contract":[
                    {
                        "parameter":{
                            "value":{
                                "amount":10000000000000000,
                                "owner_address":"TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
                                "to_address":"TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW"
                            },
                            "type_url":"type.googleapis.com/protocol.TransferContract"
                        },
                        "type":"TransferContract",
                        "Permission_id":2
                    }
                ],
                "ref_block_bytes":"0318",
                "ref_block_hash":"60e195d3609c8661",
                "expiration":1554123306262,
                "timestamp":1554101706260
            },
            "raw_data_hex":"0a020318220860e195d3609c86614096eadec79d2d5a6e080112680a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412370a1541a7d8a35b260395c14aa456297662092ba3b76fc01215415a523b449890854c8fc460ab602df9f31fe4293f18808084fea6dee11128027094bcb8bd9d2d"
        }
    }
}

How to use smart contract

deploy smart contracts

> DeployContract [ownerAddress] contractName ABI byteCode constructor params isHex fee_limit consume_user_resource_percent origin_energy_limit value token_value token_id(e.g: TRXTOKEN, use # if don't provided) <library:address,library:address,...> <lib_compiler_version(e.g:v5)> library:address,...>

OwnerAddress

The address of the account that initiated the transaction, optional, default is the address of the login account.

contractName

Name of smart contract

ABI

Compile generated ABI code

byteCode

Compile generated byte code

constructor, params, isHex

Define the format of the bytecode, which determines the way to parse byteCode from parameters

fee_limit

Transaction allows for the most consumed TRX

consume_user_resource_percent

Percentage of user resource consumed, in the range [0, 100]

origin_energy_limit

The most amount of developer Energy consumed by trigger contract once

value

The amount of trx transferred to the contract account

token_value

Number of TRX10

token_id

TRX10 Id

Example:

> deployContract normalcontract544 [{"constant":false,"inputs":[{"name":"i","type":"uint256"}],"name": "findArgsByIndexTest","outputs":[{"name":"z","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
608060405234801561001057600080fd5b50610134806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b5061005d60043561006f565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100a657fe5b602090810290910101528051600290829060019081106100c257fe5b602090810290910101528051600390829060029081106100de57fe5b6020908102909101015280518190849081106100f657fe5b906020019060200201519150509190505600a165627a7a72305820b24fc247fdaf3644b3c4c94fcee380aa610ed83415061ff9e65d7fa94a5a50a00029 # # false 1000000000 75 50000 0 0 #

Get the result of the contract execution with the getTransactionInfoById command:

> getTransactionInfoById 4978dc64ff746ca208e51780cce93237ee444f598b24d5e9ce0da885fb3a3eb9
{
    "id": "8c1f57a5e53b15bb0a0a0a0d4740eda9c31fbdb6a63bc429ec2113a92e8ff361",
    "fee": 6170500,
    "blockNumber": 1867,
    "blockTimeStamp": 1567499757000,
    "contractResult": [
        "6080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b5061005d60043561006f565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100a657fe5b602090810290910101528051600290829060019081106100c257fe5b602090810290910101528051600390829060029081106100de57fe5b6020908102909101015280518190849081106100f657fe5b906020019060200201519150509190505600a165627a7a72305820b24fc247fdaf3644b3c4c94fcee380aa610ed83415061ff9e65d7fa94a5a50a00029"
    ],
    "contract_address": "TJMKWmC6mwF1QVax8Sy2AcgT6MqaXmHEds",
    "receipt": {
        "energy_fee": 6170500,
        "energy_usage_total": 61705,
        "net_usage": 704,
        "result": "SUCCESS"
    }
}

trigger smart contarct

> TriggerContract [ownerAddress] contractAddress method args isHex fee_limit value token_value token_id

OwnerAddress

The address of the account that initiated the transaction, optional, default is the address of the login account.

contractAddress

Smart contarct address

method

The name of function and parameters, please refer to the example

args

Parameter value, if you want to call receive, pass '#' instead

isHex

The format of the parameters method and args, is hex string or not

fee_limit

The most amount of trx allows for the consumption

token_value

Number of TRX10

token_id

TRC10 id, If not, use ‘#’ instead

Example:

> triggerContract TGdtALTPZ1FWQcc5MW7aK3o1ASaookkJxG findArgsByIndexTest(uint256) 0 false
1000000000 0 0 #
# Get the result of the contract execution with the getTransactionInfoById command
> getTransactionInfoById 7d9c4e765ea53cf6749d8a89ac07d577141b93f83adc4015f0b266d8f5c2dec4
{
    "id": "de289f255aa2cdda95fbd430caf8fde3f9c989c544c4917cf1285a088115d0e8",
    "fee": 8500,
    "blockNumber": 2076,
    "blockTimeStamp": 1567500396000,
    "contractResult": [
        ""
    ],
    "contract_address": "TJMKWmC6mwF1QVax8Sy2AcgT6MqaXmHEds",
    "receipt": {
        "energy_fee": 8500,
        "energy_usage_total": 85,
        "net_usage": 314,
        "result": "REVERT"
    },
    "result": "FAILED",
    "resMessage": "REVERT opcode executed"
}

get details of a smart contract

> GetContract contractAddress

contractAddress

smart contract address

Example:

> GetContract TGdtALTPZ1FWQcc5MW7aK3o1ASaookkJxG
{
    "origin_address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
    "contract_address": "TJMKWmC6mwF1QVax8Sy2AcgT6MqaXmHEds",
    "abi": {
        "entrys": [
            {
                "name": "findArgsByIndexTest",
                "inputs": [
                    {
                        "name": "i",
                        "type": "uint256"
                    }
                ],
                "outputs": [
                    {
                        "name": "z",
                        "type": "uint256"
                    }
                ],
                "type": "Function",
                "stateMutability": "Nonpayable"
            }
        ]
    },
    "bytecode": "608060405234801561001057600080fd5b50610134806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663329000b58114610045575b600080fd5b34801561005157600080fd5b5061005d60043561006f565b60408051918252519081900360200190f35b604080516003808252608082019092526000916060919060208201838038833901905050905060018160008151811015156100a657fe5b602090810290910101528051600290829060019081106100c257fe5b602090810290910101528051600390829060029081106100de57fe5b6020908102909101015280518190849081106100f657fe5b906020019060200201519150509190505600a165627a7a72305820b24fc247fdaf3644b3c4c94fcee380aa610ed83415061ff9e65d7fa94a5a50a00029",
    "consume_user_resource_percent": 75,
    "name": "normalcontract544",
    "origin_energy_limit": 50000,
    "code_hash": "23423cece3b4866263c15357b358e5ac261c218693b862bcdb90fa792d5714e6"
}

update smart contract parameters

> UpdateEnergyLimit [ownerAddress] contract_address energy_limit  # Update parameter energy_limit
> UpdateSetting [ownerAddress] contract_address consume_user_resource_percent  # Update parameter consume_user_resource_percent

How to delegate resource

delegate resource

> freezeBalance [OwnerAddress] frozen_balance frozen_duration [ResourceCode:0 BANDWIDTH, 1 ENERGY] [receiverAddress]

The latter two parameters are optional parameters. If not set, the TRX is frozen to obtain resources for its own use; if it is not empty, the acquired resources are used by receiverAddress.

OwnerAddress

The address of the account that initiated the transaction, optional, default is the address of the login account.

frozen_balance

The amount of frozen TRX, the unit is the smallest unit (Sun), the minimum is 1000000sun.

frozen_duration

frezen duration, 3 days

ResourceCode

0 BANDWIDTH;1 ENERGY

receiverAddress

target account address

unfreeze delegated resource

> unfreezeBalance [OwnerAddress] ResourceCode(0 BANDWIDTH, 1 CPU) [receiverAddress]

The latter two parameters are optional. If they are not set, the BANDWIDTH resource is unfreeze by default; when the receiverAddress is set, the delegate resources are unfreezed.

get resource delegation information

getDelegatedResource fromAddress toAddress

get the information from the fromAddress to the toAddress resource delegate

getDelegatedResourceAccountIndex address

get the information that address is delegated to other account resources

Wallet related commands

RegisterWallet

Register your wallet, you need to set the wallet password and generate the address and private key.

BackupWallet

Back up your wallet, you need to enter your wallet password and export the private key.hex string format, such as: 721d63b074f18d41c147e04c952ec93467777a30b6f16745bc47a8eae5076545

BackupWallet2Base64

Back up your wallet, you need to enter your wallet password and export the private key.base64 format, such as: ch1jsHTxjUHBR+BMlS7JNGd3ejC28WdFvEeo6uUHZUU=

ChangePassword

Modify the password of an account

ImportWallet

Import wallet, you need to set a password, hex String format

ImportWalletByBase64

Import wallet, you need to set a password, base64 fromat

Account related commands

GenerateAddress

Generate an address and print out the public and private keys

GetAccount

Get account information based on address

GetAccountNet

The usage of bandwidth

GetAccountResource

The usage of bandwidth and energy

GetAddress

Get the address of the current login account

GetBalance

Get the balance of the current login account

How to get transaction information

GetTransactionById

Get transaction information based on transaction id

GetTransactionCountByBlockNum

Get the number of transactions in the block based on the block height

GetTransactionInfoById

Get transaction-info based on transaction id, generally used to check the result of a smart contract trigger

GetTransactionInfoByBlockNum

Get the list of transaction information in the block based on the block height

How to get block information

GetBlock

Get the block according to the block number; if you do not pass the parameter, get the latest block

GetBlockById

Get block based on blockID

GetBlockByLatestNum n

Get the latest n blocks, where 0 < n < 100

GetBlockByLimitNext startBlockId endBlockId

Get the block in the range [startBlockId, endBlockId)

Some others

GetNextMaintenanceTime

Get the start time of the next maintain period

ListNodes

Get other peer information

ListWitnesses

Get all miner node information

BroadcastTransaction

Broadcast the transaction, where the transaction is in hex string format.

How to transfer shielded TRC20 token

If you want to try to transfer shielded TRC20 token, you'd better set the blockNumberStartToScan field in config.conf file. This field is used to set the starting block that the wallet needs to scan. If you ignore this field, or set it to 0, the notes you receive will probably take a long time to show up in the wallet. It is recommended that this field is set to the block number in which the earliest relevant shielded contract was created. If the exact number is not known, this field can be set as follows. If used in mainnet, please set 22690588. If used in Nile testnet, please set 6380000. Otherwise, please set 0.

When you begin to transfer TRC20 token to shielded address, you must have a shielded address. The following commands help to generate shielded account.

GetSpendingKey

Generate a sk

Example:

> GetSpendingKey
0eb458b309fa544066c40d80ce30a8002756c37d2716315c59a98c893dbb5f6a

GetExpandedSpendingKey

> GetExpandedSpendingKey sk

Generate ask, nsk, ovk from sk

Example:

> GetExpandedSpendingKey 0eb458b309fa544066c40d80ce30a8002756c37d2716315c59a98c893dbb5f6a
ask:252a0f6f6f0bac114a13e1e663d51943f1df9309649400218437586dea78260e
nsk:5cd2bc8d9468dbad26ea37c5335a0cd25f110eaf533248c59a3310dcbc03e503
ovk:892a10c1d3e8ea22242849e13f177d69e1180d1d5bba118c586765241ba2d3d6

GetAkFromAsk

> GetAkFromAsk ask

Generate ak from ask

Example:

> GetAkFromAsk 252a0f6f6f0bac114a13e1e663d51943f1df9309649400218437586dea78260e
ak:f1b843147150027daa5b522dd8d0757ec5c8c146defd8e01b62b34cf917299f1

GetNkFromNsk

> GetNkFromNsk nsk

Generate nk from nsk

Example:

> GetNkFromNsk 5cd2bc8d9468dbad26ea37c5335a0cd25f110eaf533248c59a3310dcbc03e503
nk:ed3dc885049f0a716a4de8c08c6cabcad0da3c437202341aa3d9248d8eb2b74a

GetIncomingViewingKey

> GetIncomingViewingKey ak[64] nk[64]

Generate ivk from ak and nk

Example:

> Getincomingviewingkey f1b843147150027daa5b522dd8d0757ec5c8c146defd8e01b62b34cf917299f1
 ed3dc885049f0a716a4de8c08c6cabcad0da3c437202341aa3d9248d8eb2b74a
ivk:148cf9e91f1e6656a41dc9b6c6ee4e52ff7a25b25c2d4a3a3182d0a2cd851205

GetDiversifier

Generate a diversifier

Example:

> GetDiversifier
11db4baf6bd5d5afd3a8b5

GetShieldedPaymentAddress

> GetShieldedPaymentAddress ivk[64] d[22]

Generate a shielded address from ivk and d

Example:

> GetShieldedPaymentAddress 148cf9e91f1e6656a41dc9b6c6ee4e52ff7a25b25c2d4a3a3182d0a2cd851205
 11db4baf6bd5d5afd3a8b5
pkd:65c11642115d386ed716b9cc06a3498e86e303d7f20d0869c9de90e31322ac15
shieldedAddress:ztron1z8d5htmt6h26l5agk4juz9jzz9wnsmkhz6uucp4rfx8gdccr6leq6zrfe80fpccny2kp2cray8z

SetShieldedTRC20ContractAddress

> SetShieldedTRC20ContractAddress TRC20ContractAddress ShieldedContractAddress

TRC20ContractAddress

TRC20 contract address

ShieldedContractAddress

Shielded contract address

Set TRC20 contract address and shielded contract address. Please execute this command before you perform all the following operations related to the shielded transaction of TRC20 token except ScanShieldedTRC20NoteByIvk and ScanShieldedTRC20NoteByOvk.

When you execute this command, the Scaling Factor will be shown. The Scaling Factor is set in the shielded contract.

Example:

> SetShieldedTRC20ContractAddress TLDxNTzNvEPd4gHox8V1zK2w82LFnideKE TKERuAmhJh8vZi1dzJtx8926xeCT74747e
scalingFactor():ed3437f8
SetShieldedTRC20ContractAddress succeed!
The Scaling Factor is 1000
That means:
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

LoadShieldedTRC20Wallet

Load TRC20 shielded address, shielded note and start to scan by ivk.

Example:

> LoadShieldedTRC20Wallet
Please input your password for shieldedTRC20 wallet.
> *******
LoadShieldedTRC20Wallet successful !!!

GenerateShieldedTRC20Address

> GenerateShieldedTRC20Address number

number

The number of TRC20 shielded addresses, the default is 1.

Generate TRC20 shielded addresses.

Example:

> GenerateShieldedTRC20Address 3
ShieldedTRC20Address list:
ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf
ztron109r3w5gpm0qcf67r67a9ftjt3zy9wmzux4fqgtgcql8gwhcmauv5dm6t9t9x9ht7h3lvs8shxhq
GenerateShieldedTRC20Address successful !!!

ListShieldedTRC20Address

Display cached local TRC20 shielded address list.

Example:

> ListShieldedTRC20Address
ShieldedTRC20Address :
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf
ztron109r3w5gpm0qcf67r67a9ftjt3zy9wmzux4fqgtgcql8gwhcmauv5dm6t9t9x9ht7h3lvs8shxhq
ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc
ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46

SendShieldedTRC20Coin

SendShieldedTRC20Coin fromAmount shieldedInputNum input1 input2 ... publicToAddress toAmount shieldedOutputNum shieldedAddress1 amount1 memo1 shieldedAddress2 amount2 memo2 ....

Shielded transfer, support three types:

  • MINT: transfer from one public address to one shielded address, fromAmount should be equal to the shielded output amount. When you MINT, you need to enter password twice as prompted, one time is for triggering approve method of TRC20 contract that allows the shielded contract can transfer form your account, and other one is for triggering mint method of shielded contract that executes MINT. It's important to remember that you must use the same public address to trigger these two methods.
  • TRANSFER: transfer from one or two shielded address(es) to one or two shielded address(es), the sum of shielded input amount should be equal to the sum of shielded output amount. When you TRANSFER, you need to enter password of public account as prompted, and this is used to trigger 'transfer' method of shielded contract that executes TRANSFER.
  • BURN: transfer from one shielded address to one public address and one optional shielded address. If there is no shielded output, toAmount should be equal to the shielded input amount , otherwise, the sum of toAmount and shielded output amount should be equal to the shielded input amount. When you BURN, you need to enter password of public account as prompted, and this is used to trigger 'burn' method of shielded contract that executes BURN.

It's better to use different accounts to trigger BURN, TRANSFER and MINT.

fromAmount

The amount transfer from public address. If the transfer type is MINT, this variable must be equal to the shielded output amount, otherwise it must be 0.

shieldedInputNum

The number of shielded input note, should be 0, 1 or 2. If the transfer type is MINT, this variable must be 0; if BURN, it must be 1.

input1/input2

The index of shielded input note, get from executing command ListShieldedTRC20Note. If shieldedInputNum set to 0, no need to set.

publicToAddress

Public to address. If the transfer type is BURN, this variable must be a valid address, otherwise it should be set null.

toAmount

The amount transfer to public address. If the transfer type is BURN, this variable must be equal to the shielded input amount, otherwise it should be 0.

shieldedOutputNum

The amount of shielded output note. That is the number of (shieldedAddress amount memo) pairs, should be 0, 1 or 2.

shieldedAddress1/shieldedAddress2

Output shielded address

amount1/amount2

The amount transfer to shieldedAddress1/shieldedAddress2

memo1/memo2

The memo of this note, up to 512 bytes, can be set to null if not needed.

Example:

In this example, the scalingFactor is 1000.

  1. MINT

In this mode, some variables must be set as follows, shieldedInputNum = 0, publicToAddress = null, toAmount = 0.

> SendShieldedTRC20Coin 1000000000000 0 null 0 1 ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1000000000000 null

2.   TRANSFER

In this mode, some variables must be set as follows, fromAmount = 0, publicToAddress = null,toAmount = 0.

Transfer from one shielded address to one shielded address.

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
9 ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 2000000000000 23f171f6552680b553707715bead8de807a70255c0b091f7e788bf3b59fe3bea 1 UnSpend
8 ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1000000000000 23f171f6552680b553707715bead8de807a70255c0b091f7e788bf3b59fe3bea 0 UnSpend
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

> SendShieldedTRC20Coin 0 1 8 null 0 1 ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1000000000000 null

Transfer from one shielded address to two shielded addresses.

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
9 ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 2000000000000 23f171f6552680b553707715bead8de807a70255c0b091f7e788bf3b59fe3bea 1 UnSpend
10 ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1000000000000 81a06080f2be3f795c506826e066b9bb5327ca234eb31a0ef2446e11339a3935 0 UnSpend
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

> SendShieldedTRC20Coin 0 1 9 null 0 2 ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1500000000000 test1 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 500000000000 null

Transfer from two shielded addresses to one shielded address.

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
11 ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1500000000000 35901973a96369618e5e3f7f4dcede2b5ddb5bc99bf6feac29f2706420ea99c0 0 UnSpend test1
10 ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1000000000000 81a06080f2be3f795c506826e066b9bb5327ca234eb31a0ef2446e11339a3935 0 UnSpend
12 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 500000000000 35901973a96369618e5e3f7f4dcede2b5ddb5bc99bf6feac29f2706420ea99c0 1 UnSpend
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000    

> SendShieldedTRC20Coin 0 2 10 11 null 0 1 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 2500000000000 null

Transfer from two shielded addresses to two shielded addresses.

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
13 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 2500000000000 6ec74435e32261a6dfe10f9498b3ab5a5cfede7c4e31299752b449b9506efc11 0 UnSpend
12 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 500000000000 35901973a96369618e5e3f7f4dcede2b5ddb5bc99bf6feac29f2706420ea99c0 1 UnSpend   
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

> SendShieldedTRC20Coin 0 2 12 13 null 0 2 ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1300000000000 null ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 1700000000000 null

3.   BURN

In this mode, some variables must be set as follows, fromAmount = 0, shieldedInputNum = 1.

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
15 ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 1700000000000 7291b2c58cafb4dede626388f12e846470441f9bb05581221fd742bdd8909a24 1 UnSpend
14 ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1300000000000 7291b2c58cafb4dede626388f12e846470441f9bb05581221fd742bdd8909a24 0 UnSpend
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

> SendShieldedTRC20Coin 0 1 14 TDVr15jvAx6maR28tP7RRpxuKZ38tgsyNE 1300000000000000 0
> SendShieldedTRC20Coin 0 1 14 TDVr15jvAx6maR28tP7RRpxuKZ38tgsyNE 300000000000000 1 ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 1000000000000000 null

SendShieldedTRC20CoinWithoutAsk

Usage and parameters are consistent with the command SendShieldedTRC20Coin, the only difference is that SendShieldedTRC20Coin uses ask for signature, but SendShieldedTRC20CoinWithoutAsk uses ak.

ListShieldedTRC20Note

> ListShieldedTRC20Note type

type

Shows the type of note. If the variable is omitted or set to 0, it shows all unspent notes; For other values, it shows all the notes, including spent notes and unspent notes.

List the note scanned by the local cache address, and the Scaling Factor.

NOTE When you load shielded wallet, the wallet will scan blocks to find the notes others send to you in the backend. This will take a long time, so when you run ListShieldedTRC20Note, your notes will not be displayed immediately.

Example:

> ListShieldedTRC20Note
This command will show all the unspent notes.
If you want to display all notes, including spent notes and unspent notes, please use command ListShieldedTRC20Note 1
The unspent note list is shown below:
15 ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 1700000000000 7291b2c58cafb4dede626388f12e846470441f9bb05581221fd742bdd8909a24 1 UnSpend
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

> ListShieldedTRC20Note 1
All notes are shown below:
ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 1700000000000 7291b2c58cafb4dede626388f12e846470441f9bb05581221fd742bdd8909a24 1 15 UnSpent
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1000000000000 dc02678b0cf1c93c557dc805edb776fe79201c77f210f08f60cea5d687b14f2e 0 0 Spent
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 1000000000000 e4d35d147762020078d7d197c98fffde181250e4a637d4bdd9ca809116d74131 0 2 Spent
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1000000000000 1594e1ee06c8420a4f1d80670000cd9268a2ff4e97e3f630909feeb51a9de993 0 3 Spent
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 2000000000000 3f035e966b3ef636ae9c0a0f64bff781b1d1a8b52bab5d8124c0f9162f71f68f 0 1 Spent
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 300000000000 6929757cb86cb6cf3e89df19f3212c3e62070b12d8b36de48e663fed214a4082 0 4 Spent test1
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 2000000000000 e39a1e1d5af7dcbab0d55a63a0c62ec9cc7c0aaf8ce98733802674c3ec1f3a06 0 6 Spent
ztron109r3w5gpm0qcf67r67a9ftjt3zy9wmzux4fqgtgcql8gwhcmauv5dm6t9t9x9ht7h3lvs8shxhq 700000000000 6929757cb86cb6cf3e89df19f3212c3e62070b12d8b36de48e663fed214a4082 1 5 Spent
ztron109r3w5gpm0qcf67r67a9ftjt3zy9wmzux4fqgtgcql8gwhcmauv5dm6t9t9x9ht7h3lvs8shxhq 2300000000000 4ce1ce9f6377ee3cd936757b696ac43ecc39ee6e8a0eab1b8f8ef093e15010f8 0 7 Spent
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1000000000000 23f171f6552680b553707715bead8de807a70255c0b091f7e788bf3b59fe3bea 0 8 Spent
ztron1tjgkfk9hgrl0u6d07w3hq0s9jtgq9q64vek3e5l447dmnzhe27yy0ftpee45h07sa092wkrgrjl 2000000000000 23f171f6552680b553707715bead8de807a70255c0b091f7e788bf3b59fe3bea 1 9 Spent
ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1000000000000 81a06080f2be3f795c506826e066b9bb5327ca234eb31a0ef2446e11339a3935 0 10 Spent
ztron1da9rnkmnzl89kqq87gzh534xmkdhq9cnm0j39lackskrhflfe9d26chnq3adl86es0jm2098hzc 1500000000000 35901973a96369618e5e3f7f4dcede2b5ddb5bc99bf6feac29f2706420ea99c0 0 11 Spent test1
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 500000000000 35901973a96369618e5e3f7f4dcede2b5ddb5bc99bf6feac29f2706420ea99c0 1 12 Spent
ztron1mm20lkcpj6tx6jfd6ek5fxkgmpk9f2hda6vxdtkwlzr45ez32wa7dt8uka9xwfqamr7zyk7jpzf 2500000000000 6ec74435e32261a6dfe10f9498b3ab5a5cfede7c4e31299752b449b9506efc11 0 13 Spent
ztron15t3c27a5ve43ssflqepa8dke36vzvccxrren4ma2lghu3hle8rtwltufnvvzrm76w042s9p5f46 1300000000000 7291b2c58cafb4dede626388f12e846470441f9bb05581221fd742bdd8909a24 0 14 Spent
The Scaling Factor is 1000
No matter you MINT, TRANSFER or BURN, the value must be an integer multiple of 1000

ResetShieldedTRC20Note

Clean all the notes scanned, and rescan all blocks. Generally used when there is a problem with the notes or when switching environments.

ScanShieldedTRC20NoteByIvk

> ScanShieldedTRC20NoteByIvk shieldedTRC20ContractAddress ivk ak nk startNum endNum [event1] [event2] ...

shieldedTRC20ContractAddress

The address of shielded contract

ivk

The ivk of shielded address

ak

The ak of shielded address. Please set this field to null, if you don't care whether the notes are spent or not.

nk

The nk of shielded address. Please set this field to null, if you don't care whether the notes are spent or not.

startNum

The starting block number of the scan

endNum

The end block number of the scan

event1/event2

The events you want to scan. These events must be compatible with standard events, that is, MintNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]), TransferNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]) and BurnNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]). If you ignore this field, the command will scan the standard events. In most cases, you can ignore these parameters.

Scan notes by ivk, ak and nk.

Example:

> ScanShieldedTRC20NoteByIvk TVqa39sqP8ZJNTWjtKrDRifGdVmA4Ycsxu fed8fa4714e6a19511760f9b8ed33388f14c626adff26034f4a21557cb928f01 faf63a2d959df05d4441c0fd42262e0a53629c532e8d29501fe94f9d86c51313 66458c23d737a30146533374d7c5c78f3e05f8f158192e8855493cc55cf8953f 5000 5400
[
    {
        note: {
            value: 100000
            payment_address:
            ztron12dq4ktrydrxzxrsgpmusp4pe0xawqyz4qfxzsgjdauw99n4n3efnw4kmrptlw8jcrrydx5694mw
            rcm: a45878a4e0d53f5cac79370fea1bf4aa82c67d3b2f647ac89c2b1e7061ea740a
            memo: without ask 2v1
        }
        position: 10
        is_spent: true
        tx_id: 5891fd3a8e860b336b7f7d31f64ec52ec5dc76f81b9bb4e4d0fa8a5756a61dd6
    }
]

> ScanShieldedTRC20NoteByIvk TVqa39sqP8ZJNTWjtKrDRifGdVmA4Ycsxu fed8fa4714e6a19511760f9b8ed33388f14c626adff26034f4a21557cb928f01  faf63a2d959df05d4441c0fd42262e0a53629c532e8d29501fe94f9d86c51313 66458c23d737a30146533374d7c5c78f3e05f8f158192e8855493cc55cf8953f 5000  6000 MintNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21])
[
    {
        note: {
            value: 100000
            payment_address: ztron1z8d5htmt6h26l5agk4ywv86xv3shuv4gjc2rzufyz4s2g5x0035nwrcqmxj4a49n2dy5sq28s5p
            rcm: 07604b4a8018d353c08f93044df0fc04ef988c2f65f9222eacc8d41f0e095404
            memo: mint
        }
        position: 16
        is_spent: false
        tx_id: 38d759216f62503c2b8bf7fc9777e6e25f5f77ec22dd760cc03057c4704277a2
    }
] 

> ScanShieldedTRC20NoteByIvk TVqa39sqP8ZJNTWjtKrDRifGdVmA4Ycsxu fed8fa4714e6a19511760f9b8ed33388f14c626adff26034f4a21557cb928f01 faf63a2d959df05d4441c0fd42262e0a53629c532e8d29501fe94f9d86c51313 66458c23d737a30146533374d7c5c78f3e05f8f158192e8855493cc55cf8953f 5000 5400 BurnNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21])
[
    {
        note: {
            value: 100000
            payment_address: ztron12dq4ktrydrxzxrsgpmusp4pe0xawqyz4qfxzsgjdauw99n4n3efnw4kmrptlw8jcrrydx5694mw
            rcm: a45878a4e0d53f5cac79370fea1bf4aa82c67d3b2f647ac89c2b1e7061ea740a
            memo: without ask 2v1
        }
        position: 10
        is_spent: true
        tx_id: 5891fd3a8e860b336b7f7d31f64ec52ec5dc76f81b9bb4e4d0fa8a5756a61dd6
    }
]

ScanShieldedTRC20NoteByOvk

> ScanShieldedTRC20NoteByOvk shieldedTRC20ContractAddress ovk startNum endNum [event1] [event2] ...

shieldedTRC20ContractAddress

The address of shielded contract

ovk

the ovk of shielded address

startNum

The starting block number of the scan

endNum

The end block number of the scan

event1/event2

The event you want to scan. These events must be compatible with standard events, that is, MintNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]), TransferNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]), BurnNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21]) and TokenBurn(address,uint256,bytes32[3]). If you ignore this field, the command will scan the standard events.

Scan notes by ovk

Example:

> ScanShieldedTRC20NoteByOvk TVqa39sqP8ZJNTWjtKrDRifGdVmA4Ycsxu 4b33fc947a53a5e2a1d1636b323f7f6cecff8c34c9fc511ccc7cfaf0dd6f4c03 5000 6000
[
    {
        note: {
            value: 60000
            payment_address: ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
            rcm: 50698dc3c97fb4d2c818b62de2265a271eb9a58b5dd65074122ddf4d794c6b03
            memo: 1
        }
        tx_id: 19c8aaa244dbcdf30a4b2a02b9b17054dc5d8ebf41d1f82daea044e65dff29d5
    }
    {
        note: {
            value: 40000
            payment_address: ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
            rcm: 94afb02c6fd4b19ada89b6b85e2cc23f2fb76c5188ede646c5046b2539a3bf00
            memo: 2
        }
        tx_id: 19c8aaa244dbcdf30a4b2a02b9b17054dc5d8ebf41d1f82daea044e65dff29d5
    }
    {
        transparent_to_address: TV7ceN4tHDNPB47DMStcUFC3Y8QQ7KzN32
        transparent_amount: 130000
        tx_id: d45da3394be6c15220d31ac17c13e02130aab0c3edf97750620538f4efae366b
    }
]

> ScanShieldedTRC20NoteByOvk TVqa39sqP8ZJNTWjtKrDRifGdVmA4Ycsxu 4b33fc947a53a5e2a1d1636b323f7f6cecff8c34c9fc511ccc7cfaf0dd6f4c03 5000 6000  BurnNewLeaf(uint256,bytes32,bytes32,bytes32,bytes32[21])  TokenBurn(address,uint256,bytes32[3])
[
    {
        note: {
            value: 60000
            payment_address: ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
            rcm: 50698dc3c97fb4d2c818b62de2265a271eb9a58b5dd65074122ddf4d794c6b03
            memo: 1
        }
        tx_id: 19c8aaa244dbcdf30a4b2a02b9b17054dc5d8ebf41d1f82daea044e65dff29d5
    }
    {
        note: {
            value: 40000
            payment_address: ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
            rcm: 94afb02c6fd4b19ada89b6b85e2cc23f2fb76c5188ede646c5046b2539a3bf00
            memo: 2
        }
        tx_id: 19c8aaa244dbcdf30a4b2a02b9b17054dc5d8ebf41d1f82daea044e65dff29d5
    }
    {
        transparent_to_address: TV7ceN4tHDNPB47DMStcUFC3Y8QQ7KzN32
        transparent_amount: 130000
        tx_id: d45da3394be6c15220d31ac17c13e02130aab0c3edf97750620538f4efae366b
    }
]

BackupShieldedTRC20Wallet

Back up one shielded address.

Example:

> BackupShieldedTRC20Wallet
Please input your password for shieldedTRC20 wallet.
password:
The 1th shieldedTRC20 address is ztron1mf0a0cy86j8rmn4l7dcdsnhyj2k46rem4qxwjqh4z0x26utlddtmmr5fk5dchzt2hpujyvgk69z
The 2th shieldedTRC20 address is ztron1mnkdjl0802dqha9ufh4m80f2ua9cff2hct8geeh77llrz4ywgtu0ct8ygy6k5xavdkd278jyttj
The 3th shieldedTRC20 address is ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
Please choose between 1 and 3
1
sk:01ef2d71f8eef668e12db7aef1267c7d6a8f43c84dffa66fc09e2c749464190e
d :da5fd7e087d48e3dcebff3
BackupShieldedTRC20Wallet successful !!!

ImportShieldedTRC20Wallet

Import one shielded address to local wallet.

Example:

> ImportShieldedTRC20Wallet
ShieldedTRC20 wallet does not exist, will build it.
Please input password.
password:
Please input password again.
password:
Please input shieldedTRC20 wallet hex string. such as 'sk d',Max retry time:3
0eb458b309fa544066c40d80ce30a8002756c37d2716315c59a98c893dbb000a 11db4baf6bd5d5afd3a8b5
Import shieldedTRC20 wallet hex string is :
sk:0eb458b309fa544066c40d80ce30a8002756c37d2716315c59a98c893dbb000a
d :11db4baf6bd5d5afd3a8b5
Import new shieldedTRC20 wallet address is: ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34
ImportShieldedTRC20Wallet successfully !!!

ShowShieldedTRC20AddressInfo

> ShowShieldedTRC20AddressInfo address

Display information about shielded addresses. If this address is not in the wallet, it will only display d and pkd

Example:

> ListShieldedTRC20Address
ShieldedTRC20Address :
ztron1mf0a0cy86j8rmn4l7dcdsnhyj2k46rem4qxwjqh4z0x26utlddtmmr5fk5dchzt2hpujyvgk69z
ztron1mnkdjl0802dqha9ufh4m80f2ua9cff2hct8geeh77llrz4ywgtu0ct8ygy6k5xavdkd278jyttj
ztron1z8d5htmt6h26l5agk5nlxdlz66fahhcp8vwhyydrwfdajc5yalftew5uhwn6wjz4pwrxu0msu34

> ShowShieldedTRC20AddressInfo ztron1mf0a0cy86j8rmn4l7dcdsnhyj2k46rem4qxwjqh4z0x26utlddtmmr5fk5dchzt2hpujyvgk69z
The following variables are secret information, please don't show to other people!!!
sk :01ef2d71f8eef668e12db7aef1267c7d6a8f43c84dffa66fc09e2c749464190e
ivk:7d2e9c14ff1d82843f39cb69e8bcc228370e4ea8750669bba79e90c485d94c03
ovk:2c3d164fffa63b41a34f495e0c9d8af79d595cfb07db1539545ddcecf046d66e
pkd:70d84ee492ad5d0f3ba80ce902f513ccad717f6b57bd8e89b51b8b896ab87922
d  :da5fd7e087d48e3dcebff3

> ShowShieldedTRC20AddressInfo ztron1z8d5htmt6h26l5agk8r7wxw9pyhc0a78hl5thva4k9kcn7fsqvygchyt3n2ncy0r4xv4j5mywnu
pkd:c7e719c5092f87f7c7bfe8bbb3b5b16d89f93003088c5c8b8cd53c11e3a99959
d  :11db4baf6bd5d5afd3a8b1

How to use tron-dex to sell asset

MarketSellAsset

Create an order to sell asset

MarketSellAsset owner_address sell_token_id sell_token_quantity buy_token_id buy_token_quantity

ownerAddress

The address of the account that initiated the transaction

sell_token_id, sell_token_quantity

ID and amount of the token want to sell

buy_token_id, buy_token_quantity

ID and amount of the token want to buy

Example:

MarketSellAsset TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW  1000001 200 _ 100    

Get the result of the contract execution with the getTransactionInfoById command:   
getTransactionInfoById 10040f993cd9452b25bf367f38edadf11176355802baf61f3c49b96b4480d374   

{
    "id": "10040f993cd9452b25bf367f38edadf11176355802baf61f3c49b96b4480d374",
    "blockNumber": 669,
    "blockTimeStamp": 1578983493000,
    "contractResult": [
        ""
    ],
    "receipt": {
        "net_usage": 264
    }
} 

GetMarketOrderByAccount

Get the order created by account(just include active status)

GetMarketOrderByAccount ownerAddress

ownerAddress

The address of the account that created market order

Example:

GetMarketOrderByAccount TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW   
{
    "orders": [
        {
            "order_id": "fc9c64dfd48ae58952e85f05ecb8ec87f55e19402493bb2df501ae9d2da75db0",
            "owner_address": "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",
            "create_time": 1578983490000,
            "sell_token_id": "_",
            "sell_token_quantity": 100,
            "buy_token_id": "1000001",
            "buy_token_quantity": 200,
            "sell_token_quantity_remain": 100
        }
    ]
}  

GetMarketOrderById

Get the specific order by order_id

GetMarketOrderById orderId

Example:

GetMarketOrderById fc9c64dfd48ae58952e85f05ecb8ec87f55e19402493bb2df501ae9d2da75db0   
{
    "order_id": "fc9c64dfd48ae58952e85f05ecb8ec87f55e19402493bb2df501ae9d2da75db0",
    "owner_address": "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",
    "create_time": 1578983490000,
    "sell_token_id": "_",
    "sell_token_quantity": 100,
    "buy_token_id": "1000001",
    "buy_token_quantity": 200,
}

GetMarketPairList

Get market pair list

Example:

GetMarketPairList   
{
    "orderPair": [
        {
            "sell_token_id": "_",
            "buy_token_id": "1000001"
        }
    ]
}

GetMarketOrderListByPair

Get order list by pair

GetMarketOrderListByPair sell_token_id buy_token_id

sell_token_id

ID of the token want to sell

buy_token_id

ID of the token want to buy

Example:

GetMarketOrderListByPair _ 1000001   
{
    "orders": [
        {
            "order_id": "fc9c64dfd48ae58952e85f05ecb8ec87f55e19402493bb2df501ae9d2da75db0",
            "owner_address": "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",
            "create_time": 1578983490000,
            "sell_token_id": "_",
            "sell_token_quantity": 100,
            "buy_token_id": "1000001",
            "buy_token_quantity": 200,
            "sell_token_quantity_remain": 100
        }
    ]
}

GetMarketPriceByPair

Get market price by pair

GetMarketPriceByPair sell_token_id buy_token_id

sell_token_id

ID of the token want to sell

buy_token_id

ID of the token want to buy

Example:

GetMarketPriceByPair _ 1000001   
{
    "sell_token_id": "_",
    "buy_token_id": "1000001",
    "prices": [
        {
            "sell_token_quantity": 100,
            "buy_token_quantity": 200
        }
    ]
}

MarketCancelOrder

Cancel the order

MarketCancelOrder owner_address order_id

owner_address

the account address who have created the order

order_id

the order id which want to cancel

Example:

MarketCancelOrder TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW fc9c64dfd48ae58952e85f05ecb8ec87f55e19402493bb2df501ae9d2da75db0  

Get the result of the contract execution with the getTransactionInfoById command:

getTransactionInfoById b375787a098498623403c755b1399e82910385251b643811936d914c9f37bd27   
{
    "id": "b375787a098498623403c755b1399e82910385251b643811936d914c9f37bd27",
    "blockNumber": 1582,
    "blockTimeStamp": 1578986232000,
    "contractResult": [
        ""
    ],
    "receipt": {
        "net_usage": 283
    }
}

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/wallet-cli
License: LGPL-3.0 license

#tron #cli  #blockchain  #smartcontract #java 

Wallet Cli for Tron Protocol

Sun Photon: Framework for Smart Contract Development on SUN Network

sun-photon

Introduction

sun-photon is a development framework for smart contract development on SUN Network (Layer 2 of TRON Network). Core functionality includes:

  • smart contract compiling
  • smart contract deployment
  • smart contract testing

Installation

npm install -g sun-photon

System requirement

  • NodeJS 8.0+
  • Windows, Linux, or Mac OS X

Initalize a project

Create project in an empty directory:

sun-photon init
  • Shell
➜  new-project sun-photon init
Downloading...
Unpacking...
Setting up...
Unbox successful. Sweet!

Commands:

  Compile:        sun-photon compile
  Migrate:        sun-photon migrate
  Test contracts: sun-photon test

Directory

  • ./contracts smart contract files
  • ./migrations smart contract migration scripts
  • ./test smart contract tests

Commands

➜  new-project sun-photon --help
sun-photon v0.2.1 - a development framework for sunweb

Usage: sun-photon <command> [options]

Commands
  init     Initialize new and empty sun-photon project
  compile  Compile contract source files
  migrate  Run migrations to deploy contracts
  deploy   (alias for migrate)
  build    Execute build pipeline (if configuration present)
  test     Run JavaScript and Solidity tests
  console  Run a console with contract abstractions and commands available
  create   Helper to create new contracts, migrations and tests
  watch    Watch filesystem for changes and rebuild the project automatically
  serve    Serve the build directory on localhost and watch for changes
  exec     Execute a JS module within this sun-photon environment
  unbox    Download a sun-photon Box, a pre-built sun-photon project
  version  Show version number and exit

See more at https://developers.tron.network/docs/tron-box-user-guide

Configuration files

Define settings in sun-photon.js. Use --network mainnet to set different network。

  • sun-photon.js
module.exports = {
  networks: {
    dappchain: {
      // Don't put your private key here:
      privateKey: process.env.PRIVATE_KEY_DAPPCHAIN,

      /* Create a .env file (it must be gitignored) containing something like
       * export PRIVATE_KEY_DAPPCHAIN=4E7FECCB71207B867C495B51A9758B104B1D4422088A87F4978BE64636656243
       * Then, run the migration with:
       * source .env && npx sun-photon migrate --network dappchain
       **/

      userFeePercentage: 100,
      feeLimit: 1e8,
      mainFullHost: 'https://api.trongrid.io',
      sideFullHost: 'https://sun.tronex.io',
      mainGateway: 'TWaPZru6PR5VjgT4sJrrZ481Zgp3iJ8Rfo',
      sideGateway: 'TGKotco6YoULzbYisTBuP6DWXDjEgJSpYz',
      chainId: '41E209E4DE650F0150788E8EC5CAFA240A23EB8EB7',
      network_id: '1'
    },
    testnet: {
      privateKey: process.env.PRIVATE_KEY_TESTNET,
      userFeePercentage: 50,
      feeLimit: 1e8,
      mainFullHost: 'https://testhttpapi.tronex.io',
      sideFullHost: 'https://suntest.tronex.io',
      mainGateway: 'TFLtPoEtVJBMcj6kZPrQrwEdM3W3shxsBU',
      sideGateway: 'TRDepx5KoQ8oNbFVZ5sogwUxtdYmATDRgX',
      chainId: '413AF23F37DA0D48234FDD43D89931E98E1144481B',
      network_id: '2'
    },
    compilers: {
      solc: {
        version: '0.5.4'
      }
    }
  }
}

Contract compilation

Set correct solc version in sun-photon.js and run command:

sun-photon compile

Contract deployment

Create a .env file to import private key and run command:

source .env && sun-photon migrate --network mainnet

Contract testing

Testing file should be in ./test directory Test demo:

  • test.js
var Test = artifacts.require('./test.sol');
contract('Test', function(accounts) {
  it('call method g', function() {
    Test.deployed()
      .then(function(instance) {
        return instance.call('g');
      })
      .then(function(result) {
        assert.equal('method g()', result, 'is not call method g');
      });
  });
  it('call method f', function() {
    Test.deployed()
      .then(function(instance) {
        return instance.call('f');
      })
      .then(function(result) {
        assert.equal('method f()', result, 'is not call method f');
      });
  });
});

Run below command, if you want to deploy test.sol to dappchain (spec. in sun-photon.js).

source .env && sun-photon test ./test/test.js --network dappchain

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/sun-photon
License: MIT license

#tron  #blockchain  #smartcontract 

Sun Photon: Framework for Smart Contract Development on SUN Network

TronBox: Simple Development Framework for Tronweb

TronBox v2.7.25

Simple development framework for tronweb TronBox is a fork of Truffle code

Installation

npm install -g tronbox

OS requirement

  • NodeJS 8.0+
  • Windows, Linux, or Mac OS X

Quick Usage

Initialize a Customer Tron-Box Project

tronbox init

Download a dApp, ex: metacoin-box

tronbox unbox metacoin

Contract Compiler

tronbox compile

To compile for all contracts, select --compile-all.

Optionally, you can select: 
--compile-all: Force compile all contracts. 
--network save results to a specific host network

 

Configuration

To use TronBox, your dApp has to have a file tronbox.js in the source root. This special files, tells TronBox how to connect to nodes and event server, and passes some special parameters, like the default private key. This is an example of tronbox.js:

module.exports = {
  networks: {
    development: {
      // For trontools/quickstart docker image
      privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0',
      userFeePercentage: 30, // or consume_user_resource_percent
      feeLimit: 100000000, // or fee_limit
      originEnergyLimit: 1e8, // or origin_energy_limit
      callValue: 0, // or call_value
      fullNode: "http://127.0.0.1:8090",
      solidityNode: "http://127.0.0.1:8091",
      eventServer: "http://127.0.0.1:8092",
      network_id: "*"
    },
    mainnet: {
      // Don't put your private key here, pass it using an env variable, like:
      // PK=da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0 tronbox migrate --network mainnet
      privateKey: process.env.PK,
      userFeePercentage: 30,
      feeLimit: 100000000,
      fullNode: "https://api.trongrid.io",
      solidityNode: "https://api.trongrid.io",
      eventServer: "https://api.trongrid.io",
      network_id: "*"
    }
  }
};

Starting from TronBox 2.1.9, if you are connecting to the same host for full and solidity nodes, and event server, you can set just fullHost:

module.exports = {
  networks: {
    development: {
      // For trontools/quickstart docker image
      privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0',
      userFeePercentage: 30,
      feeLimit: 100000000,
      fullHost: "http://127.0.0.1:9090",
      network_id: "*"
    },
    mainnet: {
      // Don't put your private key here, pass it using an env variable, like:
      // PK=da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0 tronbox migrate --network mainnet
      privateKey: process.env.PK,
      userFeePercentage: 30,
      feeLimit: 100000000,
      fullHost: "https://api.trongrid.io",
      network_id: "*"
    }
  }
};

Notice that the example above uses Tron Quickstart >= 1.1.16, which exposes a mononode on port 9090.

Configure Solc

You can configure the solc compiler as the following example in tronbox.js

module.exports = {
  networks: {
    // ...
    compilers: {
      solc: {
        version: '0.6.0' // for compiler version
      }
    }
  },

  // solc compiler optimize
  solc: {
    optimizer: {
      enabled: false, // default: false, true: enable solc optimize
      runs: 200
    },
    evmVersion: 'istanbul'
  }
}

Tron Solidity supported the following versions:

0.4.24
0.4.25
0.5.4
0.5.8
0.5.9
0.5.10
0.5.12
0.5.13
0.5.14
0.5.15
0.5.16
0.5.17
0.5.18
0.6.0
0.6.2
0.6.8
0.6.12
0.6.13
0.7.0
0.7.6
0.7.7
0.8.0
0.8.6

more versions details: https://github.com/tronprotocol/solidity/releases

Contract Migration

tronbox migrate

This command will invoke all migration scripts within the migrations directory. If your previous migration was successful, tronbox migrate will invoke a newly created migration. If there is no new migration script, this command will have no operational effect. Instead, you can use the option --reset to restart the migration script.

tronbox migrate --reset

Parameters by contract (introduced in v2.2.2)

It is very important to set the deploying parameters for any contract. In TronBox 2.2.2+ you can do it modifying the file

migrations/2_deploy_contracts.js

and specifying the parameters you need like in the following example:

var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");

module.exports = function(deployer) {
  deployer.deploy(ConvertLib);
  deployer.link(ConvertLib, MetaCoin);
  deployer.deploy(MetaCoin, 10000, {
    fee_limit: 1.1e8,
    userFeePercentage: 31,
    originEnergyLimit: 1.1e8
  });
};

Start Console
 

This will use the default network to start a console. It will automatically connect to a TVM client. You can use --network to change this.

tronbox console

The console supports the tronbox command. For example, you can invoke migrate --reset in the console. The result is the same as invoking tronbox migrate --reset in the command. 
 

Extra Features in TronBox console:
 

All the compiled contracts can be used, just like in development & test, front-end code, or during script migration. 
 

After each command, your contract will be re-loaded. After invoking the migrate --reset command, you can immediately use the new address and binary.
 

Every returned command's promise will automatically be logged. There is no need to use then(), which simplifies the command.
 

Testing
 

To carry out the test, run the following command:

tronbox test

You can also run the test for a specific file:

tronbox test ./path/to/test/file.js

Testing in TronBox is a bit different than in Truffle. Let's say we want to test the contract Metacoin (from the Metacoin Box that you can download with tronbox unbox metacoin):

contract MetaCoin {
    mapping (address => uint) balances;

    event Transfer(address _from, address _to, uint256 _value);
    event Log(string s);

    constructor() public {
        balances[tx.origin] = 10000;
    }

    function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
        if (balances[msg.sender] < amount) return false;
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        emit Transfer(msg.sender, receiver, amount);
        return true;
    }

    function getBalanceInEth(address addr) public view returns(uint){
        return ConvertLib.convert(getBalance(addr),2);
    }

    function getBalance(address addr) public view returns(uint) {
        return balances[addr];
    }
}

Now, take a look at the first test in test/metacoin.js:

var MetaCoin = artifacts.require("./MetaCoin.sol");
contract('MetaCoin', function(accounts) {
  it("should put 10000 MetaCoin in the first account", function() {

    return MetaCoin.deployed().then(function(instance) {
      return instance.call('getBalance',[accounts[0]]);
    }).then(function(balance) {
      assert.equal(balance.toNumber(), 10000, "10000 wasn't in the first account");
    });
  });
  // ...

Starting from version 2.0.5, in TronBox artifacts () the following commands are equivalent:

instance.call('getBalance', accounts[0]);
instance.getBalance(accounts[0]);
instance.getBalance.call(accounts[0]);

and you can pass the address and amount for the method in both the following ways:

instance.sendCoin(address, amount, {from: account[1]});

and

instance.sendCoin([address, amount], {from: account[1]});

Verifying the PGP signature

Prepare, you need to install the npm pkgsign for verifying.

First, get the version of tronbox dist.tarball

$ npm view tronbox dist.tarball
https://registry.npmjs.org/tronbox/-/tronbox-2.7.25.tgz

Second, get the tarball

wget https://registry.npmjs.org/tronbox/-/tronbox-2.7.25.tgz

Finally, verify the tarball

$ pkgsign verify tronbox-2.7.25.tgz --package-name tronbox
extracting unsigned tarball...
building file list...
verifying package...
package is trusted

You can find the signature public key here.

How to contribute

  1. Fork this repo.
  2. Clone your forked repo recursively, to include submodules, for example:
git clone --recurse-submodules -j8 git@github.com:sullof/tronbox.git

3.   If you use nvm for Node, please install Node 8, and install lerna globally:

nvm install v8.16.0
nvm use v8.16.0
npm i -g lerna

4.   Bootstrap the project:

lerna bootstrap

5.   During the development, for better debugging, you can run the unbuilt version of TronBox, for example

./tronbox.dev migrate --reset

TronBox Changelog

for more details: CHANGELOG

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/tronbox
License: MIT license

#tron  #blockchain  #smartcontract #java #solidity 

TronBox: Simple Development Framework for Tronweb

Sun Network: Java Implementation Of The Sun Network

What's SunNetwork?

Sun Network is a project dedicated to building a trustful decentralized sidechain of TRON Blockchain. When completed, this project will greatly increase on-chain TPS rates, while decreasing the energy consumption of smart contract executions, which is very beneficial for both DAPP developers and the on-chain users of the TRON Blockchain.

Developer Community

  • Discord Please join our Developer Discord
  • Gitter the core dev gitter

Projects

Resource

Contributing

Thank you for all of our contributors; this project wouldn’t be what it is without you! If you want to help out, please see CONTRIBUTING.md.

If you'd like to contribute to sun-network, please fork, fix, commit and send a pull request to the maintainers for them to review and merge into the main code base.
If you wish to submit more complex changes though, please communicate with the core devs first on our gitter channel to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/sun-network
License: LGPL-3.0 license

#tron #java  #blockchain  #smartcontract #solidity

Sun Network: Java Implementation Of The Sun Network

Java Tron: Java Implementation Of The Tron Whitepaper

What's TRON?

TRON is a project dedicated to building the infrastructure for a truly decentralized Internet.

Tron Protocol, one of the largest blockchain-based operating systems in the world, offers scalable, high-availability and high-throughput support that underlies all the decentralized applications in the TRON ecosystem.

Tron Virtual Machine (TVM) allows anyone to develop decentralized applications (DAPPs) for themselves or their communities with smart contracts thereby making decentralized crowdfunding and token issuance easier than ever.

TRON enables large-scale development and engagement. With over 2000 transactions per second (TPS), high concurrency, low latency, and massive data transmission. It is ideal for building decentralized entertainment applications. Free features and incentive systems allow developers to create premium app experiences for users.

Quick Start

This guide walks the user through the TRON Quickstart (v2.0.0) image setup. TRON Quick Start

Deploy

Deployment

  • Deployment Guide walks the user through how to deploy a FullNode and an SR node.

Channel

Tron Developers & SRs is Tron's official Discord channel. Feel free to join this channel if you have any questions.

Core Devs Community is the Telegram channel for java-tron community developers. If you want to contribute to java-tron, please join this channel.

tronprotocol/allcoredev is the official Gitter channel for developers.

Contribution

If you'd like to contribute to java-tron, please read the following instructions.

Resources

  • Medium java-tron's official technical articles are published there.
  • Documentation java-tron's official technical documentation website.
  • Test network A stable test network of TRON contributed by TRON community.
  • Tronscan TRON network blockchain browser.
  • Wallet-cli TRON network wallet using command line.
  • TIP TRON Improvement Proposal (TIP) describes standards for the TRON network.
  • TP TRON Protocol (TP) describes standards already implemented in TRON network but not published as a TIP.
  • White Paper White paper of TRON network.

Download Details:
Author: tronprotocol
Source Code: https://github.com/tronprotocol/java-tron
License: LGPL-3.0 license

#tron #java  #blockchain  #smartcontract #solidity 

Java Tron: Java Implementation Of The Tron Whitepaper
Jack  C

Jack C

1649469521

What is TRONSCAN | How to Use TRONSCAN | Beginner's Guide

In this post, you'll learn What is TRONSCAN and How to Use TRONSCAN

What is TRONSCAN?

TRONSCAN is the first TRON-based blockchain explorer, allowing users to look up, confirm and validate transactions on TRON blockchain. Meanwhile, TRONSCAN not only has the basic features as a blockchain explorer, like looking up transactions, accounts, blocks, nodes, smart contracts and on-chain data, it also supports token-creation, contract deployment, voting, etc.

TRON blockchain has a public ledger, from where TRONSCAN retrieve information and display them on our website. It is our mission to promote transparency of blockchains by retrieving and searching all transactions on TRON blockchain in the most transparent and accessible manner.

How to Use TRONSCAN

1. How to create a wallet on TRONSCAN?

  • Step 1: [glossary_exclude]Open[/glossary_exclude] TRONSCAN and click on SIGN IN at the top right corner, then click IMPORT A WALLET.
  • Step 2: Click CREATE WALLET.
  • Step 3: ENTER your password.
  • Step 4: Click on DOWNLOAD ENCRYPTED KEY. (Note: Your password encrypts the private key and both are needed to access your wallet)
  • Step 5: Save your private key by copying it to a local file or printing a paper wallet.
  • Step 6: You’ll be able to enter the account management page once you are successfully registered.

2. How to sign in to TRONSCAN with keystore file?

  • Step 1: [glossary_exclude]Open[/glossary_exclude] TRONSCAN and click SIGN IN at the top right corner, then click IMPORT A WALLET.
  • Step 2: Click SELECT FILE and open the keystore file.
  • Step 3: Enter your password to unlock keystore file.
  • Step 4: You are signed in successfully when you see the Wallet Unlocked pop-up notification.
  • Step 5: Click WALLET > Account to enter your account page.
  • Step 6: You’ll see the details of your account.

3. How to sign in to TRONSCAN with private key?

  • Step 1: [glossary_exclude]Open[/glossary_exclude] TRONSCAN and click SIGN IN at the top right corner, then click IMPORT A WALLET.
  • Step 2: Enter your private key and click SIGN IN.
  • Step 3: You’ll see the Login Success notification at the bottom right corner.
  • Step 4: Click WALLET > Account to enter your account page.
  • Step 5: You’ll see the details of your account.

4. How to send tokens on TRONSCAN?

  • Step 1: Sign in to TRONSCAN
  • Step 2: Click WALLET > SEND.
  • Step 3: Enter the necessary information.
  • Step 4: Click SEND and then confirm the transaction. (Note: Additional confirmation is required if you sign in with TronLink or Ledger)
  • Step 5: Successful Transaction.

5. How to receive tokens on TRONSCAN?

  • Step 1: Sign in to TRONSCAN
  • Step 2: Click WALLET > RECEIVE.
  • Step 3: Copy your address or save the QR code, send them to the people who are going to send tokens to you.
  • Step 4: You’ll see the details of your account.

6. How to obtain bandwidth and energy?

  • Step 1: Open TRONSCAN and click Login in the upper right corner. (We recommend you log in with TronLink)
  • Step 2: Open the wallet and click Bandwidth or Energy to jump to the account page.
  • Step 3: Choose to freeze TRX on the account page to obtain energy and bandwidth. (Users can also select TronLending on the homepage to lease their Energy)

7. How to vote for Super Representatives?

  • Step 1: Open TRONSCAN and click Login in the upper right corner.
  • Step 2: Click on COMMITTEE and then click on VOTES to go to the voting page.
  • Step 3: On the voting page, you will see the display which shows the time until the next round of voting, total votes, and the team with the most ranks gained. Click the Click here to Start Voting button to begin the voting process.
  • Step 4: Select the super representative candidate that you would like to vote for. To add votes to this SR, click the green + button to add votes. You can add as many or as little as you like. Press the red button to remove votes.
  • Step 5: Once you have entered as many votes as you would like for the SR candidate, click the green SUBMIT VOTES button.
  • Step 6: You will be notified that your vote was successful.

Note: Your votes will take effect when the next voting cycle starts. You may redistribute your votes any time you like before the next voting cycle.

8. How to unfreeze TRX?

  • Step 1: Open TRONSCAN and click Login in the upper right corner.
  • Step 2: Open the wallet, enter your account page.
  • Step 3: Choose to unfreeze TRX on the account.

Note: No. 1 TRX can be unfrozen once they have been frozen for three days. Depending on different types of resources obtained from freezing, TRX can be unfrozen in separate batches as long as all TRX frozen for the same purpose have been frozen for at least three days.

No. 2 After unfreezing, resources (TP, bandwidth/energy, etc) obtained from freezing TRX will be cleared.

No. 3 After unfreezing, TPs that have been used to vote will also be removed, and you need to re-freeze the TRX and get the TP to vote again to ensure that your voting rights are not affected.

Transaction on the Tron Chain

Just as many crypto tokens already have decentralized wallet systems for managing and staking assets, TRON has already developed a hardware-software system of its own; TRONSCAN cum Ledger device.

TRONSCAN is the official explorer of the TRX public smart contract blockchain. Like every other explorer, it features a wallet for managing assets and DApps for navigation on the network, and it manages smart contracts on the TRX blockchain. 

Tron chain is linked with the TronWallet, which can manage several other tokens. So, users who have accounts on both platforms can enjoy balanced services.

How to send crypto using Tron Chain

Opening a TRONSCAN account is very easy. You will have to create a wallet on that account before opening an account. The account created allows for increased compatibility with TRONSCAN.


You will have to create a password and download a private encrypted key, with which you will access your wallet. Once these are completed, you can start transactions on TRONSCAN.

Performing transactions on TRONSCAN is simple. Once you have logged on to your account, you will click ‘Link Wallet,’ then ‘Import A Wallet,’ as seen below.


 


 

You will then click ‘Send’ and a box will appear, requesting the details of the transaction.

Once you have input the details correctly, you can confirm the transaction.


Transaction on TRONSCAN is made more secure by acquiring a Ledger, which is essentially a hardware device linked to your TRONSCAN. Using Ledger requires additional confirmation while carrying out transactions, increasing the security of an account.

Read more: SolScan | How to use SolScan. Solana's Beginner Guide

I hope this post will help you. Don't forget to leave a like, comment and sharing it with others. Thank you!

#blockchain #tron  #cryptocurrency 

What is TRONSCAN | How to Use TRONSCAN | Beginner's Guide

TVM: Pure Rust implementation of TRON Virtual Machine(TVM)

SputnikVM: Rust Ethereum Virtual Machine Implementation

Features

  • Standalone - can be launched as an independent process or integrated into other apps
  • Universal - supports different Ethereum chains, such as ETC, ETH or private ones
  • Stateless - only an execution environment connected to independent State storage
  • Fast - main focus is on performance
  • written in Rust, can be used as a binary, cargo crate or shared library

Dependencies

Ensure you have at least rustc 1.33.0 (2aa4c46cf 2019-02-28). Rust 1.32.0 and before is not supported.

Documentation

Build from sources

SputnikVM is written Rust. If you are not familiar with Rust please see the getting started guide.

Build

To start working with SputnikVM you'll need to install rustup, then you can do:

$ git clone git@github.com:sorpaas/rust-evm.git
$ cd rust-evm
$ cargo build --release --all
NameDescriptionCrates.ioDocumentation
evmMain library that re-export most things.crates.ioDocumentation
evm-coreCore library defining the basic execution rules.crates.ioDocumentation
evm-gasometerIntegration of Ethereum gas rules.crates.ioDocumentation
evm-runtimeRuntime defining interface for block, transaction, and storage.crates.ioDocumentation

Download Details:
Author: opentron
Source Code: https://github.com/opentron/evm
License: Apache-2.0 License

#rust  #blockchain #tron #evm #ethereum 

TVM: Pure Rust implementation of TRON Virtual Machine(TVM)

OpenTron: An Implementation Of The Tron Blockchain Written in Rust

 OpenTron is an implementation of the Tron blockchain written in Rust. This project is under active development and is not ready for general use.

Rationale

  1. Decentralised

The Tron network currently has one and only implementation. This has lead to some criticism of Tron being too centralized. We want to change that by providing an alternative implementation and independent development team.

2.   High performance

API calls to java-tron nodes often results in CPU timeouts and other "out of resource" related errors. This is partly due to java-tron being written in Java, a garbage collected language that runs on a virtual machine. OpenTron is written in Rust, a modern compiled language that is increasingly adopted for blockchain and systems development due to its high performance, safety and modern design.

3.   Modern codebase

Java-tron was forked a few years ago from a Java Ethereum implementation. It has accumulated a lot of technical debt over the years and has a lot of inconsistent or missing documentation. We believe that a greenfield implementation will enable us to produce a cleaner code base that is easier to understand, improve and extend. In addition, since Rust has first class support for WebAssembly, it will be possible to re-use its code for creating web based clients, wallets, explorers, etc.

Roadmap

  •  Block data sync, only blocks (raw transactions), without transaction info and any other state data. Handle chain fork and block Merkle tree verification.
  •  Simple transaction broadcast, without much verification, just broadcast transactions to the network as quickly as possible(an airdrop tool can be made from it)
  •  Handle transaction verification. all state data will be available. (difficult, EVM engine, resource consumption mode, witness/vote/proposal, chain parameter are all handled at this stage, to make the state data identical as java-tron )
  •  Build a query API layer upon state data. json-rpc.
  •  Build a event API layer upon state data.
  •  block mining logic (difficult, DPoS mining, need resource to become an SR)

TODOs

  •  Full Tron Protocol implementation
    •  proto2: refactor the protobuf
    •  primitives
      •  use primitive-types
      •  keys: Address, PublicKey, PrivateKey, Signature
    •  config file
      •  genesis block parsing
      •  toml config file parsing
      •  reorganize chain parameters
    •  chain-db
      •  Block / Transaction
    •  state-db
    •  discover protocol
    •  channel protocol
      •  demo works
      •  sync
      •  TODO: minor bug fix, timeout error
      •  integrate with state-db
    •  mempool - block producing
    •  governance
      •  witness schedule
      •  voting
      •  proposal
      •  block reward - still has minor bug
    •  executor/actuator
      •  account
      •  trx/trc10 assets
      •  witness and voting
      •  proposal
      •  resource freeze/unfreeze
      •  exchange
      •  smart contract
      •  market (4.1)
    •  EVM / TVM
      •  3.7 TVM https://github.com/opentron/evm and tvm crate
      •  4.0 TVM with zksnark: ztron crate
        •  shielded trc20 transaction - ztron
        •  integration
      •  4.1 TVM
        •  CREATE2
      •  massive tests against resource usage, exit_reason
    •  RPC API replacement
      • will not support gRPC
      • might have json-rpc support
      •  GraphQL API for chain query and state query
      •  GraphQL API to broadcast transaction

Quickstart

See INSTALL.md for more detailed information.

> # Install rust-nightly
> curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
> rustup component add rustfmt

> # Install protoc
> brew install protobuf  # macOS
> sudo pacman -S protobuf  # ArchLinux
> sudo apt install protobuf-compiler libprotobuf-dev # Ubuntu / Debian

> # Get code
> git clone https://github.com/opentron/opentron.git

> # Compile opentron
> cd ./opentron/
> cargo build

> cargo run -- --config etc/conf.nile.toml

Local Testnet

./target/release/opentron --config ./etc/conf.local-test.toml

Then open http://localhost:3000 and play with the GraphQL APIs.

Download Details:
Author: opentron
Source Code: https://github.com/opentron/opentron
License: View license

#rust  #blockchain #protocol #tron 

OpenTron: An Implementation Of The Tron Blockchain Written in Rust