Giter VIP home page Giter VIP logo

evm-rpc's Introduction

EVM RPC Movement Network Proxy

This project demonstrates how to:

  • Call with EVM runtime on Movement.
  • Implement partial Ethereum RPC methods to interact with Solidity contracts using MetaMask and Remix.
  • Deploy Solidity contracts using Remix.
  • Perform contract read and write operations.

Implemented RPC Methods

The following RPC methods have been implemented to ensure interaction with Solidity contracts using MetaMask and Remix:

  • eth_chainId: Get the chain ID, currently fixed at 336.
  • net_version: Get the version number.
  • eth_gasPrice: Get the current gas price.
  • eth_blockNumber: Get the latest block number. Updated every 2 seconds.
  • eth_sendRawTransaction: Send signed raw transaction data. This checks the correctness of the signature.
  • eth_call: Invoke methods of smart contracts.
  • eth_getTransactionCount: Get the transaction count for a specific address.
  • eth_getTransactionByHash: Get transaction information based on the transaction hash.
  • eth_getTransactionReceipt: Get the transaction receipt based on the transaction hash.
  • eth_estimateGas: Estimate the gas consumption for a transaction. For successful transactions, if the gas is less than 21,000, it will return 21,000, but the actual consumed gas will be used when sending the transaction.
  • eth_getBlockByNumber: Get block information based on the block number.
  • eth_getBlockByHash: Get block information based on the block hash. Currently returns empty.
  • eth_getBalance: Get the balance of a specific address
  • eth_getCode: Get the code of a specific contract address.
  • eth_getStorageAt: Get the storage at a specific position in a specific address
  • eth_getLogs: Returns an array of all logs matching a given filter object.
  • web3_clientVersion: Returns the current client version.

Start Your EVM RPC

  • Set environment variables
mv .env.example .env
  • NODE_URL: The restful endpoint provided by the movement`

  • EVM_SENDER: The private key of a account to send EVM transactions to the Move. Please ensure that the account has enough MOVE native token to pay for the gas fee.(At least 10)

  • FAUCET_SENDER: The private key of a account to send bridge move native token to evm native token. Please ensure that the account has enough MOVE native token to pay for the gas fee and bridge token.(At least 10)

Then, run the following command to start the server:

npn run start

# This will start a server on port 3044

Add RPC to MetaMask

  1. Open MetaMask png
  2. Go to settings png
  3. Go to network settings png
  4. Add a network png
  5. Add network information (if it's local development, replace RPC with http://127.0.0.1:3044/v1) png

Connect MetaMask to Remix and Interact with Contracts

  1. Open Remix IDE, and open the built-in Storage contract png

  2. Compile the contract png

  3. Deploy the contract (make sure to select the network environment provided by MetaMask). After successful deployment, the contract address will appear in the bottom left corner for interaction.png

  4. Interact with the contractpng

Possible Issues

  • If you are using MetaMask to send transactions and a transaction fails, please follow these steps to clear the transaction history and retry. This is because the nonce does not change when an EVM transaction fails, and MetaMask will increment by default instead of fetching the latest nonce.
    • Go to Settings
    • Navigate to Advanced
    • Click on Clear Activity Tab Data
    • Confirm by clicking Clear

evm-rpc's People

Contributors

andyjsbell avatar

Watchers

Brian HH 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.