0.3.2 • Published 3 years ago
@vechain.energy/hardhat-thor v0.3.2
hardhat VeChain Thor plugin
- hardhat-thor allows to deploy and interact with contracts through hardhat with VeChain
Installation
yarn add @vechain.energy/hardhat-thorAdd the following line to hardhat.config.js:
require('@vechain.energy/hardhat-thor')Configuration
VeChain network is be configured in hardhat.config.js file:
module.exports = {
solidity: "0.8.4",
networks: {
vechain: {
url: 'https://testnet.veblocks.net',
privateKey: "0x…",
delegateUrl: 'https://sponsor-testnet.vechain.energy/by/#',
blockGasLimit: 10000000
}
}
};Each network configuration accepts
url: used to connect to the desired network nodeprivateKey: private key used for deployment and interaction with the blockchainaccounts[]: (optional) list of private keys to use as signer for blockchain interactiondelegateUrl: (optional) makes use of fee delegation and let another user pay for gas fees
Default values are:
{
url: 'https://testnet.veblocks.net',
privateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
}- Defaults to network
vechainwhich can be changed:- in the command line with
--network <network name> - with an environment variable
NETWORK=<network name>
- in the command line with
Usage
The plugin exposes hre.thor for interaction with the VeChain-Thor
Deployment
hre.thor works as hre.ethers replacement:
const Greeter = await hre.thor.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, VeChain!");Interaction
const Greeter = await hre.thor.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, VeChain!");
await greeter.deployed();
console.log("Greeter deployed to:", greeter.address);
const deployedGreeter = await hre.thor.getContractAt('Greeter', greeter.address)
const greeting = await deployedGreeter.greet()
console.log("Greeter responded with:", greeting)