0.1.9 • Published 22 days ago

@vechain/hardhat-web3 v0.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

hardhat-vechain

A package extending Hardhat Web3 plugin to use a Connex provider.

Usage

  • Modify hardhat.config.js to require @vechain/hardhat-vechain and @vechain/hardhat-web3.
  • Configure networks to include a vechain configuration

    Note: A solo Thor instance should be running for the below configurations to work

Sample hardhat.config.js

const {
  VECHAIN_URL_SOLO
} = require("@vechain/hardhat-vechain");
require("@vechain/hardhat-web3");

module.exports = {
    solidity: {
        version: "0.8.17",
    },
    networks: {
        vechain: {
            url: VECHAIN_URL_SOLO
        },
    }
};

Sample hardhat.config.js with fee delegation

Fee delegation can be configured by providing optional delegate config which has required url and optional signer field. Url needs to point to delegation a valid delegation service, for example https://sponsor-testnet.vechain.energy/by/${projectId}.

const {
  VECHAIN_URL_SOLO
} = require("@vechain/hardhat-vechain");
require("@vechain/hardhat-web3");

module.exports = {
    solidity: {
        version: "0.8.17",
    },
    networks: {
        vechain: {
            url: VECHAIN_URL_SOLO,
            delegate: {
                url: "${feeDelegationServiceUrl}",
                signer: "${optionalSigner}"
            }
        },
    }
};

Multi network support sample hardhat.config.js

Multiple network can also be configured to simplify testing and deployments. Networks which are targeting VechainThor nodes should have vechain as part of the network name (vechain, vechain_testnet, vechainNode are all valid). Network names without this requirement won't be preprocessed by the plugin and it is not expected to function properly with Thor network. Sample configuration:

const {
  VECHAIN_URL_SOLO
} = require("@vechain/hardhat-vechain");
require("@vechain/hardhat-web3");

module.exports = {
    solidity: {
        version: "0.8.17",
    },
    networks: {
        vechain_solo: {
            url: VECHAIN_URL_SOLO,
            delegate: {
                url: "${feeDelegationServiceUrl}",
                signer: "${optionalSigner}"
            }
        },
        vechain_mainnet: {
            url: "https://mainnet.veblocks.net",
        },
    }
};

Testing

  • Use Hardhat web3 as usual
describe("vechain-web3", function() {
    it("should be able to get accounts", async function () {
        const accounts = await await web3.eth.getAccounts();;
        assert.equals(accounts[0], "0xf077b491b355e64048ce21e3a6fc4751eeea77fa");
    });
});
0.1.9

22 days ago

0.1.8

4 months ago

0.1.4

8 months ago

0.0.4

6 months ago

0.1.3

9 months ago

0.1.0

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

1 year ago