Announcing the Hardhat-Tableland Plugin v0
⚙️

Announcing the Hardhat-Tableland Plugin v0

A simple way to use and interact with Local Tableland, and future releases will expand to include support for easy table creation and management, plus more.

Announcing the Hardhat-Tableland Plugin v0

Easily interact with Tableland while locally developing with Hardhat.

By @Aaron Sutula

We’re excited to announce the first version of Tableland’s Hardhat plugin, @tableland/hardhat. This release marks the beginning of deeper integration between the two projects, and tooling that will make Tableland development even easier for Hardhat users. The first release focuses on providing a simple way to use and interact with Local Tableland, and future releases will expand to include support for easy table creation and management, plus more.

image

Installation

To get started, create a Hardhat project, and simply install @tableland/hardhat as a dev dependency:

npm install @tableland/hardhat --save-dev

Next, import the plugin in your hardhat.config.ts:

import "@tableland/hardhat";

Configuration

The @tableland/hardhat plugin adds an optional localTableland property to the Hardhat user config. It is of type Config, which is defined in the Local Tableland repo:

export type Config = {
  validator?: string;
  validatorDir?: string;
  registry?: string;
  registryDir?: string;
  verbose?: boolean;
  silent?: boolean;
};

You can set this property in your hardhat.config.ts to control how Local Tableland runs. For example:

const config: HardhatUserConfig = {
  ...
  localTableland: {
    silent: false,
    verbose: false,
  },
  ...
};

export default config;

Tasks

The plugin doesn’t yet add any new tasks to Hardhat, but any builtin Hardhat task that accepts the --network flag can use an added network name, local-tableland, to trigger running the task using Local Tableland. For example:

npx hardhat test --network local-tableland

This is useful when you want to deploy your own smart contracts to the same local network that Tableland’s smart contracts are deployed to and have a Tableland validator also connected to that local network and available to interact with over its API.

Hardhat Runtime Environment

If programmatically controlling Local Tableland is more your style, this plugin extends the Hardhat Runtime Environment with a localTableland field that you can import and use in your Hardhat scrips and tests:

import { localTableland } from "hardhat";

It provides a simple API to start and stop Local Tableland:

{
    start: (config?: Config) => Promise<void>;
    stop: () => Promise<void>;
}

If you omit the config parameter to start, the localTableland property of your hardhat.config.ts will be used if present.

Summary

This integration of Local Tableland with Hardhat is just the beginning of what we can do with the @tableland/hardhat plugin. We’re excited to expand it’s functionality moving forward, and we hope that it can streamline your workflow while building on Tableland.

The plugin code is available on Github and releases are published on NPM. Please give it a try, and as always, bug reports and pull requests are welcome.