1.0.11 • Published 1 year ago

@reef-defi/evm-provider v1.0.11

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@reef-defi/evm-provider.js

evm-provider.js implements a web3 provider which can interact with the Reef chain EVM.

Getting Started

Install dependencies

yarn

Documentation

Most of the api of evm-provider.js is compatible with ethers.js. If you are not familiar with ethers.js, you can start by looking at its documentation

Provider

The Provider provides some api for interacting with nodes and is an instance of ethers.js AbstractProvider.

Creating Instances

new Provider( apiOptions )

apiOptions has the same parameters as when creating an instance of apiPromise for polkadot.js

import { options } from "@reef-defi/api";
import { Provider } from "@reef-defi/evm-provider";
import { WsProvider } from "@polkadot/api";

const provider = new Provider(
  options({
    provider: new WsProvider("ws://localhost:9944")
  })
);

Wallet

The Wallet class inherits Signer and can sign transactions and messages using a private key.

Creating Instances

new Wallet( privateKey , provider? , keyringPair? )

privateKey is the private key of evm's account.provider is an instance of Provider. keyringPair is a key pair for polkadot. If the keyringPair is empty, a key pair will be generated from the privateKey.

import { Wallet } from "@reef-defi/evm-provider";
const wallet = new Wallet("0xaa397267eaee48b2262a973fdcab384a758f39a3ad8708025cfb675bb9effc20", provider)

Wallet.claimEvmAccounts()

Use keyringpair to bind an EVM account generated by privateKey.

wallet.claimEvmAccounts()

Examples

For examples see scripts in hardhat-reef-examples repo.