Git Product home page Git Product logo

hedera-hardhat-hethers's Introduction

⛔️ DEPRECATED

Deprecation of Hethers.js by October 20, 2023
As we continue to evolve the Hedera ecosystem, we are committed to ensuring that our developer tools and resources remain easy to use and up-to-date. With this goal in mind, the Hethers.js library will be deprecated by October 20, 2023 If you are currently using or planned to use Hethers in your projects, please consider instead ethers.js or web3js in combination with hedera-json-rpc-relay before the deprecation date. For ED25519 focused scenarios the hedera-sdk-js may be utilized


No Maintenance Intended npm hardhatLicense

@hashgraph/hardhat-hethers

Hardhat plugin for integration with hethers.js.

What

This plugin brings to Hardhat the Hedera library hethers.js, which allows you to interact with the Hedera hashgraph in a simple way.

Installation

npm install --save-dev '@hashgraph/hardhat-hethers'

And add the following statement to your hardhat.config.js:

require("@hashgraph/hardhat-hethers");

Or if you're using Typescript:

import "@hashgraph/hardhat-hethers";

Configuration

This plugin extends the HardhatConfig object with hedera and updates the type of the networks field.

Here is an example network configuration in hardhat.config.js:

module.exports = {
  defaultNetwork: 'testnet',  // The selected default network. It has to match the name of one of the configured networks.
  hedera: {
    gasLimit: 300000, // Default gas limit. It is added to every contract transaction, but can be overwritten if required.
    networks: {
      testnet: {      // The name of the network, e.g. mainnet, testnet, previewnet, customNetwork
        accounts: [   // An array of predefined Externally Owned Accounts
          {
            "account": '0.0.123',
            "privateKey": '0x...'
          },
          ...
        ]
      },
      previewnet: {
        accounts: [
          {
            "account": '0.0.123',
            "privateKey": '0x...'
          },
          ...
        ]
      },
      
      // Custom networks require additional configuration - for conesensusNodes and mirrorNodeUrl
      // The following is an integration example for the local-hedera package
      customNetwork: {
        consensusNodes: [
          {
            url: '127.0.0.1:50211',
            nodeId: '0.0.3'
          }
        ],
        mirrorNodeUrl: 'http://127.0.0.1:5551',
        chainId: 0,
        accounts: [
          {
            'account': '0.0.1002',
            'privateKey': '0x7f109a9e3b0d8ecfba9cc23a3614433ce0fa7ddcc80f2a8f10b222179a5a80d6'
          },
          {
            'account': '0.0.1003',
            'privateKey': '0x6ec1f2e7d126a74a1d2ff9e1c5d90b92378c725e506651ff8bb8616a5c724628'
          },
        ]
      },
      ...
    }
  }
};

The following networks have their respective settings pre-defined. You will only need to specify the accounts when using testnet, mainnet, previewnet or local. For any other networks the full configuration needs to be provided, as in the customNetwork example above.

Read more about Externally Owned Accounts here.

Tasks

This plugin creates no additional tasks.

Environment extensions

This plugin adds a hethers object to the Hardhat Runtime Environment.

This object has the same API as hethers.js, with some extra Hardhat-specific functionality.

Provider object

A provider field is added to hethers, which is an hethers.providers.BaseProvider automatically connected to the selected network.

Helpers

These helpers are added to the hethers object:

Interfaces

interface Libraries {
  [libraryName: string]: string;
}

interface FactoryOptions {
  signer?: hethers.Signer;
  libraries?: Libraries;
}

interface HederaAccount {
    account?: string;
    address?: string;
    alias?: string;
    privateKey: string;
}

interface HederaNodeConfig {
    url: string;
    nodeId: string;
}

interface HederaNetwork {
    accounts: Array<HederaAccount>;
    nodeId?: string;
    consensusNodes?: Array<HederaNodeConfig>;
    mirrorNodeUrl?: string;
    chainId?: number;
}

interface HederaNetworks {
    [name: string]: HederaNetwork
}

interface HederaConfig {
    gasLimit: number;
    networks: HederaNetworks;
}

Functions

  • function getSigners() => Promise<hethers.Signer[]>;
const signers = await hre.hethers.getSingers();
  • function getSigner(identifier: any) => Promise<hethers.Signer>;
const signer = await hre.hethers.getSigner({
    "account": "0.0.123",
    "privateKey": "0x..."
});
  • function getContractFactory(name: string, signer?: hethers.Signer): Promise<hethers.ContractFactory>;
const contractFactoryWithDefaultSigner = await hre.hethers.getContractFactory('Greeter');
const signer = (await hre.getSigners())[1];

const contractFactoryWithCustomSigner = await hre.hethers.getContractFactory('Greeter', signer);
  • function getContractFactory(name: string, factoryOptions: FactoryOptions): Promise<hethers.ContractFactory>;
const libraryFactory = await hre.hethers.getContractFactory("contracts/TestContractLib.sol:TestLibrary");
const library = await libraryFactory.deploy();

const contract = await hre.hethers.getContractFactory("Greeter", {
    libraries: {
        "contracts/Greeter.sol:TestLibrary": library.address
    }
});
  • function getContractFactory(abi: any[], bytecode: hethers.utils.BytesLike, signer?: hethers.Signer): Promise<hethers.ContractFactory>;
const greeterArtifact = await hre.artifacts.readArtifact("Greeter");

const contract = await hre.hethers.getContractFactory(greeterArtifact.abi, greeterArtifact.bytecode);
  • function getContractAt(name: string, address: string, signer?: hethers.Signer): Promise<hethers.Contract>;
const Greeter = await hre.hethers.getContractFactory("Greeter");
const deployedGreeter = await Greeter.deploy();

const contract = await hre.hethers.getContractAt("Greeter", deployedGreeter.address);
  • function getContractAt(abi: any[], address: string, signer?: hethers.Signer): Promise<hethers.Contract>;
const greeterArtifact = await hre.artifacts.readArtifact("Greeter");

const contract = await hre.hethers.getContractAt(greeterArtifact.abi, deployedGreeter.address);
  • function getContractFactoryFromArtifact(artifact: Artifact, signer?: hethers.Signer): Promise<ethers.ContractFactory>;
const greeterArtifact = await hre.artifacts.readArtifact("Greeter");

const contractFactoryFromArtifact = await hre.hethers.getContractFactoryFromArtifact(greeterArtifact);
  • function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<hethers.ContractFactory>;
const greeterArtifact = await hre.artifacts.readArtifact("Greeter");
const libraryFactory = await hre.hethers.getContractFactory(
    "contracts/TestContractLib.sol:TestLibrary"
);
const library = await libraryFactory.deploy();

const contract = await hre.hethers.getContractFactory(greeterArtifact, {
    libraries: {
        "contracts/TestContractLib.sol:TestLibrary": library.address
    }
});
  • function getContractAtFromArtifact(artifact: Artifact, address: string, signer?: hethers.Signer): Promise<hethers.Contract>;
const Greeter = await hre.hethers.getContractFactory("Greeter");
const deployedGreeter = await Greeter.deploy();
const greeterArtifact = await hre.artifacts.readArtifact("Greeter");

const contract = await hre.getContractAtFromArtifact(greeterArtifact, deployedGreeter.address);

The Contract's and ContractFactory's returned by these helpers are connected to the first signer returned by getSigners by default.

Usage

There are no additional steps you need to take for this plugin to work.

Install it and access hethers through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc). For example, in your hardhat.config.js:

require("@hashgraph/hardhat-hethers");

// task action function receives the Hardhat Runtime Environment as second argument
task('getBalance', 'Prints the the balance of "0.0.29631749"', async (_, {hethers}) => {
    const balance = (await hethers.provider.getBalance('0.0.29631749')).toString();
    console.log(`Balance of "0.0.29631749": ${balance} tinybars`);
});

module.exports = {};

And then run npx hardhat getBalance to try it.

Read the documentation on the Hardhat Runtime Environment to learn how to access the HRE in different ways to use hethers.js from anywhere the HRE is accessible.

Library linking

Some contracts need to be linked with libraries before they are deployed. You can pass the addresses of their libraries to the getContractFactory function with an object like this:

const contractFactory = await this.env.hethers.getContractFactory("Example", {
    libraries: {
        ExampleLib: "0x...",
    },
});

This allows you to create a contract factory for the Example contract and link its ExampleLib library references to the address "0x...".

To create a contract factory, all libraries must be linked. An error will be thrown informing you of any missing library.

Troubleshooting

Events are not being emitted

Hethers.js polls the network to check if some event was emitted (except when a WebSocketProvider is used; see below). This polling is done every 4 seconds. If you have a script or test that is not emitting an event, it's likely that the execution is finishing before the event is detected by the polling mechanism.

If you are connecting to a Hardhat node using a WebSocketProvider, events should be emitted immediately. But keep in mind that you'll have to create this provider manually, since Hardhat only supports configuring networks via http. That is, you can't add a localhost network with a URL like ws://localhost:8545.

Contributing

Contributions are welcome. Please see the contributing guide to see how you can get involved.

Code of Conduct

This project is governed by the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].

License

Apache License 2.0

hedera-hardhat-hethers's People

Contributors

georgi-l95 avatar ivo-yankov avatar kalina-todorova avatar natanasow avatar nathanklick avatar simihunjan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hedera-hardhat-hethers's Issues

Export extended hre and config types

There are errors when the plugin is installed in a typescript project: Property 'hethers' does not exist on type 'HardhatRuntimeEnvironment'.

`waitForDeployment` is not a function

Description

Upon running something like this errors in: TypeError: collectionImpl.waitForDeployment is not a function

import { hethers } from 'hardhat'

const main = async () => {
    const CollectionImplV1 = await hethers.getContractFactory('CollectionImplV1')

    const collectionImpl = await CollectionImplV1.deploy()
    await collectionImpl.waitForDeployment()

    console.log(`Collection Implementation: ${collectionImpl.target}`)
}

main().catch((error) => {
    console.error(error)
    process.exitCode = 1
})

Steps to reproduce

npx hardhat run script/ScriptName.s.ts --network testnet

Additional context

No response

Hedera network

testnet

Version

Latest

Operating system

macOS

The `--network` argument is being ignored

  1. Create a sample hardhat project
  2. Add the network config and include a set of networks (previewnet, testnet, local f.e). Example config:
previewnet: {
		accounts: [ ACCS_HERE ]
	},
	testnet: {
		accounts: [ACCS_HERE  ]
	},
	local: {
		name: 'local',
		consensusNodes: [
			{
				url: '127.0.0.1:50211',
				nodeId: '0.0.3'
			}
		],
		mirrorNodeUrl: '127.0.0.1:5551',
		chainId: 0,
		accounts: [
			{
				account: '0.0.1001',
				privateKey: "0x7f109a9e3b0d8ecfba9cc23a3614433ce0fa7ddcc80f2a8f10b222179a5a80d6",
			},
			{
				account: '0.0.1002',
				privateKey: "0x6ec1f2e7d126a74a1d2ff9e1c5d90b92378c725e506651ff8bb8616a5c724628",
			},
			{
				account: '0.0.1003',
				privateKey: "0xb4d7f7e82f61d81c95985771b8abf518f9328d019c36849d4214b5f995d13814",
			}
		]
	}
  1. Create a script that deploys a sample contract to the network
  2. When executing the script, the --network tag is ignored and the network being used is always the one defined as defaultNetwork in the hardhat.config file.

If defaultNetwork: 'previewnet', is set in the hardhat.config file, the scripts are always using the previewnet network.

Excpectation
When running the script:

npx hardhat deploy --network local

I would expect that the used network is local and not previewnet

Add license headers to source files

Add the following license headers to all source files (example).

/*-
 * ‌
 * Hedera Hardhat Hethers
 * ​
 * Copyright (C) 2022 - 2023 Hedera Hashgraph, LLC
 * ​
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ‍
 */

Hbar amount passed as `value` is HBARs not `tinybars`

When defining value as part of a contract call, the amount is denominated in hbars however it should be in tinybars
Example code:

 const depositTx = await WHBAR.deposit({value: hbarAmount, gasLimit: 150_000});

In this case hbarAmount is in hbars and not tinybars

Cannot access namedAccounts

Problem

In hardhat.config.ts:

const config: HardhatUserConfig = {
  defaultNetwork: "localHederaNetwork",
  ...,
  namedAccounts: {
    deployer: {
      default: 0, // maps to account 0.0.1002
    },
    dev: {
      default: 1, // maps to account 0.0.1003
    },
  },
  hedera: {
    ...,
    localHederaNetwork: {
      ...,
      accounts: [
        {
          account: "0.0.1002",
          privateKey: "0x7f109a9e3b0d8ecfba9cc23a3614433ce0fa7ddcc80f2a8f10b222179a5a80d6",
        },
        {
          account: "0.0.1003",
          privateKey: "0x6ec1f2e7d126a74a1d2ff9e1c5d90b92378c725e506651ff8bb8616a5c724628",
        }
      ]      
    },
  }
}

In script:

import {getNamedAccounts } from "hardhat";

const { deployer, dev } = await getNamedAccounts();

On getNamedAccounts() fails with the following error stack trace:

TypeError: this.network.provider.send is not a function
      at DeploymentsManager.getChainId (node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:51)
      at DeploymentsManager.setupAccounts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1505:34)
      at DeploymentsManager.getNamedAccounts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:574:16)
      at initialize (test/harness/ConstantProduct.ts:60:36)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Context.<anonymous> (test/Test.test.ts:10:5)

Solution

  • Given the stack trace appears to be similar to that of this issue the solution would likely be the same

Alternatives

No response

Cannot pass BigNumber to Contract constructor parameter

Description

BigNumber variables cannot be passed to constructor params(and though untested possibly function params as well). number variables work fine. The error that is thrown is:

Error: missing argument:  in Contract constructor (count=2, expectedCount=3, code=MISSING_ARGUMENT, version=contracts/1.2.0)

Steps to reproduce

const ERC20 = await hre.hethers.getContractFactory("ERC20Mock", accounts[0]);

// number works:
await ERC20.deploy(`Token A`, `TOKENA`, 1_000_000))

// BigNumber fails:
const supply = BigNumber.from(1_000_000).mul(BigNumber.from(10).pow(0));
await ERC20.deploy(`Token A`, `TOKENA`, supply))

// Using BigNumber.toString() works:
const supply = BigNumber.from(1_000_000).mul(BigNumber.from(10).pow(0)).toString();
await ERC20.deploy(`Token A`, `TOKENA`, supply))

Additional context

No response

Hedera network

other

Version

1.0.2

Operating system

macOS

Support for max_automatic_token_associations at contract.deploy()

As a user I'd like to be able to set the property for max automatic token associations somewhere within the deploy() method of a contract.

Reference for max_automatic_token_associations:
This property is supported both for accounts and contracts, but the documentation is not yet updated so I am linking the cryptocreate page for reference instead.

This is where the property should be populated. I am referencing it as a starting point.

Compatibility with hardhat-deploy

Problem

hardhat-deploy doesn't work with @hashgraph/hardhat-hethers.
Attempting await deployments.fixtures() results in the following error stack trace:

TypeError: this.network.provider.send is not a function
      at DeploymentsManager.getChainId (node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:51)
      at DeploymentsManager.loadDeployments (node_modules/hardhat-deploy/src/DeploymentsManager.ts:619:28)
      at DeploymentsManager.runDeploy (node_modules/hardhat-deploy/src/DeploymentsManager.ts:998:16)
      at Object.fixture (node_modules/hardhat-deploy/src/DeploymentsManager.ts:315:20)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async initialize (test/helpers.ts:40:3)
      at async Context.<anonymous> (test/_/Contract.test.ts:10:5)

Solution

  • In hardhat-deploy the DeploymentsManager's constructor's 2nd parameter i.e. network is set to env.network i.e. hre.network. Potentially have hedera-hardhat-hethers plugin load network: Network into hre with a compatible Provider

Alternatives

No response

Functional Hedera network configured in HardhatUserConfig.networks

Problem

A hedera network configured in HardhatUserConfig.networks isn't functional presumably due to the lack of parity in the hedera-json-rpc-relay with the standard ethereum json rpc.

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const config: HardhatUserConfig = {
  ...,
  defaultNetwork: "hedera",
  networks: {
    hedera: {
      url: "http://127.0.0.1:7546",
      chainId: 298,
      accounts: [
        // Alias ECDSA keys private keys
        "0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524",
        "0x2e1d968b041d84dd120a5860cee60cd83f9374ef527ca86996317ada3d0d03e7",
        "0x45a5a7108a18dd5013cf2d5857a28144beadc9c70b3bdbd914e38df4e804b8d8",
        "0x6e9d61a325be3f6675cf8b7676c70e4a004d2308e3e182370a41f5653d52c6bd",
        "0x0b58b1bd44469ac9f813b5aeaf6213ddaea26720f0b2f133d08b6f234130a64f",
        "0x95eac372e0f0df3b43740fa780e62458b2d2cc32d6a440877f1cc2a9ad0c35cc",
        "0x6c6e6727b40c8d4b616ab0d26af357af09337299f09c66704146e14236972106",
        "0x5072e7aa1b03f531b4731a32a021f6a5d20d5ddc4e55acbb71ae202fc6f3a26d",
        "0x60fe891f13824a2c1da20fb6a14e28fa353421191069ba6b6d09dd6c29b90eff",
        "0xeae4e00ece872dd14fb6dc7a04f390563c7d69d16326f2a703ec8e0934060cc7",
      ],
    },
  }
  ...,
};

export default config;

Attempting to run a simple test fails on the first call to the json rpc relay i.e. deploy:

import { expect } from "chai";
import { ethers } from 'hardhat';

describe("Greeter", function () {
  it("Should return the new greeting once it's changed", async function () {

    const signers = await ethers.getSigners();

    const signer = signers[0];

    const Greeter = await ethers.getContractFactory("Greeter", signer);

    // fails here
    const greeter = await Greeter.deploy("Hello, world!");

    await greeter.deployed();

    expect(await greeter.greet()).to.equal("Hello, world!");

    const setGreetingTx = await greeter.setGreeting("Hola, mundo!");

    // wait until the transaction is mined
    await setGreetingTx.wait();

    expect(await greeter.greet()).to.equal("Hola, mundo!");
  });
});

Hardhat error stack trace:

ProviderError: Internal error
  at HttpProvider.request (node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
  at LocalAccountsProvider.request (node_modules/hardhat/src/internal/core/providers/accounts.ts:188:34)
  at async EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

Greeter.sol:

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.9;

contract Greeter {
    string private greeting;

    constructor(string memory _greeting) {
        greeting = _greeting;
    }

    function greet() public view returns (string memory) {
        return greeting;
    }

    function setGreeting(string memory _greeting) public {
        greeting = _greeting;
    }
}

json-rpc-relay docker container logs:

[2022-08-29 08:42:13.714 +0000] INFO (rpc-server/50 on baafe97141e2): [GET]: /health/liveness 1 ms
[2022-08-29 08:42:13.958 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.958 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.960 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 1 ms 
[2022-08-29 08:42:13.964 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.964 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.964 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms 
[2022-08-29 08:42:13.971 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.971 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.971 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms 
[2022-08-29 08:42:13.997 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_blockNumber
[2022-08-29 08:42:13.998 +0000] TRACE (relay-eth/50 on baafe97141e2): blockNumber()
[2022-08-29 08:42:14.024 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:14.024 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:14.024 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms 
[2022-08-29 08:42:14.037 +0000] ERROR (mirror-node/50 on baafe97141e2): [GET] blocks?limit=1&order=desc 567 status
    err: {
      "type": "Error",
      "message": "connect ECONNREFUSED 127.0.0.1:5551",
      "stack":
          Error: connect ECONNREFUSED 127.0.0.1:5551
              at MirrorNodeClient.handleError (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:107:27)
              at MirrorNodeClient.<anonymous> (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:95:22)
              at Generator.throw (<anonymous>)
              at rejected (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:25:65)
              at processTicksAndRejections (node:internal/process/task_queues:96:5)
    }
[2022-08-29 08:42:14.042 +0000] ERROR (Internal error/50 on baafe97141e2): [POST] eth_blockNumber: -32603 45 ms
    code: -32603
    message: "Unknown error invoking RPC"

Solution

  • Requires further investigation.

Alternatives

No response

Update workflows to use self hosted runners

Description

We need to update the .github/workflows/nodejs.yml workflow to use the ephemeral self-hosted runners which are now configured on this repository. Additionally, we should add a workflow dispatch trigger to improve ease of testing.

Requirements

  • Change the runs-on specification to the following stanza:
    • runs-on: [self-hosted, hardhat, hethers, standard, ephemeral]
  • Add a workflow_dispatch trigger to the on declaration
  • Update the following actions to use the v3 version:
    • actions/setup-node
    • actions/checkout
  • Enable NodeJS caching support

chai expect to be revertedWith does not work

Problem

The error with which a contract call reverts can be tested positively as follows:

import { expect } from "chai";

  await expect(
    contract.foo(-1)
  ).to.be.revertedWith("OUT_OF_RANGE");

If the contract reverts with another error an AssertionError like the following is normally in hardhat:

AssertionError: Expected transaction to be reverted with OUT_OF_RANGE, but other exception was thrown: Error: VM Exception while processing transaction: reverted with custom error 'OutOfRange()'

The response from a contract call that reverted using @hashgraph/hardhat-hethers does not have parity with the default hardhat functionality and instead throws the follows AssertionError:

AssertionError: Expected transaction to be reverted with OUT_OF_RANGE, but other exception was thrown: Error: receipt for transaction [email protected] contained error status CONTRACT_REVERT_EXECUTED (code=CONTRACT_REVERT_EXECUTED, version=providers/1.2.0)

Solution

  • Have hedera-hardhat-ethers decode and handle CONTRACT_REVERT_EXECUTED calls identically to hardhat-ethers

Alternatives

No response

Compatibility with solidity-coverage

Problem

The solidity-coverage plugin cannot be used simultaneously with @hashgraph/hardhat-hethers.

Attempting to analyse code coverage with command npx hardhat coverage throws the following error:

Error in plugin solidity-coverage: HardhatError: HH10: Error while loading Hardhat's configuration.
You or one of your plugins is trying to modify the userConfig.hedera.networks.localHederaNetwork.allowUnlimitedContractSize value from a config extender

Solution

  • Possibly update the HederaConfig type to include all properties present in HardhatUserConfig including the allowUnlimitedContractSize property with identical defaults.

Alternatives

No response

Contract call event logs assertion does not work

As a user I want to be able to assert that certain events have been emitted in a certain transaction I am making.

await expect(smartContract.method(arg1, arg2, arg3)).to.emit(contract, "SomeEvent").withArgs(arg1, arg2, arg3);

Currently the snippet above does not work.

Return type of deploy contract doesn't match contract type

Problem

The only allowed return type of the deployed contract is Contract, however, the type of the deployed contract should also be allowed.

const ERC20Factory = await hre.hethers.getContractFactory("ERC20", accounts[0]);

// works fine
const erc20contract1: Contract = await ERC20Factory.deploy(`Token A`, `TOKENA`, 1_000_000);

// type error:
// Type 'Contract' is missing the following properties from type 'ERC20': DOMAIN_SEPARATOR, allowance, approve, balanceOf, and 11 more.
const erc20contract2: ERC20 = await ERC20Factory.deploy(`Token A`, `TOKENA`, 1_000_000);

Solution

  • the return type of hethers.ContractFactory.deploy should allow for both hethers.Contract or type of Contract which is identical to the contract name.

Alternatives

No response

Deprecated: Use `ledgerId` instead

Description

Did not see this error until switching to hethers.
Can't seem to figure out what it's complaining about.
You will see this when running any command npx hardhat run ...

Steps to reproduce

npx hardhat run ...

Additional context

No response

Hedera network

testnet

Version

Latest

Operating system

macOS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.