DIRT Lib - Typescript Library
DIRTlib is a Typescript client library that makes it simple and easy to interact with the DIRT smart contracts.
Installing the library
npm install --save '@dirt/lib'
Getting a Web3 instance
You will need a Web3
instance to use DIRT lib.
For offline transactions (without MetaMask):
let provider = new HDWalletProvider('PRIVATE_KEY_HERE', 'ETHEREUM_NODE_URL')
let web3 = new Web3(provider)
web3.eth.defaultAccount = 'ACCOUNT_OF_PRIVATE_KEY_HERE'
When MetaMask is installed, Web3
will be automatically injected and available at window.web3
.
To use MetaMask, see the sample web app or check out MetaMask's developer guide.
Instantiating DIRT
import { Dirt } from "@dirt/lib";
let dirt = await Dirt.create({
rootAddress: DIRT_ROOT_CONTRACT_ADDRESS,
web3: web3
})
For the root contract address, a deployed RootRegistry contract or use the your own deployed contract's address.