A smart-contract api and client for revm

Overview

revmup

A smart contract and client API for revm.

Features:

  • Auto-generate contracts that interact directly with revm without needing ethers provider
  • Contract API is almost identical to ethers generated contracts
  • Extract event logs

Setup

These crates have not yet been published. To experiment with the code you can try the following:

To run the basics example:

cargo run --bin basics

To generate contracts from abi you can run:

cargo run --bin revmup -- -i INPUT_PATH_OF_ABI_SON -o OUTPUT_PATH_OF_GENERATED_CODE

For help:

cargo run --bin revmup -- --help

Generate contract bindings for revm

Usage: revmup --input-path <PATH> --output-path <PATH>

Options:
  -i, --input-path <PATH>   Input path for contract artifacts/json files
  -o, --output-path <PATH>  Output path for generated code
  -h, --help                Print help

Example

// First you auto-generate the contract code from the ABI. In this example, 
// we're using MockERC20 that was generated from 'erc20.json'.

// Create the revm client
let client = ::std::sync::Arc::new(revmup_client::BasicClient::new());

// Funding amount in ether
let amt = ::ethers::core::utils::parse_ether(3u8).unwrap();

// Create 2 funded accounts
let accounts = client.batch_create_accounts_with_balance(2, amt).expect("acccounts");
let alice = accounts[0];
let bob = accounts[1];

// Deploy the contract (bob is the deployer)
let contract_address = MockErc20::deploy::<(String, String, u8)>(
        client.clone(),
        bob,
        ("hello".into(), "H".into(), 8u8)).unwrap();
println!("contract address: {}", addy);

// Create an instance of the contract
let erc = MockErc20::new(contract_address, client.clone());

// mint 2 tokens to bob
erc.mint(bob, 2u8.into()).send_transaction(bob).unwrap();

// check the token balance for bob
let bobs_tokens = erc.balance_of(bob).call().unwrap();
println!("token bal: {:?}", bobs_tokens);

//  Transfer a token to alice
let (_, logs) = erc.transfer(alice.into(), 1u8.into()).send_transaction(bob).unwrap();

// Note the call above returns event logs...we can view them looking for specific event types.  In the case 'Transfer' events
 let log_results = erc.get_transfer_filter_logs(logs.clone()).expect("parse log");
println!("transfer events: {:?}", log_results);

Standing on the shoulders of giants...

You might also like...
Vectis - Smart Contract Wallet

A smart contract wallet project to add functionality for users of DApps to manage their keys by allowing for recovery and account freeze, whilst preserving user control, and enabling relayer capability for gas provisioning

Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

The Ink! smart contract SDK for XVM interface

Ink! XVM SDK The Ink! smart contract SDK for XVM interface. This SDK contains contract wrappers and all middleware code to make XVM development easy.

Example NFT marketplace project using ink! smart contract.

NFT Marketplace project This contract is an example for the NFT marketplace implementation. License Apache 2.0 🏗️ How to use - Contracts 💫 Build Use

MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose.

MevWallet MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose. This repo contains the so

An EVM low-level language that gives full control over the control flow of the smart contract.

Meplang - An EVM low-level language Meplang is a low-level programming language that produces EVM bytecode. It is designed for developers who need ful

A brand-new multi-scenarios smart contract compiler framework

The Smart Intermediate Representation The Smart Intermediate Representation(short for IR) project is a new compiler framework intended for smart contr

My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.

60-days-of-solana My attempt at learning Solana program (smart contract) development through RareSkill's Solana course. Originally, I was trying to cr

Owner
Dave Bryson
Dave Bryson
A Simple Rust NFT API + Smart Contract

Rust NFT API Purpose Rust NFT API is a simple RESTful API developed in Rust that offers functionalities for creating, retrieving, and listing Non-Fung

Luis Soares 5 Feb 25, 2024
Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.

Heimdall is an advanced EVM toolkit which aims to make dealing with smart contracts on EVM based chains easier. Installation & Usage Heimdall's update

Jonathan Becker 489 Jan 2, 2023
Substrate NFT !ink smart contract base

Substrate !ink NFT simple implementation This is a simple working version of base NFT smart contract written using latest (as of this date) !ink 3.0.0

POLK4.NET 14 Dec 3, 2022
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

Zeke Medley 7 Oct 3, 2022
Testing a smart contract on the Solana blockchain

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Maurice 1 Oct 25, 2021
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

zeke 7 Oct 3, 2022
The NFT smart contract powering xyz on Terra

xyz NFT Contract This repository contains the core NFT smart contract that implements xyz, a base layer for metaverses on the Terra blockchain. The xy

null 16 Sep 25, 2022
An example smart contract that builds on top of xyz

xyz Guestbook Tutorial Contract This repository contains an example smart contract that illustrates how to build on top of the xyz NFT contract. This

null 5 Apr 4, 2022
Smart Contract for Terra Name Service

TERRA NAME SERVICE CONTRACTS Terra Name Service is to create easy-to-remember names for your Terra address like ‘dokwon.ust’ instead of ‘terra1...whez

null 12 Nov 23, 2022
Emerging smart contract language for the Ethereum blockchain.

Emerging smart contract language for the Ethereum blockchain.

null 1.4k Jan 9, 2023