Skip to content

Ethereum RPC compatibility for Polkadot smart contracts

License

Apache-2.0, GPL-3.0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE2
GPL-3.0
LICENSE-GPL3
Notifications You must be signed in to change notification settings

agryaznov/ethink

Repository files navigation

Warning

This is an Early Prototype. It works, but not (yet) intended for production use!!

ink!   MetaMask logo

The ethink!

This project is an experimental add-on to Polkadot SDK's pallet-contracts to make it Ethereum RPC -compatible.

Tip

In a nutshell, it allows your parachain users to call ink! smart contracts via MetaMask.

Quickstart

Install customized cargo-contract tool:

Why?

Our 🦆-chain has pallet-contracts on board and at the same time works with Ethereum 20-bytes Account format. The latter fact is required so that our node can understand MetaMask-signed transactions. But for the existing ink! contracts tooling this is an unusual setting, as they're expected to work with 32-bytes long Accounts.

For this reason, to work with our ink! contracts on this chain, we use a fork of cargo-contract tool which speaks with our node the same language! Run this command to install it:

cargo install --git https://github.com/agryaznov/cargo-contract --branch v4-ethink --force

Run tests:

cargo test

Inject a well-known keypair of Baltathar into ethink! node's keystore:
(This step is needed only of you want to sign transactions on the node side)

cargo run -- key insert --dev --key-type "ethi" -d tmp --scheme ecdsa

Start the ethink! development node:

cargo run -- --dev

Open your MetaMask and add a new network:

Import a couple of pre-funded well-known development accounts into your MetaMask in order to be able to sign and send transactions.

Caution

It is highly recommended to use a separate MetaMask instance for this (e.g. in a dedicated browser profile), not to mix the development accounts (whose private keys are compromised by design) with your real money-holding accounts.

That's it! You should right away be able to communicate with the Duck 🦆 chain using your MetaMask. Let's see it in action, as described in the Demo section below.

End-to-end Tests

ethink! comes with e2e integration tests, grouped into test suites:

  • flipper: basic tests for the RPC methods;
  • erc20: ERC20 contract tests.
  • (more to be added later)

Use this command to run the integration tests (at the project root):

cargo test --test "*"

Documentation

rustdoc

Build documentation for the project crates:

cargo doc --document-private-items --open

The ethink! Book

The book is written with mdBook tool.
To install it, run:

cargo install mdbook

Then build and open the book:

cd docs/ethink-book
mdbook serve --open

Happy reading!

Demo 🧐

A comprehensive step-by-step Demo is described in the book chapter. You will be able to deploy an ink! contract to ethink-node and use the demo dApp via MetaMask. Go ahead and give it a try!

Useful Links

  • The table with all Ethereum RPC methods needed along with their description and implementation status.
  • Collection of curl composed request templates to Ethereum RPC exposed by ethink! node.

About

Ethereum RPC compatibility for Polkadot smart contracts

Resources

License

Apache-2.0, GPL-3.0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE2
GPL-3.0
LICENSE-GPL3

Stars

Watchers

Forks

Packages

No packages published

Languages