Skip to content

A framework to build web3 dapps with javascript/typescript

License

Notifications You must be signed in to change notification settings

moshmage/dappkit

 
 

Repository files navigation

dappkit

A javascript SDK for web3 projects with curated community contracts to ease development and interactions with blockchain contracts.

Build Status GitHub issues Contributions welcome License

Installation

$ npm install @taikai/dappkit

Usage

dappkit offers tokens (ERC20, ERC721, ERC1155 and ERC4626) along with some other contracts, such as Staking and Voting, for ease of use. you can check all the models over at the SDK Documentation.

Simple browser connection

import {Web3Connection} from '@layerx-labs/dappkit';

const web3Connection = new Web3Connection({web3Host: 'https://rpc.tld'});
await web3Connection.connect();

console.log(`Address`, await web3Connection.getAddress());

It's possible to provide more options (such as privateKey) to the Web3Connection class.

Note: a Server side connection does not need to call connect() and should when needed provide a privateKey

Creating ERC20 tokens

import {ERC20} from '@layerx-labs/dappkit';

const erc20 = new ERC20({ web3Host: 'http://rpc.tld' });

await erc20.deployJsonAbi(
  'Token Name', // the name of the token
  '$tokenSymbol', // the symbol of the token
  "1000000000000000000000000", // the total amount of the token (with 18 decimals; 1M = 1000000000000000000000000)
  "0xOwnerOfErc20Address" // the owner of the total amount of the tokens (your address)
);

console.log(`ERC20 address`, erc20.contractAddress);

Note: Full model documentation on the sdk

Creating ERC721 NFTs

import {ERC721Collectibles} from '@layerx-labs/dappkit'

const erc721 = new ERC721Collectibles({web3Host: 'http://rpc.tld'});

await erc721.deployJsonAbi(
  `Token Name`, 
  `$token_symbol`, 
  1, // how many packs can be open of this collectible (0 = infinite)
  `0xAddressOfPurchasingAddress`, // address of the erc20 used to open packs
  `0xBaseFeeAddress`, // address for where the main fee goes
  `0xFeeAddress`, // address for where fee from purchases and pack shares
  `0xAnotherAddress`); // adress for pack shares fee

console.log(`ERC721 address`, erc721.contractAddress)

Note: Full model documentation on the sdk

Creating ERC1155

import {ERC1155Ownable} from "@layerx-labs/dappkit";

const erc1155 = new ERC1155Ownable({web3Host: 'http://rpc.tld'});

await erc1155.deployJsonAbi('http://my.token-uri.tld/');

console.log(`ERC1155 address`, erc1155.contractAddress);

Note: Full model documentation on the sdk

Creating ERC4626

import {ERC4626} from "@layerx-labs/dappkit";

const erc4626 = new ERC4626({web3Host: 'http://rpc.tld'})

await erc4626.deployJsonAbi(`0xUnderlyingERC20Address`, `Vault Name`, `$vault_symbol`);

console.log(`ERC4626 address  `, erc4626.contractAddress);

Note: Full model documentation on the sdk

Documentation

Please refer to the test/ folder to read further usage examples of the various contracts available.

Quick start

How to Generate Documentation

You can generate the documentation locally by issuing

$ npm run docs

and then serving the docs/ folder as a root http-server.

Contribution

Contributions are welcomed, but we ask that you read existing code guidelines, specially the code format. Please review Contributor guidelines

License

ISC

Notes

About

A framework to build web3 dapps with javascript/typescript

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 51.7%
  • Solidity 47.8%
  • Other 0.5%