2.3.0 • Published 2 years ago

@elysia-dev/contract-typechain v2.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

contract-typechain

contract typechain for developing elysia dapp.

Do not need ABI file and to define any types of contract with this package!

Supported contracts

  • StakingPool (StakingPool__factory)
  • MoneyPool (MoneyPool__factory)
  • IncentivePool (IncentivePool__factory)
  • ERC20 (ERC20__factory)

and others are listed in src/factories

Getting started

yarn add @elysia-dev/contract-typechain

Example

StakingPool with web3 libray in React

import React, { useMemo } from 'react';
import { useWeb3React } from '@web3-react/core';
import { StakingPool__factory } from "@elysia-dev/contract-typechain";

const StakingModal: React.FunctionComponent = () => {
  const { account, library } = useWeb3React();
  const contract = useMemo(() => {
    return StakingPool__factory.connect(
      "0xDF409737E31475Ec46e13335Ad5370c551b97D12",
      library.getSigner()
    )
  }, [library])

  const stake = async (amount: BigNumber) => {
    const tx = await contract.stake(
      amount
    )

    /* tx is typed well
      interface TransactionResponse extends Transaction {
        hash: string;
        blockNumber?: number,
        blockHash?: string,
        timestamp?: number,
        confirmations: number,
        from: string;
        raw?: string,
        wait: (confirmations?: number) => Promise<TransactionReceipt>
      };
    */

    it(tx){
      console.log(tx.hash)
      /*
      tx.wait().then(() => {

      })
      */
    } else {
      console.log("Tx is not created")
    }
  }

  ...
  return (
    ...
  )
}

Moneypool with web3 libray

Assume thats there is a singer instance(ether.js signer).

import { MoneyPool__factory } from "@elysia-dev/contract-typechain";

const signer = ... // this instance is created with provider & signer secret key

const contract = MoneyPool__factory.connect(
  "address",
  signer,
)

const deposit = async () => {

}

Release

  1. yarn build
  2. yarn build:d
  3. update pacakge version number
  4. npm publish
2.3.0

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago