@acala-network/bodhi

bodhi.js SDK implements a web3 provider to allow existing Ethereum dApp to be able to interact with [Acala EVM](https://github.com/AcalaNetwork/Acala/tree/master/modules/evm).

Usage no npm install needed!

<script type="module">
  import acalaNetworkBodhi from 'https://cdn.skypack.dev/@acala-network/bodhi';
</script>

README

@acala-network/bodhi.js

bodhi.js SDK implements a web3 provider to allow existing Ethereum dApp to be able to interact with Acala EVM.

Getting Started

  • Install dependencies
yarn

Documentation

Most of the api of bodhi.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 "@acala-network/api";
import { Provider } from "@acala-network/bodhi";
import { WsProvider } from "@polkadot/api";

const evmprovider = 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 "@acala-network/bodhi";
const wallet = new Wallet("0xaa397267eaee48b2262a973fdcab384a758f39a3ad8708025cfb675bb9effc20", provider)

Wallet.claimEvmAccounts()

Use "keyringpair" to bind an evm account generated by "privateKey".

wallet.claimEvmAccounts()

Examples

deploy a contract

import { deployContract } from "ethereum-waffle";
import ERC20Abi from "../build/ERC20Abi.json";
import { Wallet } from "@acala-network/bodhi";
import { WsProvider, options } from "@acala-network/api";
import { Provider } from "@acala-network/bodhi";

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

const master = new Wallet("0xaa397267eaee48b2262a973fdcab384a758f39a3ad8708025cfb675bb9effc20", evmprovider)

const tokenInstance = await deployContract(master, ERC20Abi);