Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unfinishedlabs/contracts

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unfinishedlabs/contracts

Official DSNP Interfaces, Contracts, and ABIs

  • 0.0.0-1fb655
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

DSNP Contracts

The official DSNP interface and implementations.

Overview

Installation

$ npm install @unfinishedlabs/contracts

JavaScript ABI Usage

const announcer = require("@unfinishedlabs/contracts/abi/Announcer.json");
const annoucerABI = announcer.abi;

TypeScript ABI Usage

// Requires "resolveJsonModule": true in [tsconfig](https://www.typescriptlang.org/tsconfig#resolveJsonModule)
import { abi as announcerABI } from "@unfinishedlabs/contracts/abi/Announcer.json";
TypeScript Contract Types

To maintain types, it is suggested to use TypeChain.

  1. Follow the install directions and add the correct package for your toolset.
  2. Add a postinstall or other step to run typechain:
  • "postinstall": "typechain --target=(ethers-v5|web3-v1|other...) node_modules/@unfinishedlabs/contracts/**/*.json --outDir ./types/typechain"
  • "build:web3types": "typechain --target=web3-v1 node_modules/@unfinishedlabs/contracts/**/*.json --outDir ./types/typechain"
  1. Make sure your --outDir is in tsconfig typeRoots.
  2. Use the types:
// web3 example
import web3 from "web3";
import { Announcer } from "./types/typechain/Announcer";
import { abi as announcerABI } from "@unfinishedlabs/contracts/abi/Announcer.json";

const getAnnouncerContract = (contractAddress: string) => {
  // web3 requires the type cast
  return new web3.eth.Contract(announcerABI, contractAddress) as Announcer;
}
// ethersjsv5 example
import { Provider } from "@ethersproject/providers";
import { Announcer } from "./types/typechain/Announcer";

const getAnnouncerContract = (contractAddress: string, provider: Provider) => {
  // TypeChain for Ethers provides factories
  return Announcer__factory.connect(contractAddress, provider);
}

Contract Usage

Once installed, you can use the contracts in the library by importing them:

pragma solidity ^0.8.0;

import "@unfinishedlabs/contracts/IAnnounce.sol";

contract MyAnnouncer is IAnnounce {
    // ...
}

Development

We are using hardhat to compile and deploy the contracts

Key Commands and Tasks

Basic Command List:

  • npm install
  • npm run clean - clears the cache and deletes all artifacts
  • npm run compile - compiles the entire project, building all artifacts
  • npm run console - opens a hardhat console
  • npm run test - runs mocha tests
  • npm run lint - to run the linter
  • npm run format - to trigger formatting
  • npm run deploy:testnet - deploys our deploy.ts script to our POA testnet defined in the hardhat.config.ts

Environment Variables

  1. create a .env file and set values for all variables in .env.sample
Env Variable NameDescription
LOCAL_NETWORK_PRIVATE_KEYprivate key for an account we have on our local network that has eth.
TESTNET_ACCOUNT_PRIVATE_KEYprivate key for an account we have on our test network that has eth.
TESTNET_CHAIN_URLUrl to connect to tesnet
VALIDATOR1hex prefixed address for validator running on node called liberty-chain
VALIDATOR2hex prefixed address for validator running on node called liberty-chain1
BOOTNODEenode address of the node our node would like to connect to

Accounts

Deployments

Ports

Development

  • This repo uses Hardhat + ethers for interfacing with Ethereum,
  • Waffle for testing,
  • And Truffle or truffle-style for contract migration.

FAQs

Package last updated on 26 Apr 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc