Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@layerzerolabs/hardhat-tron
Advanced tools
Hardhat plugin for integrating the Tron Solidity Compiler.
This plugin provides seamless integration of the Tron Solidity Compiler into the Hardhat build environment. It extends Hardhat's native Solidity compilation tasks to support Tron's version of the solc compiler. This allows developers working on Tron blockchain projects to compile their smart contracts within the familiar Hardhat environment, using Tron's specific compiler versions and configurations.
yarn add -D @layerzerolabs/hardhat-tron
Import the plugin in your hardhat.config.ts
:
import "@layerzerolabs/hardhat-tron";
The following plugin is needed to support hardhat deployments on Tron chains
This plugin overrides several internal Hardhat tasks to integrate the Tron Solidity Compiler:
compile
: Extended for compiling with the Tron solc compiler.clean
: Enhanced to clean Tron-specific artifacts and cache.This plugin extends the Hardhat Runtime Environment by adding configurations and utilities for handling the Tron Solidity Compiler. This includes network configurations specific to the Tron blockchain and support for downloading and setting up the Tron version of solc.
This plugin extends the HardhatUserConfig
with Tron-specific compiler configurations.
In addition to the predefined versions known by the plugin, it is possible to select a compiler version greater than the latest known. The plugin will attempt to download and use the specified compiler version. However, if the specified version does not exist, it will throw an error.
All tronSolc.compilers versions must also be declared in the solidity.compilers array.
const hardhatConfig = {
...regularHardhatConfig,
tronSolc: {
enable: true,
// Optional: specify an array of contract filenames (without path) to selectively compile. Leave as empty array to compile all contracts.
filter: [],
compilers: [{ version: "0.7.7" }, { version: "0.8.20" }], // can be any tron-solc version
// Optional: Define version remappings for compiler versions
versionRemapping: [
["0.7.7", "0.7.6"], // Remap version "0.7.7" to "0.7.6"
["0.8.22", "0.8.20"], // Remap version "0.8.20" to "0.8.19"
],
},
networks: {
shasta: {
url: "https://api.shasta.trongrid.io/jsonrpc",
accounts: [process.env.TRON_PRIVATE_KEY],
httpHeaders: { "TRON-PRO-API-KEY": process.env.TRON_PRO_API_KEY },
tron: true,
},
},
};
After installation, the plugin automatically hooks into Hardhat's compilation tasks. Configure the Tron solc compiler in the Hardhat configuration file as shown above. The plugin handles the rest, ensuring that your smart contracts are compiled with the appropriate version of the Tron Solidity Compiler.
If you want to compile contracts using tron-solc
, you must pass the network
option to force the use of tron-solc
. like the following command:
yarn hardhat compile --network tron
After compiling the contracts, two non-empty folders, artifacts-tron
and cache_hardhat-tron
, will be generated.
Ensure that your URL supports Ethereum's JSON-RPC. For example, the following command will fail:
curl -X POST 'https://api.shasta.trongrid.io' --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":79}'
This is because the URL https://api.shasta.trongrid.io
is not supported. However, if you change the URL to https://api.shasta.trongrid.io/jsonrpc
, the command will succeed.
curl -X POST 'https://api.shasta.trongrid.io/jsonrpc' --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":79}'
Note: Make sure to enable the plugin in your Hardhat configuration and specify the required compiler versions for your project.
The versionRemapping option allows you to specify Solidity versions to remap. This is useful when you want to compile contracts with a specific version of the Tron Solidity Compiler that is different from the one declared in the contract files. The map keys are the original versions specified in your contract files, and the values are the target compiler versions you wish to use instead.
To use this feature, simply add the versionRemapping property to your tronSolc configuration in the Hardhat config file. The map should contain entries where each key is the version to be replaced, and each value is the new target version.
The filter option in the tronSolc configuration allows for selective compilation of Solidity contracts. By specifying an array of contract filenames, you can target specific contracts for compilation. To compile all contracts in your project, set filter to an empty array. Note: The filenames in the filter array should not include the path, only the contract file names without the extension.
FAQs
Hardhat plugin for compiling contracts with tron solc
The npm package @layerzerolabs/hardhat-tron receives a total of 141 weekly downloads. As such, @layerzerolabs/hardhat-tron popularity was classified as not popular.
We found that @layerzerolabs/hardhat-tron demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.