Giter Site home page Giter Site logo

4skinskywalker / evm-provider.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reef-defi/evm-provider.js

0.0 2.0 0.0 3.26 MB

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

License: Apache License 2.0

JavaScript 2.35% TypeScript 97.65%

evm-provider.js's Introduction

@reef-defi/evm-provider.js

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

It can also be used as a Substrate provider to query or to interact with the Reef chain using the same calls as in the Polkadot.js.

Getting started

To create a Provider instance, use the following code:

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")
  })
);

with this object you can interact with the Substrate chain.

EVM interaction

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

Wallet

The Wallet class inherits Signer and can sign transactions and messages using a private key. When using the wallet for the first time, make sure to always claim the EVM account for the wallet you are using:

wallet.claimDefaultAccount()

before performing any EVM calls otherwise it may lead to InsufficientBalance errors.

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)

Examples

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

Develop

Install dependencies with yarn.

evm-provider.js's People

Contributors

ntduan avatar actions-user avatar jbargu avatar xlc avatar zjb0807 avatar frenkiee avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.