Quickstart

Browseth quickstart for those already familiar with Ethereum development. New to Ethereum? Check out the getting-started.


Installation

From your project directory:

yarn add @browseth/browser

Import inside relevant project files:

import Browseth from '@browseth/browser'

Initializing Browseth

Initialize Browseth with an Ethereum RPC url or web3 instance.

By default, Browseth uses http://localhost:8545.

const beth = new Browseth("https://mainnet.infura.io")
// or
const beth = new Browseth(window.web3)

Accounts

The following account types are supported: private key, ledger, and online.

import PrivateKeySigner from '@browseth/signer-private-key'
import SignerLedger from '@browseth/signer-ledger'

beth.useSignerAccount(new PrivateKeySigner(PRIVATE_KEY));
beth.useSignerAccount(new SignerLedger());
beth.useOnlineAccount();

Send requests

beth.send({ to: ADDRESS, value: beth.etherToWei('.01') });

Contract Instances

const contractInstance = beth.contract(contract.abi, {bin: contract.bin, address: contract.address});

contractInstance.construct(params).send(); // deploying contract

contractInstance.fn
    .functionName(params)
    .call()
    .then(console.log); // function call

contractInstance.fn
    .functionName(params)
    .send({ value: beth.etherToWei('1') })
    .then(txHash => {
        beth.tx.listen(txHash).then(console.log)
    }); // send then log receipt