What is Tron-Web?
You can install Tron-Web using the latest release on NPM or by downloading the latest distributable js files.
npm install tronweb
Creating an Instance
To instantiate a TronWeb object within your DApp, please see the API reference forinstantiating a TronWeb Object
Providers are used to provide methods of transport for requests. At the moment, Tron-Web only supports a single transport — HTTP.
If you wish to provide more options to the node endpoints, such as user authentication or custom headers, you can pass a TronWeb.providers.HttpProviderinstance.
Tron-Web allows you to set a number of default values for fetching, creating, and dispatching transactions.
setDefaultBlock(blockID = false)
This allows you to set the default block (hash or number) for use when querying transactions (and in some instances, creating).
setPrivateKey(privateKey = false)
When set, this private key will sign transactions without the need to pass a private key argument to each function call.
setAddress(address = false)
For use when creating unsigned transactions. This will fill in the owner_addressproperty for each transaction created by the HTTP API. This is automatically set if you call setPrivateKey().
Promises vs. Callbacks
Tron-Web has been designed to be as compatible with Ethereum’s Web3 implementation as possible. This means we support callbacks in the majority of our functions.
That doesn’t mean Tron-Web is limited in any shape or form....
To keep reading, please go to the original article at:
Stories by TRON Foundation on Medium